Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

How to get the selected item of combox in form to another form.(connect and Form1 )

in connect form :

C#
<pre lang="c#"><pre lang="sql">public string machineId
        {
            get
            {
                return comboBox1.SelectedItem.ToString();
            }
            set
            {
                comboBox1.Text = value;
            }
        }</pre></pre>

and in Form1;

<pre lang="c#"><pre lang="c#">
                Connect c = new Connect();
                String machineid=c.machineId;


so i got the error as:at String machineid=c.machineId

Object reference not set to an instance of an object.
Posted

1 solution

Hi, here is an article that describes the diffrents techniques used to pass values between pages.


Passing Data Between Forms[^]



Hope it helps
 
Share this answer
 
v2
Comments
Member 10263519 20-Feb-14 4:11am    
it's winforms application.that link is giving error it's not opening
Ziee-M 20-Feb-14 5:48am    
sorry, the link works now, the article is about winforms, there are better article out there but i couldent find them, there are other techniques not described in there so do some resarch to find them out.

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