c# - Windows Forms don't work -


i want set code, if there no file opened (i use tabs also), it'll display message. here's if code:

if (getrichtextbox().text = null) {     messagebox.show("you must open document first!", "failure", messageboxbuttons.okcancel); } 

and getrichtextbox() function:

private richtextbox getrichtextbox() {     richtextbox rtb = null;     tabpage tp = tabcontrol1.selectedtab;     if (tp != null)     {         rtb = tp.controls[0] richtextbox;     }     return rtb; } 

see here how assign null in if statement:

if (getrichtextbox().text = null) { 

you need check equality:

if (getrichtextbox().text == null) { 

the other problem if function returns null, trying check text property fail. better way it:

richtextbox rtbtext = getrichtextbox(); if (rtbtext == null) { 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -