c# - Object reference not set to an instance of an object. [NullReferencceException was unhandled] -
related topic:
if condition mdi parent control
i need call text label in dtexteditor (form) label in frmmain (form) . , use timer instead of button since follow answer here: communicate between 2 windows forms in c#
which leads to:
frmmain.cs:
private dtexteditor a; public frmmain(form callingform) { = callingform dtexteditor; initializecomponent(); } private void timercountline_tick(object sender, eventargs e) { a.lblcl = lblcountline.text; }
dtexteditor.cs
public string lblcl //rich { { return lblcountline.text; } set { lblcountline.text = value; } }
but thing error shows:
what should remove error? pls lot!
check followings :
1- check variable in constructor not null
2-after initializecomponent can design objects :
public frmmain(form callingform) { initializecomponent(); = callingform dtexteditor; }
3- assignment both side seems same : a.lblcl = lblcountline.text means :
lblcountline.text = lblcountline.text : lblcountline.text = value !!
4- check timer interval , enable after initializecomponent ( set in designto false )
public frmmain(form callingform) { initializecomponent(); = callingform dtexteditor; timer1.enabled=true; }
Comments
Post a Comment