Solved

Editing Listbox on runtime

Posted on 2004-03-26
4
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…

759 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