Did my second windows controls today, feel good but this is strictly newby stuff.
I used mostly the properties window and toolbox in VSNet. The dev program is alot better than I thought.
This is what I did:
Created a translucent windows form with blue background, added a button and some check boxes, added events namely mouse events for the controls such as mouseover and mousedown, and add a text box.
After creating a new C# (or VB) project -> windows application
In design view of the window, use the tool box to add these windows control to the win form by dragging them of the toolbox.
Then with the properties pane click on the window form and set the properties of the win form like colour and caption, also use the properties pane to set events like mousedown, doubleclick mousedown on the evnt section of the toolbox, there are various events on this pane, then edit the event handler function that is automatically created.
eg
Code:
//This is call when the button is clicked
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Boop");
}
//... when the mouse right clicks the win form and not the controls
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
MessageBox.Show("The mouse is down");
}
//... when the mouse moves over the datagrid control
private void dataGrid1_MouseHover(object sender, System.EventArgs e)
{
//'this' refers to the winform and 'text' is its caption
this.Text = ("hovered me");
}
private void dataGrid1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
//the event args hold the position of the mouse pointer, X and Y, relative to the control of form that it is called on
MessageBox.Show("mouse x pos " + e.X + "mouse x pos " + e.Y);
}
//... When the text in the text box control changes
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
//'this' refers to the win form
//'textBox1' refers to the text box control on the win form
//'this.textBox1.Text' reform to the text in the text box
MessageBox.Show(this.textBox1.Text);
}
About 90% of the code was auto-generated; each function head was generated; after typing every dot (.) a listbox appear with options of what to type next, and it is easy to use the toolbox and properties. Hope to use datagrid control soon and the other form controls.
There is also a data section in the tool box, with stuff dealing with sqlcomnands and adapters, and there is a component section with stuff like timers and messagequeue. I will try to learn those in time too.