Re: Control is inaccessible
- From: "Irfan" <irfan@xxxxxxxxxxxxx>
- Date: Tue, 17 Oct 2006 14:07:18 +0100
thanks for the reply. I created a public method in form2 that updates its
labels.
Thanks Again
irfan
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1f9ddd355266f47a98d54d@xxxxxxxxxxxxxxxxxxxxxxx
Irfan <irfan@xxxxxxxxxxxxx> wrote:
In C#.Net, if i have a form1 and i want to access one of the controls of
form2(eg a label) from Form1, it gives an error.
(Label1 is Inaccessible, due to its protection level)
However, i was able to do the same is vb.net.
How to get around with this inaccessibility. Do i have to create wrapper
in
form2 everytime i want to access one of the control of form1.
Well, you *could* just make label1 public, but that's a bad idea in
terms of encapsulation.
What would often be better is to write a method in Form2 (which I hope
will have a more descriptive name by the time you've finished) which
changes the text of label1, or whatever it is you need to do from
form1.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- References:
- Control is inaccessible
- From: Irfan
- Re: Control is inaccessible
- From: Jon Skeet [C# MVP]
- Control is inaccessible
- Prev by Date: Re: Rewinding a TextReader file stream.
- Next by Date: Re: Time Zone and DateTime voes.
- Previous by thread: Re: Control is inaccessible
- Next by thread: Re: help with time zone issues
- Index(es):
Relevant Pages
|