trichview.com

trichview.support




Re: tables, select, scrollto


Return to index


Author

Message

Sergey Tkachenko

Posted: 10/30/2003 21:22:56


So you need to scroll to the specific cell (row) in the table.


You can use the the function ScrollToChar below:


function FindFirstTable(rv: TCustomRichView): TRVTableItemInfo;

var i: Integer;

begin

  for i := 0 to rv.ItemCount-1 do

    if rv.GetItemStyle(i)=rvsTable then begin

      Result := TRVTableItemInfo(rv.GetItem(i));

      exit;

    end;

  Result := nil;

end;


function FindRowStartingWithChar(table: TRVTableItemInfo; ch: Char):

Integer;

var r: Integer;

    s: String;

begin

  for r := 0 to table.Rows.Count-1 do

    if (table.Cells[r,0]<>nil) and

       (table.Cells[r,0].GetRVData.GetItemStyle(0)>=0) then begin

      s := table.Cells[r,0].GetRVData.GetItemTextA(0);

      if (s<>'') and (s[1]=ch) then begin

        Result := r;

        exit;

      end;

    end;

  Result := -1;

end;


function ScrollToChar(rv: TCustomRichView; ch: Char): Boolean;

var table: TRVTableItemInfo;

    r, x, y: Integer;

begin

  Result := False;

  table := FindFirstTable(rv);

  if table=nil then

    exit;

  r := FindRowStartingWithChar(table, ch);

  if r=-1 then

    exit;

  table.Cells[r,0].GetOriginEx(x, y);

  rv.ScrollTo(y);

  Result := True;

end;


Notes:

1) They assume that you use Cell.Clear; Cell.AddNL instead of Cell.Add

2) FindRowStartingWithChar returns an index of row. You can use search in

your stringlist instead.



"ian" <[email protected]> wrote in message news:[email protected]...

>

> Hi Sergey,

>

> Yes i have only 1 table .. I use ADDNL because i have to verify each

caracters

> (display smiley with AddPictureEx) for each lines.

>

> I can use my TStringList for searching first caracter.

>

> I "just" need that :

>

> - search for first letter "a" or "c" or "g" (...) in Tstringlist.

> - example, "C" started in 122nd line in TStringList

>

> I need to scroll bar to the 122nd item of my table (focus 122nd line)

>

> I use MouseMove event for Highlighting cell (from QUIZZ example) and its

> work fine. I don't found function like :

>

> GetItemPosAt(122,x,y); // Get Y position of the 122nd item

> ScrollTo(y);

>

> You see what i mean ?

>

> Thanks

>

>





Powered by ABC Amber Outlook Express Converter