473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Passing the listBox1.SelectedItem value from one form to another?

The output for the listBox1.SelectedItem in Form1 is a path (eg: "E:\\New Files")
Now Form2 basically contains the code for an application. I want to use the output of this selectedItem in Form2.
Please help me as I am very new to C#.
Thank you in advance
Apr 8 '13 #1
1 1323
vijay6
158 100+
Hey user033088, inside the 'listbox1_SelectedIndexChanged' event write the following line,

Expand|Select|Wrap|Line Numbers
  1. Form2 Frm2 = new Form2(Convert.ToInt32(listbox1.SelectedItem));

And inside the 'Form2' add a new constructor with one integer argument. Like as follows,

Expand|Select|Wrap|Line Numbers
  1. public Form2(int value)
  2. {
  3.         MessageBox.Show(value.ToString());
  4.         // Do your work
  5. }
Apr 9 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bernard Davis | last post by:
Hi, I need to pass the value held in a field in one form and have it appear in another form. I specifically don't want to have to refer to the original form name as it has passed, because I...
3
by: JoeD | last post by:
I am creating a popup window based on a value that is sent to me. Another program is calling the popup windows. Basically by calling the popup program: C:\screenpop UUI: XXXXXXXX My question...
4
by: Mike | last post by:
Hello, I have a web form with a Listbox. When trying to read the value of the last selected item with the statement below, I always get the first item, even if the user selected another item:...
2
by: Dave | last post by:
Greetings, How can I access the selecteditem.value property for a listbox that is in a user control (.ascx) inside of my .aspx page? Thanks, -Dave
4
by: Martyn Fewtrell | last post by:
I want to update a database record with a number of fields - doesn't sound to difficult at this stage! I have a system to select the correct record from the database and load the data into a...
4
by: darrel | last post by:
what is the difference between these? I always end up typing 'selectedvalue' only to have problems and then realize I meant to use selecteditem.value (the value of the selected item). When would...
2
by: HH | last post by:
Hi, I have a dropdown list that is datafilled via a SQL table. The text part is always unique. (A list of countries) Each country is assigned one of three numbers. (This being the 'value' of...
0
by: Phillip Vong | last post by:
Doing this in VS2005. ASPX in VB code. This image details my problem. http://ebay.philvong.com/help.jpg I have a simple FormView1 bound to a SQLDataSource1. In edit mode, Label1 is bound to a...
2
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...
1
by: Andy B | last post by:
I have a wizard that has 3 wizardSteps. The first one is selecting a NewsArticle from the combobox to edit. The second wizardStep (pressing next) loads the whole database record into a form. The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.