Thanks Salushan for the answer, I used what you recommend and it worked. Regards!
On Feb 13, 1:33 pm, Caio Dias <[email protected]> wrote: > you can use a singleton: > *http://en.wikipedia.org/wiki/Singleton*<http://pt.wikipedia.org/wiki/Singleton> > > 2009/2/13 sallushan <[email protected]> > > > > > > > Thanks buddy :) > > > On Feb 13, 11:33 am, Cerebrus <[email protected]> wrote: > > > Seriously, Arsalan ! That's another great answer! Keep up the great > > > work. ;-) > > > > On Feb 13, 10:40 am, sallushan <[email protected]> wrote: > > > > > @Brandon: OP is talking about Windows Forms (see the link he has > > > > provided). > > > > > @Nacho108: > > > > I assume you have understood the basic concept of passing data between > > > > forms. Now coming to your issues: > > > > > 1) In this article, every time I click the button it creates another > > > > instance of the forms. > > > > > Ans: Because each time the button is clicked, new instance of form is > > > > created which is then shown. > > > > Solution #1: > > > > Use Application.OpenForms or create your own list of open forms. > > > > Iterate through them to see whether the form is still open, if it is > > > > then set focus on it. > > > > Solution #2: > > > > Use the class/module level variable of form and check the variable if > > > > Form still exists (i.e. NOT closed and disposed) then set focus on it. > > > > Solution #3: > > > > Use the "ShowDialog()" method of Form. > > > > > 2) In my case I'm trying to access the main form (in this case a > > > > simple label) that was created by the visual studio and which is > > > > already opened, from another form that is opened after that. > > > > > Ans: If you are trying to access the "First" form "Second" form then > > > > you need a reference of "First" form on "Second" form. > > > > Solution #1: > > > > If you have used the "ShowDialog()" method, then (after you call the > > > > "ShowDialog()" method) check the properties of "Second" form and make > > > > Changes on "First" form appropriately. > > > > Solution #2: > > > > If you have used the "Show()" method, then you need to use the > > > > delegates/events in order to notify the "First" form that some changes > > > > have occurred. > > > > > Regards, > > > > Arsalan Tamiz > > > > > On Feb 12, 8:25 pm, Nacho108 <[email protected]> wrote: > > > > > > Hi! > > > > > > I'm having the c# typical beginner's problem (as far as I can read in > > > > > forums) of passing data between forms. > > > > > I was reading a lot about the subject but all the solutions I read > > are > > > > > about creating a NEW instance of a form and then use delegates, or > > > > > objects or class properties, etc. Like in this article: > > > > > >http://www.codeproject.com/KB/cs/pass_data_between_forms.aspx > > > > > > But the problems I'm having are: > > > > > 1) In this article, every time I click the button it creates another > > > > > instance of the forms. > > > > > 2) In my case I'm trying to access the main form (in this case a > > > > > simple label) that was created by the visual studio and which is > > > > > already opened, from another form that is opened after that. > > > > > > Maybe I'm missing very basic but I cannot understand how to face this > > > > > problem. > > > > > > Thanks in advance! > > > > > Nacho- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text - > > -- > > ~ Caio Dias
