Solved

Edit Listbox's data at run time

Posted on 1998-03-15
6
470 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

691 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