Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi All,

 

I have a mediator class that takes a form in its constructor. My question is how I access the controls on the form within the mediator? Using something like frm.txtBox.Text = ""; give a build error. I can move through the controls collection for the reference so the form is there and that part is correct, but I would like to access each control on the form individually in the easiest way possible � something like frm.myTxtBox.Text = �hello�;

 

Any ideas?

 

Mike

Posted

Hey Plaus,

 

When I send the form by form name (CompareLists) I get a protection errors when I try to access a given control (...\UI\ListComparisonUIs\CompareListMediator.cs(92): 'UI.ListComparisonUIs.CompareLists.txtBaseList' is inaccessible due to its protection level)

 

When I send the form by Form, there are no easy ways to access the controls. Of course, they are in the controls collection and I can list them.

 

Go figure? What am I doing wrong?

Posted

By default you can't direcly access controls as they are declared as Private (only the class/form itself can access them).

You have to change the Modifier property to internal or public if you want to access them from another class.

Nothing is as illusive as 'the last bug'.
Posted
Thanks Wile for you input. I though of that shortly after I send my last post. I was hoping to find a way to access the controls in a more clean way and not have to modify the form code outside of the form designer. Oh well�.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...