Forum > Beginners

Scrool to a position in a Memo(Solved)

(1/2) > >>

JLWest:
Trying to scroll to a position in a memo.
This code dose nothing.
What am I missing?
Thanks



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.ListBox1Click(Sender: TObject);   Var i : Integer;   Item : String;  begin    i := ListBox1.ItemIndex;    if i = -1 then exit;    Item := Listbox1.Items[ i ];    Item := Item + ':';    Memo1.selstart:= Pos(Item,Memo1.text)-1;    Memo1.SelLength:=0;    Memo1.SetFocus;;  end;              

trev:
Works for me - see pic (I changed Memo1.SelLength:=0; to :=2 to show search hit)

JLWest:
@trev

Not here.

I attached a self contained demo;

bytebites:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  Item := Item + ':';
The listbox items have colon padded "Item1:".

trev:
@JLWest: I compiled my macOS trivial demo program on Windows 10 and it still works. I've attached the trivial project. Does this work for you? It does for me.

As bytebites says, in your demo you've added the colon to the Item once in the original listbox text and again in the onlick handler which is why that fails.

Navigation

[0] Message Index

[#] Next page

Go to full version