Peter Kiers
asked on
From ShowModal to Show
HI,
I have a main form called MainForm and a second form called StickyNotes.
On the main form I have just one toolbar-button to call for the form StickyNotes.
It looks like this:
private void tbNewNote_Click(object sender, EventArgs e)
{
frmNote.txtCaption.Text = "";
frmNote.rtbContent.Clear() ;
frmNote.lblCreation.Text = (DateTime.Now.ToString());
if (frmNote.ShowDialog() == System.Windows.Forms.Dialo gResult.OK ) <=========================
{
ListViewItem myItem = new ListViewItem(frmNote.txtCa ption.Text , 0);
myItem = lvNotes.Items.Add(myItem);
myItem.SubItems.Add(frmNot e.rtbConte nt.Text);
myItem.SubItems.Add(frmNot e.lblCreat ion.Text);
}
}
But now I don't want to use a ShowDialog anymore but use multilpe forms
of the StickyNotes.What do I have to change in the code above to achieve this.
Who knows the answer and is willing to help me?
Greetings, Peter Kiers
I have a main form called MainForm and a second form called StickyNotes.
On the main form I have just one toolbar-button to call for the form StickyNotes.
It looks like this:
private void tbNewNote_Click(object sender, EventArgs e)
{
frmNote.txtCaption.Text = "";
frmNote.rtbContent.Clear()
frmNote.lblCreation.Text = (DateTime.Now.ToString());
if (frmNote.ShowDialog() == System.Windows.Forms.Dialo
{
ListViewItem myItem = new ListViewItem(frmNote.txtCa
myItem = lvNotes.Items.Add(myItem);
myItem.SubItems.Add(frmNot
myItem.SubItems.Add(frmNot
}
}
But now I don't want to use a ShowDialog anymore but use multilpe forms
of the StickyNotes.What do I have to change in the code above to achieve this.
Who knows the answer and is willing to help me?
Greetings, Peter Kiers
ASKER
Hi, thanks for the reaction but I don't use MDI. Its just the mainform with a button
and by pressing on that button another form shows up called the StickyNotes.cs.
Peter
and by pressing on that button another form shows up called the StickyNotes.cs.
Peter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. Peter
ShowDialog is a special command that you use in special occasions, since it freezes the code for as long as the form is visible.
Use Show instead.
Use Show instead.
It sounds as though you want to go to MDI (Multiple Document Interface), meaning that you have multiple child forms for a single parent form.
To do this, set the IsMdiContainer property of the main form to True.
Then change your code as follows:
Open in new window
However, unless you are going to ShowDialog you cannot wait for something to occur before you do something. You will therefore need to move your save code into frmNote.
Once you have done this you will be able to create multiple notes at once.
Chris Bray