Forum > General

Edit ListBox item on double click

<< < (2/3) > >>

That example you linked to has leaks in it, the EDIT control isn't being freed.

In any case, you can use a TStringGrid. .

 Set fixed columns to 0 and cell count to what you want. Turn off the grid lines etc.

 In the end you get what looks like a ListBox but the string grid has Editors built in that you can configure.

Building on KodeZwergs example, couldn't you do this:

--- 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.ListBox1DblClick(Sender: TObject);var  lb: TListBox;  s: string;begin  lb := (Sender as TListBox);  if ((lb = nil) or (lb.ItemIndex < 0)) then    Exit;  // inputbox('caption','message','default text'); -> returns new text or untouched string  s := InputBox('Edit Item','Please enter new text for item:',lb.Items[lb.ItemIndex]);  // i  think this should work, untested...  lb.Items[lb.ItemIndex] := s;end; Just my 2 cents...  :)
Regards Benny

Try project in attachment.
It's based on your link. I added handling of enter and escape keys.
It works on Windows 11.

Almost solved. I changed TEdit for TCombobox. After the combobox is created i need to click it twice to open the dropdownlist. Can i simulate a mousclick?

 Using my old Lazurus I see the AutoDropDown drops down when you select a different control.

 Using the Trunk, it seems AutoDropDown does not work anymore, does nothing.

 as for the older test, all I did was change the TAB order and that cause the combobox to drop down when I clicked on a different control.

  But like i said, don't seem to work anymore in trunk, unless there is some secret code I 'am missing?

   Apparently there is a bug in my older version of Lazurus.
  I am not going to worry about it.
But in any case you can use the DroppedDown property at anytime to drop it, in the OnEnter, onClick etc.


[0] Message Index

[#] Next page

[*] Previous page

Go to full version