TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Charlie Holt
NA
12
49.7k
Saving Form Location to DB?
Nov 23 2010 5:19 AM
I am trying to save a form location to a database whenever the LocationChanged event is triggered on that form.
private void DisplayForm_LocationChanged(object sender, EventArgs e)
{
DSLocation = this.Location;
((Form1)this.MdiParent).NotifyChanges(this); // notify parent form that there are changes on this child
}
DSLocation is a property that I'm trying to fill with data from this.Location in order to pass it back to the parent form and ultimately the database. Whenever I try to compile, I get the error: Cannot implicitly convert type 'System.Drawing.Point' to 'string'
I know that I need to somehow break the coordinates coming from this.Location into two pieces and convert them into int and then recombine them into a string, but I have no idea how to go about this. My searches have only found tutorials and sites that talk about going from String to Point, not the reverse... Using those tutorials and examples I was able to get the coordinates formatted coming from the database:
private Point StringToPoint(string str)
{
string[] s = str.Split(',');
int x = Int32.Parse(s[0]);
int y = Int32.Parse(s[1]);
return new Point(x, y);
}
childForm.Location = StringToPoint((string)row["location"]);
...but I am not nearly knowledgeable enough to make the reverse happen.
Any of you bright people know how to juggle backwards?
-Charlie
Reply
Answers (
3
)
Keypress or Keydown Event in mdiForm
TextBox Example Into Datagridview