Peter Kiers
asked on
Remember formsize/position when using multilpe forms.
Dear Experts,
I am programming in C# and I use VS2010.
I hope I explain this right. I am trying to make a Sticky-Form application.
Just what Microsoft Outlook has. By pressing on a button a sticky-form
appears. But when I change the size of the stick-form and then close the
sticky-form and reopen it, the form has then return to its original size and
position.
Is there a code that I can implement that remembers the size of every
resized form and its position.
Peter
I am programming in C# and I use VS2010.
I hope I explain this right. I am trying to make a Sticky-Form application.
Just what Microsoft Outlook has. By pressing on a button a sticky-form
appears. But when I change the size of the stick-form and then close the
sticky-form and reopen it, the form has then return to its original size and
position.
Is there a code that I can implement that remembers the size of every
resized form and its position.
Peter
ASKER
What "Type" should I use: int; strings etc...
P.
P.
ASKER
Ohh, system_drawing_size offcaurse...
P
P
ASKER
I have test the code but it only works for one form and not multiple forms.
Peter
Peter
ASKER
ASKER
And this is my code:
p.
//*------------------------------------------------------------*//
private void tbNewNote_ItemClick(object sender, ItemClickEventArgs e)
{
StickyNotes sticky = new StickyNotes();
sticky.lblTitle.Text = "";
sticky.rtbContent.Clear();
sticky.lblCreation.Text = (DateTime.Now.ToString());
sticky.FormClosed += new FormClosedEventHandler(sticky_FormClosed);
sticky.Show();
}
//*------------------------------------------------------------*//
void sticky_FormClosed(object sender, FormClosedEventArgs e)
{
StickyNotes sticky = (StickyNotes)sender;
ListViewItem myItem = new ListViewItem(sticky.lblTitle.Text, 0);
myItem = lvNotes.Items.Add(myItem);
myItem.SubItems.Add(sticky.rtbContent.Text);
myItem.SubItems.Add(sticky.lblCreation.Text);
myItem.Selected = true;
}
//*------------------------------------------------------------*//
private void lvNotes_MouseDoubleClick(object sender, MouseEventArgs e)
{
StickyNotes sticky = new StickyNotes();
sticky.lblTitle.Text = lvNotes.SelectedItems[0].Text;
sticky.rtbContent.Text = lvNotes.SelectedItems[0].SubItems[1].Text;
sticky.lblCreation.Text = lvNotes.SelectedItems[0].SubItems[2].Text;
sticky.Show();
}
//*------------------------------------------------------------*//
p.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, BuggyCoder I think that's the solution too. But I have no idea how to do this.
Peter Kiers
Peter Kiers
I did not understand that you where always reusing the same class. Since the same form is used for different notes, you would need to have a setting for each sticky note, not for the form. This could not be easily managed.
In Outlook, they do that because when they save the text of the note in the Outlook file, they also save its size and location. You record the text somewhere, isn't it? Then record the Size and Location at the same time. When you reread the text, reread the Size and Location.
In Outlook, they do that because when they save the text of the note in the Outlook file, they also save its size and location. You record the text somewhere, isn't it? Then record the Size and Location at the same time. When you reread the text, reread the Size and Location.
The best place to record the information is in the application configuration file.
Go to the Project's properties, and in the Settings tab, for each of your forms, create a Size and Location entry. Set it to User level instead of Application. That way it will be read and write, and if many users use the application on the same computer, the data will be recorded separately for each user.
In the FormClosing event to the form, record the settings:
Properties.Settings.Defaul
Properties.Settings.Defaul
Properties.Settings.Defaul
Before showing the form later, do the reverse:
Form1.Size=Properties.Sett
Form1.Location=Properties.