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
}
childForm.Location = StringToPoint((string)row["location"]);
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);
}
...but I am not nearly knowledgeable enough to make the reverse happen.
Any of you bright people know how to juggle backwards?
-Charlie