Posted on 2006-05-25
Please!!! need help!!!
I have 2 problems (i think from the same reason)
i built a treeView (with the great help from vo1d - here in this site) which opens every time the same form (this is the first problem), and also i get an error massage when i try to close the form (the only form) that has been opened with the treeView.
the error massage is :
"Forms that are already visible cannot be displayed as a modal dialog. Set the form's visible property to false before calling showDialog."
the code for the treeView is:
in the constractor:
in the InitializeComponent part:
this.varWorkersRcrmnt = new frmWorkersRcrmnt();
this.varfrmTeachrsPeriodEval = new frmTeachrsPeriodEval();
this.varfrmTeachersEvaluation = new frmTeachersEvaluation();
this.varfrmMainEmployee = new frmMainEmployee();
this.varfrmMainCandidates = new frmMainCandidates();
this.treeView1.Nodes.Nodes.Tag = this.varfrmTeachersEvaluation;
this.treeView1.Nodes.Tag = this.varfrmMainEmployee;
this.treeView1.Nodes.Tag = this.varfrmMainCandidates;
this.treeView1.BeforeSelect += new TreeViewCancelEventHandler
and also in the treeview BeforeSelect:
void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)
if(e.Node.Tag != null && e.Node.Tag is Form)
(e.Node.Tag as Form).ShowDialog();
in the form "frmWorkersRcrmnt" in the closing event :
private void frmWorkersRcrmnt_Closing(object _
_ sender,System.ComponentModel.CancelEventArgs e)
e.Cancel = true;
(sender as Form).Hide();
All the forms that opened are Modal Forms! because i wrote: "ShowDialog" (with "show" it works fine) but i need them to be Modal!