Forum > General

Edit ListBox item on double click

<< < (3/3)

Hansvb:
Looks like  I found it.

This creates a TComboBox dynamically and when you click on the arrow down the itemslist collapse. No need anymore to click it twice.


--- 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 TFrm_main.ListBoxOnDblClick(Sender: TObject);var  r: TRect;  cb: TComboBox;  Level : Byte;  itemsNames : AllItemsObjectData;  i : Integer;begin  FCurrListBox := Sender as TListbox;  if FCurrListBox.ItemIndex < 0 then Exit;   cb := TComboBox.Create(Self);  cb.Font.Size := 9;  r := FCurrListBox.ItemRect(FCurrListBox.itemindex);  r.topleft := FCurrListBox.ClientToScreen(r.topleft);  r.BottomRight := FCurrListBox.clienttoscreen(r.bottomright);  r.topleft := ScreenToClient(r.topleft);  r.BottomRight := screenToClient(r.bottomright);   Level := StrToInt(GetNumbers(FCurrListBox.Name));  itemsNames := GetListBoxItems(Level);  for i := 0 to Length(itemsNames)-1 do begin    cb.Items.Add(itemsNames[i].Name);  end;   cb.Text :=  FCurrListBox.Items[FCurrListBox.itemindex];  cb.setbounds(r.left, r.top-2, FCurrListBox.clientwidth, r.bottom - r.top + 4);  cb.OnExit := @ComboBoxDone;  cb.OnMouseDown:= @ComboBoxMouseDown;  cb.OnKeyUp := @ComboBoxKeyUp;  cb.Parent := Self;//  SetCapturecontrol(cb);  <== when active you have to click the drowdown arrow twice.    cb.SetFocus;end;  

Navigation

[0] Message Index

[*] Previous page

Go to full version