Solved

Edit Listbox's data at run time

Posted on 1998-03-15
6
413 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

746 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

11 Experts available now in Live!

Get 1:1 Help Now