Panel

Used to group collection of controls.

Panel is not visible in the output but helps in design time to group collection of controls.
All the controls inside panel can be moved at once and they can be relatively arranged inside a panel.

Steps to use a panel

Drag and drop a panel
Add controls inside it.
Arrange them relatively inside the panel.
Now you can arrange the panel in a form which brings all the controls inside it without any change in their relative distances of controls inside it.

Default event: Paint which fired when the panel is drawn/created on the form. This event is fired after form load event.

Code to make change the back color of panel when it is painted or created
private void panel1_Paint(object sender, PaintEventArgs e)
        {
           panel1.BackColor = Color.Black;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            panel1.BackColor = Color.Yellow;
        }
First panel back color will be yellow and then it is changed to black when it is created.

Code to change visibility of panel on button click
private void button1_Click(object sender, EventArgs e)
        {
            if (panel1.Visible == true)
            {
                panel1.Visible = false;
            }
            else { panel1.Visible = true; }
        }

All the controls inside the panel will be visible and invisible to the user based on the visibility of the panel in which they are present.
Wednesday, 17 February 2016
Posted by Sudhir Chekuri

Containers

Containers are controls which can hold other controls inside them.
Example: Panel, FlowLayoutPanel, GroupBox etc.

They are used to hold multiple controls and helps in easy organization of controls inside the form.
Posted by Sudhir Chekuri

WebBrowser

It is used to browse web pages inside the windows form.

Property:

Specifies the URL that the web browser control has to display.
Example: http://www.google.com

This will work only when internet is available.
Posted by Sudhir Chekuri

TreeView

It is used to display items in hierarchy in parent and child nodes format.

Adding items to treeview:
Click on the smart tag – Edit nodes.
Add root to add root items under which child items can be added with a click on Add child option by selecting the parent item.

Every node will have Text and Name property. Name is used to access that node in code and Text is used to display text on that node.
Posted by Sudhir Chekuri

ToolTip

Displays information when the user moves the cursor over an associated control.

Steps to use tooltip:
Drag and drop a tooltip control to the design window. It is displayed on the bottom panel.

Properties:
TootlTipTitle: Determines the title of the tooltip.

Now you can use the tooltip created after setting the above property. One tooltip control can be used to more than one control in that windows form. And all the controls will display tooltip message under this tooltip title which is optional to set.

Then drag and drop two buttons to which you want to add tooltip messages. Then for each button set ToolTip on toolTip1 property with some text which will be displayed on runtime as tooltip text for those buttons.
Posted by Sudhir Chekuri

TextBox

It is used to take input from user.

Default Event: TextChanged which is fired when text in textbox changed.

Example code to take input from user and print immediately in a label control
private void textBox1_TextChanged(object sender, EventArgs e)
        {
            label1.Text = textBox1.Text;

        }
Monday, 15 February 2016
Posted by Sudhir Chekuri

RichTextBox

It is used to take input from user like textbox and it is capable of holding text styles.

Default Event: TextChanged which is fired when text in RichTextBox changed in runtime.

Example code to print text in RichTextBox in label with a change in text
private void richTextBox1_TextChanged(object sender, EventArgs e)
        {
            label1.Text = richTextBox1.Text;
        }
Example code to print colourful text with styles in RichTextBox

private void Form1_Load(object sender, EventArgs e)
        {
            richTextBox1.Font = new Font("Consolas", 18f, FontStyle.Bold);
            richTextBox1.BackColor = Color.AliceBlue;
            string[] words =
           {
              "Hello", "World"
           };
            Color[] colors =
           {
              Color.Aqua,
              Color.CadetBlue
           };
            for (int i = 0; i < words.Length; i++)
            {
                string word = words[i];
                Color color = colors[i];
                {
                    richTextBox1.SelectionBackColor = color;
                    richTextBox1.AppendText(word);
                    richTextBox1.SelectionBackColor = Color.AliceBlue;
                    richTextBox1.AppendText(" ");
                }
            }

        }
Posted by Sudhir Chekuri

Followers

Total Pageviews

Powered by Blogger.

- Copyright © 2013 DevStudent - Metrominimalist - Powered by Blogger - Designed by Johanes Djogan -