use control in other form
-
how can i use txtNoPersoneli when this is in other form?
-
how can i use txtNoPersoneli when this is in other form?
If txtNoPersoneli's access modifier is public then you should be able to access it through otherforminstance.txtNoPersoneli Better still, create events in otherform that are rasied when whatever your interested in with txtNoPersoneli occurs, and subscribe to these in the initial form.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Expect everything to be hard and then enjoy the things that come easy. (code-frog) -
how can i use txtNoPersoneli when this is in other form?
You change the access modifier to public, but it is not recommended as it breaks OO rules. Use delegates to communicate between forms. CP has an article on this subject.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
If txtNoPersoneli's access modifier is public then you should be able to access it through otherforminstance.txtNoPersoneli Better still, create events in otherform that are rasied when whatever your interested in with txtNoPersoneli occurs, and subscribe to these in the initial form.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Expect everything to be hard and then enjoy the things that come easy. (code-frog)i change to public,but yet i can not use that
-
i change to public,but yet i can not use that
You have to access it through an instance of the second form. For example, if the form is called Form2 then:
Form2 form2 = new Form2();
// any other stuff here
form2.txtNoPersoneli.Text = "Text";Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) -
how can i use txtNoPersoneli when this is in other form?
listen, you have to use delegates, search: transfer data between form here in codeproject. you may want to drop the idea of using more than 1 form :( use parentform/childform method or 1form + 10usercontrols (usercontrols that load in form like page, i use it a lot) method i use delegates, see the following exemple (here i trigger a text msg FROM usercontrol IN form): in userform
public delegate void Delegate_TransferPageInfo(string msg);
public event Delegate_TransferPageInfo Event_TransferPageInfo;private void ToolStripButton_Add_Click(object sender, EventArgs e)
{...
Event_DriverPageInfo("ERROR: invalid birth date");//trigger
...}in form
private void Form_Main_Load(object sender, EventArgs e)
{...
UserControl_DriverPage_Child.Event_DriverPageInfo += new UserControl_DriverPage.Delegate_DriverPageInfo(Page_Info);
...}
protected void Page_Info(string msg)
{
ToolStripStatusLabel_MainInfo.Text = msg;
}can´t help you more!!! ;P
nelsonpaixao@yahoo.com.br trying to help & get help
-
You have to access it through an instance of the second form. For example, if the form is called Form2 then:
Form2 form2 = new Form2();
// any other stuff here
form2.txtNoPersoneli.Text = "Text";Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)Whoever univoted this - I agree that it's not best practice and if you look at my previous reply I did suggest using events (implies delegates too). The question in response to that from the OP was specifically on the unrecommended way, to which I gave an accurate and working response! X| ;P
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)