Solved

Editing Listbox on runtime

Posted on 2004-03-26
4
264 Views
Last Modified: 2010-04-05
Hey,

Can someone tell me how I can edit my listbox on runtime to when I select a item in the listbox and then click and button it will add "Locked" after the string in the listbox.

Cheers,

Computer Programer
0
Comment
Question by:computerprogramer
  • 2
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 40 total points
ID: 10685217
procedure TForm1.Button2Click(Sender: TObject);
begin
ListBox2.Items[ListBox2.ItemIndex] := ListBox2.Items[ListBox2.ItemIndex]+' Locked';
end;
0
 
LVL 17

Expert Comment

by:mokule
ID: 10685234
or better with check

procedure TForm1.Button2Click(Sender: TObject);
begin
if (ListBox2.Items.Count > 0) and (ListBox2.ItemIndex >= 0) then
  ListBox2.Items[ListBox2.ItemIndex] := ListBox2.Items[ListBox2.ItemIndex]+' Locked';
end;
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 10685235
Is this what you are looking for?
(Add text 'Locked' to current item of list box when a button is clicked)

procedure TForm1.Button1Click(Sender: TObject);
begin
  If ListBox1.ItemIndex >= 0 then
  Begin
    ListBox1.Items[ListBox1.ItemIndex] := ListBox1.Items[ListBox1.ItemIndex] + 'Locked';
  End;
end;

...Shu
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 10685282
3 minutes: too late.
:-)
...Shu
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now