?
Solved

Edit Listbox's data at run time

Posted on 1998-03-15
6
Medium Priority
?
473 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
[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
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 40 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 1 hour left to enroll

777 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