Jump to content


Photo

Lost grid selection after TWebBrowser clicked..


  • Please log in to reply
4 replies to this topic

#1 Oklawa

Oklawa
  • Members
  • 7 posts

Posted 14 December 2007 - 07:54 PM

Grid ver: 4.2.2, 4.2.1
SelectFullRow is True
ColMoving is disabled
GoGrid is true

CODE
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, NxColumns, NxColumnClasses, ExtCtrls, NxScrollControl, NxCustomGridControl,
  NxCustomGrid, NxGrid, ActiveX, MsHtml, SHDocVw;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    NextGrid1: TNextGrid;
    Splitter1: TSplitter;
    NxTextColumn1: TNxTextColumn;
    NxTextColumn2: TNxTextColumn;
    NxTextColumn3: TNxTextColumn;
    NxTextColumn4: TNxTextColumn;
    NxTextColumn5: TNxTextColumn;
    NxTextColumn6: TNxTextColumn;
    NxTextColumn7: TNxTextColumn;
    NxTextColumn8: TNxTextColumn;
    NxTextColumn9: TNxTextColumn;
    WebBrowser1: TWebBrowser;
    procedure FormCreate(Sender: TObject);
    procedure NextGrid1SelectCell(Sender: TObject; ACol, ARow: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var i,y:shortint;
begin
for i:=0 to 30 do
  begin
    nextgrid1.AddRow(1);
     for y:=0 to nextgrid1.Columns.Count-1 do
       nextgrid1.cell[y,i].AsString:=inttostr(i)+'-'+inttostr(y);
  end;
end;

procedure TForm1.NextGrid1SelectCell(Sender: TObject; ACol, ARow: Integer);
var i:shortint;
    v: Variant;
    HTMLDocument: IHTMLDocument2;
    HTMLString:WideString;
begin
  HTMLString:='';
  HTMLString:=HTMLString+'<html>';
  HTMLString:=HTMLString+'<head>';
  HTMLString:=HTMLString+'</head>';
  HTMLString:=HTMLString+'<body>';
    for i:=0 to nextgrid1.Columns.Count-1 do
      HTMLString:=HTMLString+nextgrid1.Columns[i].Header.Caption+' : '+
                             nextgrid1.Cell[i,nextgrid1.SelectedRow].AsString+'<BR>';
  HTMLString:=HTMLString+'</body>';
  HTMLString:=HTMLString+'</html>';
  if not assigned(WebBrowser1.Document) then WebBrowser1.Navigate('about:blank')
                                        else (WebBrowser1.Document as IHTMLDocument2).close;
  HTMLDocument := WebBrowser1.Document as IHTMLDocument2;
  v := VarArrayCreate([0, 0], varVariant);
  v[0] := HTMLString;
  HTMLDocument.Write(PSafeArray(TVarData(v).VArray));
end;
end.


Source

This code is for only test my problem.
After webbrowser clicked grid lost selection until restart application.

What's wrong and how can I solve it?
Thank you..

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 15 December 2007 - 01:24 AM

Hello Oklawa,

I will test it and hopefully find a problem.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Oklawa

Oklawa
  • Members
  • 7 posts

Posted 22 December 2007 - 01:45 PM

rolleyes.gif Anything about this problem?

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 22 December 2007 - 03:00 PM

Hello Oklawa,

It is a quite strange bug. I will need to look more, it may be that TWebBrowser made some conflict (but other components like TNextInspector work fine).

But I have find one workarond.

Temporally set focus to some other component (like TEdit) and then set it back to grid.

Set this at the end of NextGrid.OnSelectCell event:

CODE
  Edit1.SetFocus;
  NextGrid1.SetFocus;


I will definitelly need more time to find it sad.gif

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#5 Oklawa

Oklawa
  • Members
  • 7 posts

Posted 22 December 2007 - 04:21 PM

Thank you Boki.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users