{"id":84,"date":"2007-05-12T13:46:15","date_gmt":"2007-05-12T11:46:15","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/create-editable-listbox\/"},"modified":"2007-05-12T13:46:17","modified_gmt":"2007-05-12T11:46:17","slug":"create-editable-listbox","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/create-editable-listbox\/","title":{"rendered":"Create Editable ListBox"},"content":{"rendered":"<p><em>NOTE : This will also work with an OwnerDraw ListBox<br \/>\nBut be sure you &#8220;pad&#8221; the Left Property of the Edit so<br \/>\nAny icons etc, do not get covered up by the TEdit.<br \/>\nAnd also be aware that there will be a bit of &#8220;flashing&#8221;<br \/>\nif you do use an OwnerDraw ListBox<br \/>\n<\/em><br \/>\n[code lang=&#8221;delphi&#8221;]\/\/This is in a Popup menu.<br \/>\nprocedure TForm1.Change1Click(Sender: TObject);<br \/>\n Var<br \/>\n  I9 : Integer;<br \/>\n  ColInt : Integer;<br \/>\n  LRect : TRect;<br \/>\nbegin<br \/>\n LRect := ListBox1.ItemRect(ListBox1.ItemIndex);<br \/>\n\/\/Set the size of the TEdit<br \/>\n  Edit1.Top := LRect.Top + 1;<br \/>\n  Edit1.Left := LRect.Left + 1;<br \/>\n  Edit1.Width := ListBox1.Canvas.TextWidth(ListBox1.Items.Strings[ListBox1.ItemIndex]) + 6;<br \/>\n  Edit1.Height := (LRect.Bottom &#8211; LRect.Top) + 1;<\/p>\n<p>  Edit1.Text := ListBox1.Items.Strings[ListBox1.ItemIndex];<br \/>\n   ListBox1.Selected[ListBox1.ItemIndex] := False;<br \/>\n    Edit1.Visible := True;<br \/>\n   Edit1.SelectAll;<br \/>\n  Edit1.SetFocus;<br \/>\nend;<\/p>\n<p>procedure TForm1.ListBox1Click(Sender: TObject);<br \/>\nbegin<br \/>\n  Edit1.Visible := False;<br \/>\nend;<\/p>\n<p>procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);<br \/>\n Var<br \/>\n  I8 : Integer;<br \/>\nBegin<br \/>\n If Key = #13 Then<br \/>\n  Begin<br \/>\n   I8 := ListBox1.ItemIndex;<br \/>\n   ListBox1.Items.Delete(ListBox1.ItemIndex);<br \/>\n   ListBox1.Items.Insert(I8, Edit1.Text);<br \/>\n   Edit1.Visible := False;<br \/>\n   Key := #0;<br \/>\n  End;<br \/>\nEnd;[\/code]<\/p>\n<p>[tags]Delphi, Components, ListBox[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NOTE : This will also work with an OwnerDraw ListBox But be sure you &#8220;pad&#8221; the Left Property of the Edit so Any&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[11],"tags":[90,75,91],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p71Tml-1m","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/84"}],"collection":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}