473,549 Members | 2,573 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox1 problem

Jan
Hi there,

I'm a newbee in vb.net with the following problem:

4444528; Baltic Birch; 16.20; 0

I have more of these lines in a ListBox1.
Now I want to change the latest 0 with the value of a NumericUpDown1 (for
ex. 8)
My solution is this:
dim textline as string
dim item(3) as string

textline = lstWoodshop.Sel ectedItem

item = textline.Split( ";")
item(3) = " " & NumericUpDown1. Value
textline = Join(item, ";")

lstWoodshop.Ite ms.Insert(lstWo odshop.Selected Index, textline)

so far so good, but the old line with the 0 at the end still stays in the
ListBox1. How can I remove this? I tried many options, but i always get a
error?

Somebody knows they answer?
Thank you very much
Nov 20 '05 #1
2 3243
"Jan" <ca*****@planet .nl> schrieb
Hi there,

I'm a newbee in vb.net with the following problem:

4444528; Baltic Birch; 16.20; 0

I have more of these lines in a ListBox1.
Now I want to change the latest 0 with the value of a NumericUpDown1
(for ex. 8)
My solution is this:
dim textline as string
dim item(3) as string

textline = lstWoodshop.Sel ectedItem
I see, you are not using Option Strict, do you? :-)
item = textline.Split( ";")
item(3) = " " & NumericUpDown1. Value
textline = Join(item, ";")

lstWoodshop.Ite ms.Insert(lstWo odshop.Selected Index,
textline)

so far so good, but the old line with the 0 at the end still stays in
the ListBox1. How can I remove this? I tried many options, but i
always get a error?

Somebody knows they answer?
Thank you very much


Usually it is better to keep the data in variables, change them, and reflect
the changes in the UI, i.e. in the listbox. There are different approaches.
One is:
1. Write a class containing the data (4444528, "Baltic Birch", etc.).
2. "Override" the ToString function that returns a string to be displayed in
the listbox.
3. Create instances of the class and add them to the listbox. The listbox
calls the ToString method of every object added to get the string to be
shown.

Unfortunately I didn't find a way to make the listbox look for the current
values and display them whenever you change them. So, you can get the item
from the listbox, change the value, remove the item (Items.Remove) and add
it again (Items.Insert). If there is a small number of list items and/or
they change rarely, an alternative is to clear the listbox and fill it again
(to avoid writing a "change item procedure").
--
Armin

Nov 20 '05 #2
Hi,

listbox1.items. removeat.

dim textline as string
dim item(3) as string

textline = lstWoodshop.Sel ectedItem

item = textline.Split( ";")
item(3) = " " & NumericUpDown1. Value
textline = Join(item, ";")
lstWoodshop.Ite ms.RemoveAt(lst Woodshop.Select edIndex) lstWoodshop.Ite ms.Insert(lstWo odshop.Selected Index, textline)
Ken
--------------------------
"Jan" <ca*****@planet .nl> wrote in message
news:x2******** *************** *******@40tude. net... Hi there,

I'm a newbee in vb.net with the following problem:

4444528; Baltic Birch; 16.20; 0

I have more of these lines in a ListBox1.
Now I want to change the latest 0 with the value of a NumericUpDown1 (for
ex. 8)
My solution is this:
dim textline as string
dim item(3) as string

textline = lstWoodshop.Sel ectedItem

item = textline.Split( ";")
item(3) = " " & NumericUpDown1. Value
textline = Join(item, ";")

lstWoodshop.Ite ms.Insert(lstWo odshop.Selected Index, textline)

so far so good, but the old line with the 0 at the end still stays in the
ListBox1. How can I remove this? I tried many options, but i always get a
error?

Somebody knows they answer?
Thank you very much

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

117
7111
by: Peter Olcott | last post by:
www.halting-problem.com
28
5177
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass(); .... and then call the virtual method, why is it that the base class's method is called instead of the overridden method? How do I fix this if I...
4
6170
by: Bilo | last post by:
I dont know what i am doing false. the code : private void button2_Click(object sender, System.EventArgs e) { foreach (string filename in listBox1.SelectedItems) listBox1.Items.Remove(filename); } gives me the error :
1
1173
by: Jan | last post by:
Hi there, Is there a solution to the following problem: I've got a button1 in form2, with this button1 I want to fill a listbox in form1. How can I make listbox1 in form1 accesable for form2?? thank you
2
1334
by: Bernie Yaeger | last post by:
I want to open a window with a listbox (custlist) in it, but I want to automatically select a certain item in the listbox, and have it be the correct selectedindex. The call to open this window knows what it seeks, which is variable. So one time I may wish to select item 45 (marsdon) and sometimes item 1997 (albert). How can I do this? ...
2
1531
by: Krupau | last post by:
Hi Friends, I am getting following error message.. I am so fed up of this error. I am trying to solve it so long time. Please help me!! .Thanks in advance... Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace...
8
2690
by: XxMaSterXx | last post by:
My program Extracts certain urls to a Listbox Example listbox1 urls http://www.thescripts.com/forum/newthread.php?do=newthread&f=132 http://www.thescripts.com/forum/newthread.php?do=newthread&f=131 http://www.thescripts.com/forum/newthread.php?do=newthread&f=130 http://www.thescripts.com/forum/newthread.php?do=newthread&f=135 I would...
5
2456
by: BlackBox | last post by:
I have a Listbox1 in the main form and I can add listbox1 items in the parent form. But when I close the parent form Listbox1 in the main form does not get refresh. I need to re-open the app. Any idea on how to refresh items in the main from from a parent form without opening the app. -Thanks
3
1356
by: rprasad79 | last post by:
Hi Team, Here goes the scenario... i have a listbox1 which contains continent details. if i select any one of the continent, then the next list box which contains the country list should display the countries corresponding to the continent. similarly when i select the corresponding country, i should get the list of cities which are there in...
0
7527
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7459
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7726
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7485
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5097
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3488
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.