Solved

Edit Listbox's data at run time

Posted on 1998-03-15
6
424 Views
Last Modified: 2008-02-01
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.)
0
Comment
Question by:lkw022798
6 Comments
 

Expert Comment

by:tapsbin
ID: 1459141
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

0
 

Author Comment

by:lkw022798
ID: 1459142
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?
0
 

Expert Comment

by:tapsbin
ID: 1459143
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

0
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.

 

Author Comment

by:lkw022798
ID: 1459144
taps, i dont understand what you are talking about.
can i set certain property to make my listbox editable at runtime?
0
 

Expert Comment

by:Slasher
ID: 1459145
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.
0
 

Accepted Solution

by:
mattyboy earned 20 total points
ID: 1459146
Try this:

Add an invisible TextBox to your form.  Set its appearance to Flat and it border to None.  Then, when you want to edit an item in a list box, determine the position of the selected item.  You can do this using some simple API calls.  Once you have determined the size and position of the selected item, set your invisible text box to the same size and position, change its text property to the value of the list item, and make it visible.  Then, on the change event of the TextBox, set the corresponding list item's value equal to the value of the TextBox.  Then, when you are done editing (perhaps by pressing Enter), set the TextBox's visible property back to false.

Let me know if you need help with the APIs

mattyboy
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

Suggested Solutions

Title # Comments Views Activity
Help in WHSCRIPT 9 47
Validating VB6 Function 19 56
Visual Basic Excel Formatting error 4 83
SLMGR Switches Are Not Working On KMS Host 3 67
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

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

18 Experts available now in Live!

Get 1:1 Help Now