Hi all,
i'm having two forms.
Form1 contains a textbox 'txtId'.Form2 contains a grid.
Based on the Id in txtId, the grid should get filled in Form2.
When i try to access the text in TxtId in my Form2,i need to instantiate the Form1 class which leads to the creation of new object which contains 'null' for my TxtId.
Help me to overcome this problem,immediately!!!!!!
Thanks in advance,
Padma
padmavathy thiruvenkadamPosted Oct 11, 2005, 7:17 AM
Hi Matt Speller,
Thanks for spending your time to reply me.
Sorry, i didnt mention that i'm using "Composite UI Application Block"(CAB) in Visual Studio 2005 Beta 2 .
Thank u once again
Matt SpellerPosted Oct 11, 2005, 6:45 AM
If the textbox is a value that is required by the grid at all times, then the grid could show the form1 as a modal/non modal dialog when the load method on form2 is run. This form can be held as a class level variable.
The form1 can have a public property exposing the value of the textbox.
Another alternative is to create an instance of the form1 when the user presses a button on form2. Create a modal dialog and when the user closes this window if the dialogresult == ok then take the value from the property before disposing of the form1 instance and use as required.
Something must have to create an instance of the form1 to access the value, so I would create it up front in the form2 code, or even better have a controlling class create both forms and passing the reference to form1 into form2.
Hope this helps