Click here to Skip to main content
15,911,848 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hello
I am working on winforms and lately i have been asking some basic questions so bare with me.
So my question is i have 2 forms(mainform, add_valueform).In my main form i have a ListBox whihc has following meberes(salary,savings) this listbox is called listbox1, there is a Button also called button 1 and lastly a textbox called sumBox.Now when user slects a listbox member and press the button the of the mainform, add_valueForm opens and in add_value form there is just one textbox in which user enters a value which should be integer now i want that value to be assigned to that particular listbox member. I can launch a form etc but i cannot find a way to assign the value to listbox member.

I hope you guys understand.

thanks anyways
Posted
Updated 28-Dec-13 14:07pm
v2
Comments
Sergey Alexandrovich Kryukov 28-Dec-13 20:08pm    
I added the important tag to a question. Please see my answer.
—SA
BillWoodruff 28-Dec-13 22:12pm    
How to get a value from one Form to another is a frequently asked and answered question here.

Are you aware that a ListBox does not support "real" columns, like a ListView ? I suspect what you want to do will probably require using a ListView.

What's unclear is:

1. what exactly do you mean by "value assigned" to a ListBox member ? do you mean displayed inside the ListBox on the same line the Item occurs on ?

2. you mention a TextBox, 'sumBox: what's that do ?

3. why are you using a separate Form to just get a value to add to a value on the first Form ?

1 solution

My past answer should give you the idea: combobox.selectedvalue shows {} in winform[^].

If you still did not get it, please ask some follow-up questions, I'll answer.

—SA
 
Share this answer
 
Comments
loraloper_22 28-Dec-13 20:30pm    
Well to begin with i am quite lost.If i understand you correctly so basically i need to create objects and pass them to list box. So my guess would be i need to create classes for salaries and savings etc(m not really if that is what you meant). Say if i do it i want the in UI the name salary to appear how i am gonna do this. Again i did mention in the beginning i am just a beginner. If there is an alternate may be easy approach for my likings it would be great. However i really appreciate the effort you put in to explain.
Thanks a lot
Sergey Alexandrovich Kryukov 28-Dec-13 21:06pm    
Why "alternate"? Don't you think that there is a good way for experienced and better way for beginners? If it would be so, why would the experienced wouldn't use it, too? You should not look for an "easy approach", you need to look for the better one.

What does it mean, "not really if that is what you meant"? Yes, you need classes for salaries and savings, and the like, how else? How you can make the names (strings) to appear, I explained exactly: override System.Object.ToString() the way you need.

So, if you really want to solve the problem, it's time to start working at it. Please show what you got and ask further questions if you stuck. Please, try to set aside the irrelevant information. "I am quite lost" and "I am just a beginner" is not informative and is irrelevant. The compiler and other software works the same way for the beginners...

—SA
loraloper_22 29-Dec-13 17:23pm    
thanks i was able to solve it to some extent.:)
Sergey Alexandrovich Kryukov 29-Dec-13 17:33pm    
Very good.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900