Link to home
Start Free TrialLog in
Avatar of jschmuff
jschmuffFlag for United States of America

asked on

Questions about GUI C# programming

I have a few questions about somethings I am not quite sure what they are or what it means. First one is form controls statically and changing them dynamically. What does that mean? Next, is using mouse and keyboard event handling. Can I get an example of what that is exactly? Someone explain to me what I would use tree views or list views in a program? Variable passing between multiple forms, what does that mean? Anyone able to give me examples or answers to what they are exactly for my understanding, that would be great.
Avatar of JasonRawlins
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Which leads to mouse and keyboard event handling.Event handling is when you take action when something happens on the form. Clicking on a button raises the button's Click event. Look at these examples for click and hover events for button.
private void AddAnEventHandlerToAControl()
	button1.Click += new EventHandler(button1_Click);
	button1.MouseHover += new EventHandler(button1_MouseHover);
private void button1_Click(object sender, EventArgs e)
	button1.Text = "You clicked me!";
private void button1_MouseHover(object sender, EventArgs e)
	MessageBox.Show("You are hovering the mouse over this button.");

Open in new window

Many controls can also handle keyboard events. Notice the KeyEventArgs pararmter. This has information you can use to handle the event in different ways. These KeyEventArgs contain information about which keys were pressed.
private void button1_KeyUp(object sender, KeyEventArgs e)
	if (e.KeyCode == Keys.Enter)
		MessageBox.Show("You pressed the enter key.");

Open in new window

Avatar of jschmuff


OK so when I click a radio button and in the text in label 1 changes to what I set it to when the radiobutton was checked in the event that is dynamically?
A tree view is used to show parent-child relationships. It's called a tree because a "branch" can have other "branches on it, like a tree. The file directory of your computer is a tree structure.

|_ Programs
   |_ Microsoft Office
   |_ AntiVirus Software
|_ Windows
   |_ System
   |_ Another Directory
      |_ Another directory

That's a bad graphic, I know. but it should give you an idea
A Listview just displays a list of items, one below the other
"OK so when I click a radio button and in the text in label 1 changes to what I set it to when the radiobutton was checked in the event that is dynamically?"

Yes, that is changing the Text property of the label1 control dynamically
As for passing variables between different forms. Let's say you are working on a document in Microsoft Word. When you decide to print it, the Print Dialog window shows.. Behind the scenes, the document sent a variable to the Print Dialog window so it knows which document to print.

You can pass any information from one form to another if you need to share information between them.

Hope this all helps out
Hey, I'm still fairly new to EE, but this seems like alot to ask in one question.
Yea you are helping out a lot for understand certain things. So example of variable passing through forms I can create a form to take my information entered open a new form windows and see all my information displayed is that right?
I tried the key event on the keyboard that you have shown the example and it doesnt work.
Nevermind I got that keyboard event working properly. Thanks