Link to home
Start Free TrialLog in
Avatar of lkw022798
lkw022798

asked on

Edit Listbox's data at run time

Can anybody tell me whether it is possible to edit listbox's data  at run time .
if yes, how? (my listbox is not bound to any datacontrol.)
Avatar of tapsbin
tapsbin

Supposing you have following elements in a list box control.

Tapasvi
Baku
Asit
Shreyas

Now, you can access these elements as

   lstItem.List(0) for the first element   - Tapasvi
   lstItem.List(1) for the second element  - Baku
   lstItem.List(2) for the third element   - Asit

where lstItem is a name of list box control.
At the time of running your application you reassign the value
to your current index value item...

   lstItem.List(lstItem.NewIndex) = "Your Data Value"

I think these should solve your problem.

For further clarification please let me know...

Thanks,

TAPS

Avatar of lkw022798

ASKER

taps,pardon me, but i still do not see whether i can edit those data at run time . right now, when i run the application, i can select the items but not manaully change the contents.
if i m not wrong , you are giving the user the ability to key in new data right?
yes, that's true. What i mean is...

allow to enter the user in a text box control...and reassign the
value to the selected element of a listbox control...

Thanks,

TAPS

taps, i dont understand what you are talking about.
can i set certain property to make my listbox editable at runtime?
ikw,
        A listbox is not editable at anytime (you cannot key in data into it)
        What you might want to do is to have a text box which accepts the data
        and adds it into a listbox like what tapsbin has mentioned. If that is not
        appropriate, you can also use a multi-line text box (which looks like a listbox)
        You may set the (text1.locked) property to FALSE to prevent the user from
        editing the contents and set it to TRUE for editing purposes.
ASKER CERTIFIED SOLUTION
Avatar of mattyboy
mattyboy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial