Thank you very much for reading this. I've been programming for 15 years (VB, a lot of PHP, etc), but I've never considered myself a 'real' programmer. Mainly I'll build things that I need that are too specialized to be made by anyone else - simple programs and scripts to make life easier. I've managed to do what I needed without having to bother other people, but this time I'm a bit out of my depth. Before anyone jumps on me for not having a strong programming background or spending the weeks and months learning everything about C#, let me explain: My day job is in an unrelated field, I go to school at night, I'm married, and I have three great children. I've picked up and read through HeadFirst C#, but I'm having a hell of a time relating it to my own project. So I'm begging help from you guys ;)
I'm running .NET4.0 / VS 2010 on a Win7-64 machine.
I'm trying to create a program that will allow me to spawn boxes onto the screen to hold notes (Notebox) - similar to StickyNotes from Microsoft and 'bubbl.us' on the web. Each Notebox will have two textBoxes ('titleTextBox' and 'contentTextBox') and 3 control buttons (clickToMove, spawnNotebox, and delete). They're all arranged on backgroundImage (to make it easy to see). I've got the textBoxes hooked up to a SQL DB, and I've got the Notebox moving around the screen just fine. My problem is that I'm failing to understand how to create a new instance of the Notebox. While playing around with the Clone method, I managed to make an exact copy of the original Notebox appear, but it held the same information as the original and used the same row in the DB.
I'd like the user to be able to click on spawnNotebox and have another blank Notebox appear - with its own row in the DB and ready to recieve input. I realize I'm making some obvious rookie mistakes, but after strugging with it all last week I figured I'd better get help from some experts.
Ok, so the question is: How do I make a new and independent copy of my Notebox?
I've stripped my failed attempt at cloning out of the code. I have one form that I've maximized that the Notebox appears in. No other files.
From Form.cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace movableElementswDB
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void ideasBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.ideasBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.NoteboxDataSet);
}
public void ideasBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
{
this.Validate();
this.ideasBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.NoteboxDataSet);
}
public void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'NoteboxDataSet.ideas' table. You can move, or remove it, as needed.
this.ideasTableAdapter.Fill(this.NoteboxDataSet.ideas);
}
// Start of BOXEN
public void pictureBox1_Click(object sender, EventArgs e)
{
}
int x = 1;
int y = 1;
public void pictureBox1_Enter(object sender, EventArgs e)
{
}
// Storing begin point for1 (by the left click)
void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
x = e.X;
y = e.Y;
}
}
// Moving the BOXEN
void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
clickToMove.Left += (e.X - x);
clickToMove.Top += (e.Y - y);
spawnNotebox.Left += (e.X - x);
spawnNotebox.Top += (e.Y - y);
delete.Left += (e.X - x);
delete.Top += (e.Y - y);
backgroundImage.Left += (e.X - x);
backgroundImage.Top += (e.Y - y);
titleTextBox.Left += (e.X - x);
titleTextBox.Top += (e.Y - y);
contentTextBox.Left += (e.X - x);
contentTextBox.Top += (e.Y - y);
}
}
public void titleTextBox_TextChanged(object sender, EventArgs e)
{
}
public void contentTextBox_TextChanged(object sender, EventArgs e)
{
}
public void siblingIcon_Click(object sender, EventArgs e)
{
}
// End of BOXEN
}
}
Thank you VERY much for taking the time to read this. I really do appreciate the help and I hope you don't feel like I've wasted your time with a silly question.