how to access the data stored in one form's control into other form belonging to the same project in C#
-
hi i have a treeview control in one form which has some nodes and i need to display them as a list in some other form's combobox control and these two forms belonging to the same project i created an instance of form1 in form2 but its not showing the controls associated with form1 with my instance object. please suggest how to get the data of form1 into form2 thanks in advance.
-
hi i have a treeview control in one form which has some nodes and i need to display them as a list in some other form's combobox control and these two forms belonging to the same project i created an instance of form1 in form2 but its not showing the controls associated with form1 with my instance object. please suggest how to get the data of form1 into form2 thanks in advance.
-
hi i have a treeview control in one form which has some nodes and i need to display them as a list in some other form's combobox control and these two forms belonging to the same project i created an instance of form1 in form2 but its not showing the controls associated with form1 with my instance object. please suggest how to get the data of form1 into form2 thanks in advance.
Declare control on form1 as public,these will be available on another form via object of form1 Atul kumar
-
hi i have a treeview control in one form which has some nodes and i need to display them as a list in some other form's combobox control and these two forms belonging to the same project i created an instance of form1 in form2 but its not showing the controls associated with form1 with my instance object. please suggest how to get the data of form1 into form2 thanks in advance.
This is asked so often, I keep meaning to write an article on it.
kalaveer wrote:
i created an instance of form1 in form2
That won't help, it's a different instance to the one that has the data you need You can pass the right instance of form1 to form2 as a parameter, or, better yet, use delegates to pass data between forms.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
This is asked so often, I keep meaning to write an article on it.
kalaveer wrote:
i created an instance of form1 in form2
That won't help, it's a different instance to the one that has the data you need You can pass the right instance of form1 to form2 as a parameter, or, better yet, use delegates to pass data between forms.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
hi yes he is right. u would be able to access information of ur control as creating an object would create new instance of form1 i just told that declaring a control as public would make that control accessible in another form..But to pass value u need to use delegate to communicate between them. cheers.
-
Declare control on form1 as public,these will be available on another form via object of form1 Atul kumar
Yes, when I write my article, I will cover this approach. It's very nasty, you should never do this. At a minimum, expose properties that get ( for example ) the text of a textbox, but not the textbox itself. This isn't VB, we're supposed to know about OO.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
hi i have a treeview control in one form which has some nodes and i need to display them as a list in some other form's combobox control and these two forms belonging to the same project i created an instance of form1 in form2 but its not showing the controls associated with form1 with my instance object. please suggest how to get the data of form1 into form2 thanks in advance.