Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
frmMain form = (frmMain)Form.ActiveForm;
this is my code to have a form control on another class but after some time it set to null,now i don't know why it sets to null. can any one help me for this one?
thank you...
Posted
Comments
BillWoodruff 8-Oct-14 3:42am    
How many types of Form does your project have ? And where are any secondary Forms ... Forms which are NOT of Type MainForm ... created ?
Afzaal Ahmad Zeeshan 8-Oct-14 3:42am    
We also don't know why -_-

But I think, you're getting the ActiveForm, so as soon as the Focus runs out, the value is null.
saumil jariwala 9-Oct-14 1:17am    
i got the answer
frmMain form1 = new frmMain();
foreach (Form mFrm in Application.OpenForms)
{
if (mFrm.Name == "")
{
form1 = (frmMain)mFrm;
form = form1;
}
}
form = form1;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900