C# - How Import and Export Data From XML File

C# - How Import and Export Data From XML File

                                                                                                                                  

In This C# Tutorial We Will See How To Export The DataGridView Values To A XML File Using CSharp Programming Language .


Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Csharp_Datagridview_XML : Form
    {
        DataTable table = new DataTable("tbl");
        public Csharp_Datagridview_XML()
        {
            InitializeComponent();
        }

        private void Csharp_Datagridview_XML_Load(object sender, EventArgs e)
        {
         
            table.Columns.Add("ID", typeof(int));
            table.Columns.Add("First Name", typeof(string));
            table.Columns.Add("Last Name", typeof(string));
            table.Columns.Add("Age", typeof(int));

            table.Rows.Add(1, "First A", "Last A", 10);
            table.Rows.Add(2, "First B", "Last B", 20);
            table.Rows.Add(3, "First C", "Last C", 30);
            table.Rows.Add(4, "First D", "Last D", 40);
            table.Rows.Add(5, "First E", "Last E", 50);
            table.Rows.Add(6, "First F", "Last F", 60);
            table.Rows.Add(7, "First G", "Last G", 70);
            table.Rows.Add(8, "First H", "Last H", 80);
            table.Rows.Add(9, "First I", "Last I", 90);

            dataGridView1.DataSource = table;
        }

        private void BTN_EXPORT_Click(object sender, EventArgs e)
        {
            table.WriteXml(@"C:\Users\samsng\Documents\Visual Studio 2013\Projects\WindowsFormsApplication1\WindowsFormsApplication1\XMLFile1.xml",XmlWriteMode.WriteSchema);
            MessageBox.Show("Data Exported");
        }

        private void BTN_IMPORT_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt.ReadXml(@"C:\Users\samsng\Documents\Visual Studio 2013\Projects\WindowsFormsApplication1\WindowsFormsApplication1\XMLFile1.xml");
            dataGridView2.DataSource = dt;
            MessageBox.Show("Data Imported");
        }
    }
}

=> OutPut :

c# import and export to xml file
c# import and export to xml file

C# -How To Export dataGridView Data to txt file

C# -How To Export dataGridView Data to txt file

                                                                                                                                  

In This C# Tutorial We Will See How To Write The DataGridView Values In A Text File Using CSharp Programming Language .



Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Datagridview_to_txt_file : Form
    {
        public Datagridview_to_txt_file()
        {
            InitializeComponent();
        }

        private void Datagridview_to_txt_file_Load(object sender, EventArgs e)
        {
            DataTable table = new DataTable();
            table.Columns.Add("ID", typeof(int));
            table.Columns.Add("First Name",typeof(string));
            table.Columns.Add("Last Name",typeof(string));
            table.Columns.Add("Age",typeof(int));

            table.Rows.Add(1, "First A", "Last A", 10);
            table.Rows.Add(2, "First B", "Last B", 20);
            table.Rows.Add(3, "First C", "Last C", 30);
            table.Rows.Add(4, "First D", "Last D", 40);
            table.Rows.Add(5, "First E", "Last E", 50);
            table.Rows.Add(6, "First F", "Last F", 60);
            table.Rows.Add(7, "First G", "Last G", 70);
            table.Rows.Add(8, "First H", "Last H", 80);
            table.Rows.Add(9, "First I", "Last I", 90);

            dataGridView1.DataSource = table;
        }

        private void BTN_EXPORT_Click(object sender, EventArgs e)
        {
            TextWriter writer = new StreamWriter(@"C:\folder\Text.txt");
            for(int i = 0; i < dataGridView1.Rows.Count-1; i++)
            {
                for(int j = 0; j < dataGridView1.Columns.Count; j++)
                {
                    writer.Write("\t"+dataGridView1.Rows[i].Cells[j].Value.ToString()+"\t"+"|");
                }
                writer.WriteLine("");
                writer.WriteLine("-----------------------------------------------------");
            }
            writer.Close();
            MessageBox.Show("Data Exported");
        }
    }

}
=
> OutPut :

Export Datagridview Data To Text File In C#
Export Datagridview Data To Text File In C#

C# - How To Add ComboBox Button CheckBox Image to dataGridView

C# - Add ComboBox Button CheckBox Image to dataGridView

                                                                                                                              

In This C# Tutorial We will See How To :

-add Combobox To Datagridview,
-add CheckboxTo Datagridview,
-add Button To Datagridview,
-add Image To Datagridview,


Source Code :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Datagridview_Add_Button_CheckBox_Combobox_Image : Form
    {
        public Datagridview_Add_Button_CheckBox_Combobox_Image()
        {
            InitializeComponent();
        }

        private void Datagridview_Add_Button_CheckBox_Combobox_Image_Load(object sender, EventArgs e)
        {
            DataTable table = new DataTable();
            table.Columns.Add("ID", typeof(int));
            table.Columns.Add("First Name", typeof(string));
            table.Columns.Add("Last Name", typeof(string));
            table.Columns.Add("Age", typeof(int));

            table.Rows.Add(1, "First A", "Last A", 10);
            table.Rows.Add(2, "First B", "Last B", 20);
            table.Rows.Add(3, "First C", "Last C", 30);
            table.Rows.Add(4, "First D", "Last D", 40);
            table.Rows.Add(5, "First E", "Last E", 50);
            table.Rows.Add(6, "First F", "Last F", 60);
            table.Rows.Add(7, "First G", "Last G", 70);
            table.Rows.Add(8, "First H", "Last H", 80);
            table.Rows.Add(9, "First I", "Last I", 90);

            dataGridView1.DataSource = table;

            DataGridViewComboBoxColumn dcombo = new DataGridViewComboBoxColumn();
            dcombo.HeaderText = "ComboBox";

            dcombo.Items.Add("A");
            dcombo.Items.Add("B");
            dcombo.Items.Add("C");
            dcombo.Items.Add("D");

            DataGridViewButtonColumn dbtn = new DataGridViewButtonColumn();
            dbtn.HeaderText = "Button";

            DataGridViewCheckBoxColumn dchek = new DataGridViewCheckBoxColumn();
            dchek.HeaderText = "CheckBox";

            DataGridViewImageColumn dimg = new DataGridViewImageColumn();
            dimg.Image = Properties.Resources.myico;
            dimg.HeaderText = "Image";
            dimg.ImageLayout = DataGridViewImageCellLayout.Stretch;

            dataGridView1.AllowUserToAddRows = false;

            dataGridView1.Columns.Add(dcombo);
            dataGridView1.Columns.Add(dbtn);
            dataGridView1.Columns.Add(dchek);
            dataGridView1.Columns.Add(dimg);
        }
    }
}

=> OutPut :

c# Add ComboBox Button CheckBox Image to dataGridView
Add ComboBox Button CheckBox Image to dataGridView


C# - How to Bind dataGridView with Datatable In C#

C# Tutorial - How To Load Datatable Into DataGridView Using C#

                                                                                                                         

In This C# Tutorial We Will See How To Populate a DataGridView From DataTable Using CSharp Programming Language And Visual Studio 2013 .


Project Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Bind_DataGridView_Using_DataTable : Form
    {
        public Bind_DataGridView_Using_DataTable()
        {
            InitializeComponent();
        }

        private void Bind_DataGridView_Using_DataTable_Load(object sender, EventArgs e)
        {
            DataTable table = new DataTable();

            // add columns to datatable
            table.Columns.Add("Id", typeof(int));
            table.Columns.Add("First Name", typeof(string));
            table.Columns.Add("Last Name", typeof(string));
            table.Columns.Add("Age", typeof(int));

            // add rows to datatable
            table.Rows.Add(1,"First A","Last A",10);
            table.Rows.Add(2, "First B", "Last B", 20);
            table.Rows.Add(3, "First C", "Last C", 30);
            table.Rows.Add(4, "First D", "Last D", 40);
            table.Rows.Add(5, "First E", "Last E", 50);
            table.Rows.Add(6, "First F", "Last F", 60);
            table.Rows.Add(7, "First G", "Last G", 70);
            table.Rows.Add(8, "First H", "Last H", 80);

            dataGridView1.DataSource = table;

        }
    }
}

OutPut : 

load datatable data to datagridview using c#
Load DataTable To DataGridView

C# - How To Use Regex ( Regular Expressions ) In C#

C# - How To Use Regular Expressions ( Regex ) In C#

                                                                                                            

In This C# Tutorial We Will See How To  Validate:
-email.
-url.
-phone number.
-birthday.
Using Regex In CSharp Programming Language.


Source code :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;


namespace WindowsFormsApplication1
{
    public partial class Regex_Form : Form
    {
        public Regex_Form()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //  mail@mail.com                        => ^([\w]+)@([\w]+)\.([\w]+)$
            //  http://www.google.com                => ^(http://www\.)([\w]+)\.([\w]+)$
            //  Phone Number like : 0011 XXX XXX XXX => ^(0011)(([ ][0-9]{3}){3})$
            //  Date XX/XX/XXXX                      => ^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$

            Regexp(@"^([\w]+)@([\w]+)\.([\w]+)$",textBox1, pictureBox1, lblemail, "Mail");

            Regexp(@"^(http://www\.)([\w]+)\.([\w]+)$", textBox2, pictureBox2, lblwebsite, "Web Site");
            Regexp(@"^(0011)(([ ][0-9]{3}){3})$", textBox3, pictureBox3, lblphone, "Phone Number");

            Regexp(@"^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$", textBox4, pictureBox4, lbldate, "Date");
        }

        public void Regexp(string re, TextBox tb, PictureBox pc, Label lbl, string s)
        {
            Regex regex = new Regex(re);

            if(regex.IsMatch(tb.Text))
            {
                pc.Image = Properties.Resources.valid;
                lbl.ForeColor = Color.Green;
                lbl.Text = s + " Valid";
            }
            else
            {
                pc.Image = Properties.Resources.invalid;
                lbl.ForeColor = Color.Red;
                lbl.Text = s + " InValid";
            }
        }
    }
}


=> OutPut :

c# regular expressions
C# Regex



      

c# - how to bind a combobox with fonts names

c# - how to bind a combobox with fonts name

                                                                                                                           

In This C# Tutorial We Will See How We Can Populate A ComboBox With Fonts Name And Set The Font Name To A Label Using CSharp Programming Language


Project Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class ComboBox_Fonts_Names : Form
    {
        public ComboBox_Fonts_Names()
        {
            InitializeComponent();
        }

        private void ComboBox_Fonts_Names_Load(object sender, EventArgs e)
        {
            foreach(FontFamily font in FontFamily.Families)
            {
                comboBox1.Items.Add(font.Name.ToString());
            }
        }

        private void comboBox1_TextChanged(object sender, EventArgs e)
        {
            try
            {
                label1.Font = new Font(comboBox1.Text, label1.Font.Size);
            }
            catch { }
        }
    }
}

=> OutPut :

C# ComboBox With Fonts Names
Populate A ComboBox With Fonts Names In C#

c# - How to clear the text of all textBoxes in the form or in The groupBox

c# - How to clear the text of all textBoxes in the form or in The groupBox

                                                                                        

In This C# Tutorial We Will See How You Can Remove The Text From All TextBoxes In The Form Or In The GroupBox Using CSharp Programming Language..


Source Code :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Clear_TextBoxes : Form
    {
        public Clear_TextBoxes()
        {
            InitializeComponent();
        }

        private void BTN_FORM_Click(object sender, EventArgs e)
        {
            foreach(Control c in Controls)
            {
                if(c is TextBox)
                {
                    c.Text = "";
                }
            }
        }

        private void BTN_GRBX_Click(object sender, EventArgs e)
        {
            foreach (Control c in groupBox1.Controls)
            {
                if (c is TextBox)
                {
                    c.Text = "";
                }
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            BTN_FORM.PerformClick();
            BTN_GRBX.PerformClick();
        }
    }

}
=> OutPut :

Clear All TextBoxes In C#
Clear All TextBoxes In C#

C# - How To Create Login Form In C# With Access Database [with source code]

C# - How To Create Login Form In C# With Access Database [with source code]

C# - How To Create Login Form In C# With Access Database [with source code]

                                                                                                                                         

In This C# Tutorial We Will See How To Make A Login Form Using CSharp Programming Language And Access Database.



Project Source Code:

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;
using System.Data.OleDb;
 
namespace LoginPrj
{
    public partial class TestForm : Form
    {
        OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Documents\DataBase1.accdb");
        OleDbDataAdapter da;
        DataTable dt = new DataTable();
        public TestForm()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            da = new OleDbDataAdapter("select * from MyTab where Email='"+textBox1.Text+"' and Password='"+textBox2.Text+"'",cn);
            da.Fill(dt);
            if (dt.Rows.Count <= 0)
            {
                if(panel1.Height == 0)
                {
                    label1.Text = "Email Or Passwor are Invalide Please try again";
                    timer1.Start();
                }
                else if (panel1.Height == 100)
                {
                    timer2.Start();
                    label1.Text = "";
                }
            }
            else if (dt.Rows.Count > 0)
            {
                if (panel1.Height == 0)
                {
                    label1.Text = "Login Succsufully";
                    timer1.Start();
                }
                else if (panel1.Height == 100)
                {
                    timer2.Start();
                    label1.Text = "";
                }
            }
 
            dt.Clear();
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            if(panel1.Height != 100)
            {
                panel1.Height +=5;
                if(panel1.Height == 100)
                {
                    timer1.Stop();
                }
            }
        }
 
        private void timer2_Tick(object sender, EventArgs e)
        {
            if (panel1.Height != 0)
            {
                panel1.Height -= 5;
                if (panel1.Height == 0)
                {
                    timer2.Stop();
                }
            }
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            timer2.Start();
        }
    }
}

////////////////////////////////END
Other Post:
Create Login Form In C# With MySQL Database
C# - How To Add Placeholder Text To Textbox In C#

C# - How To Add Placeholder Text To Textbox In C#

C# - How To Add Placeholder Text To Textbox In C#

                                                                                                                                                           

in this c# tutorial we will see how to create a textbox placeholder in C# .


Project Source Code:

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 MyApp
{
    public partial class TextBoxPalceHolder : Form
    {
        public TextBoxPalceHolder()
        {
            InitializeComponent();
        }

        private void TextBoxPalceHolder_Load(object sender, EventArgs e)
        {
            this.ActiveControl = label1;
            textBox1.GotFocus += new EventHandler(this.TextGotFocus);
            textBox1.LostFocus += new EventHandler(this.TextLostFocus);

        }

        public void TextGotFocus(object sender , EventArgs e)
        {
            TextBox tb = (TextBox)sender;
            if (tb.Text == "Your Text ..........")
            {
                tb.Text = "";
                tb.ForeColor = Color.Black;
            }
        }

        public void TextLostFocus(object sender , EventArgs e)
        {
            TextBox tb = (TextBox)sender;
            if(tb.Text=="")
            {
                tb.Text = "Your Text ..........";
                tb.ForeColor = Color.LightGray;
            }
        }
    }
}
Change a webBrowser Background Color with colorDialog in C#

Change a webBrowser Background Color with colorDialog in C#

Change a webBrowser Background Color with colorDialog in C#

                                                                                                                                                           

in this c# tutorial we will see how to change a webBrowser control Background Color using C# .


Project Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Csharp_And_MySQL
{
    public partial class WebBroser_Background_Color : Form
    {
        public WebBroser_Background_Color()
        {
            InitializeComponent();
        }

        private void BTN_COLOR_Click(object sender, EventArgs e)
        {

            DialogResult colors = colorDialog1.ShowDialog();

            if(colors == DialogResult.OK)
            {
                string colorCode = ColorTranslator.ToHtml(colorDialog1.Color).ToString();

                textBox_Color.Text = colorCode;

                webBrowser1.DocumentText = "<html><body style='background-color:"+colorCode+"'></body></html>";

            }
        }
    }
}

flat button appearance in c#

flat button appearance in c#

Flat Button Appearance In C#



in this c# tutorial we will see how to make a flat button Appearance using c#.
to do that you need to follow this steps:
 in FlatStyle:
       Make FlatStyle to Flat 
 in FlatAppearance: 
           Change the BorderColor 
           Change the BorderSize 
          Change the MouseDownBackColor 
           Change the MouseOverBackColor
C# - Create a Simple Youtube Application Using C#

C# - Create a Simple Youtube Application Using C#

Create A Simple Youtube Application Using C#

this app can: 
   get the youtube video title
   get the youtube video thumbnail
   get youtube video description
   get youtube video tags and more informations



                                                                 Part 1



                                                                 Part 2

                     Download Code

   if you add some style and and images + manage the exceptions You can make better it than this one :




                                                             Download The App





C# - How To Get Data From Excel File In C#

C# - How To Get Data From Excel File In C#

How To Get Data From Excel File In C#

                                                                                                                                                           

in this c# tutorial we will see how to Get Data From Excel File In C# .




Project Source Code :

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;
using System.Data.OleDb;

namespace csharp
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void browse_Click(object sender, EventArgs e)
        {
            OpenFileDialog opfd = new OpenFileDialog();
            if (opfd.ShowDialog() == DialogResult.OK)
                textselect.Text = opfd.FileName;
        }

        private void showdata_Click(object sender, EventArgs e)
        {
            string stringconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + textselect.Text + ";Extended Properties=\"Excel 8.0;HDR=Yes;\";";
            OleDbConnection conn = new OleDbConnection(stringconn);
            if (textselect.Text != "")
            {
                OleDbDataAdapter da = new OleDbDataAdapter("Select * from [" + textchoice.Text + "$]", conn);
                DataTable dt = new DataTable();
                da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            else
                MessageBox.Show("ER");
        }
    }
}

How To send an email Using C#

How To send an email Using C#

How To send an email Using C#

                                                                                                                                                           

in this c# tutorial we will see how to to Send An Email With C# .


Project Source Code :

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;
using System.Net;
using System.Net.Mail;

namespace email
{
    public partial class Form1 : Form
    {
     
        public Form1()
        {
            InitializeComponent();
        }

        private void send_Click(object sender, EventArgs e)
        {
            MailMessage msg = new MailMessage("your gmail                       mail",textTo.Text,textSubject.Text,textmail.Text);
            msg.IsBodyHtml = true;
            SmtpClient sc = new SmtpClient("smtp.gmail.com",587);
            sc.UseDefaultCredentials = false;
            NetworkCredential cre = new NetworkCredential("your gmail mail",textpass.Text);//your mail password
            sc.Credentials = cre;
            sc.EnableSsl = true;
            sc.Send(msg);
            MessageBox.Show("Mail Send");
        }

    }
}

//////////////////////////////  END

C# - How to make a textbox that only accepts numbers or only characters

C# - How to make a textbox that only accepts numbers or only characters

                                                                                                                                                           

in this c# tutorial we will see how to make a textbox that only accepts numbers or only characters in C# .



Project Source Code :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class TextBox_Numbers_Characters : Form
    {
        public TextBox_Numbers_Characters()
        {
            InitializeComponent();
        }

        private void TXTB_ONLY_CHAR_KeyPress(object sender, KeyPressEventArgs e)
        {
            if(!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar))
            {
                e.Handled = true;
            }
        }

        private void TXTB_ONLY_NUMBER_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
            {
                e.Handled = true;
            }
        }

        private void TXTB_CHAR_AND_NUMBER_KeyPress(object sender, KeyPressEventArgs e)
        {
            // allow digit + char + white space
            if (!char.IsControl(e.KeyChar) && !char.IsLetterOrDigit(e.KeyChar) && !char.IsWhiteSpace(e.KeyChar))
            {
                e.Handled = true;
            }
        }

    }
}


=> OutPut :

Textbox Accepts Only Numbers Or Only Characters
Textbox Accepts Only Numbers Or Only Characters In C#

How To Add Flash Object In C# Form

How To Add Flash Object In C# Form

How To Add Flash Object In C# Form

                                                                                                                                                           

in this c# tutorial we will see how to add flash object in C# components used "shockwave flash object" .




    Steps :
1) Right click on the box tools .
2) choose: choose items .
3) select: shockwave flash object .

4) add in the form .
5) go to his property ==> in movie write the path of the flash object (.swf).

How to Create a Drop Down Menu in C#

How to Create a Drop Down Menu in C#

                                                                                                                                                                

in this c# tutorial we will see how to Create a Drop Down Menu in C# using TextBoxes . components used "TextBoxes" "GroupBox" and "timer".



Project Source Code :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Drop_Down_Menu : Form
    {

        public Drop_Down_Menu()
        {
            InitializeComponent();
        }

        int t1 = 45;
        int t2 = 45;
        int t3 = 45;

        private void button1_MouseHover(object sender, EventArgs e)
        {
            this.panel2.Size = new Size(this.panel2.Size.Width, t2);
            this.panel3.Size = new Size(this.panel3.Size.Width, t3);
            timer1.Start();
        }

        private void button1_MouseLeave(object sender, EventArgs e)
        {
            timer1.Stop();
            t1 = 45;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (t1 > 225)
            { timer1.Stop(); }
            else
            {
                this.panel1.Size = new Size(this.panel1.Size.Width, t1);
                t1 += 5;
            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            if (t2 > 225)
            { timer2.Stop(); }
            else
            {
                this.panel2.Size = new Size(this.panel2.Size.Width, t2);
                t2 += 5;
            }
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            if (t3 > 225)
            { timer3.Stop(); }
            else
            {
                this.panel3.Size = new Size(this.panel3.Size.Width, t3);
                t3 += 5;
            }
        }

        private void button10_MouseHover(object sender, EventArgs e)
        {
            this.panel1.Size = new Size(this.panel1.Size.Width, t1);
            this.panel3.Size = new Size(this.panel3.Size.Width, t3);
            timer2.Start();
        }

        private void button10_MouseLeave(object sender, EventArgs e)
        {
            timer2.Stop();
            t2 = 45;
        }

        private void button15_MouseHover(object sender, EventArgs e)
        {
            this.panel1.Size = new Size(this.panel1.Size.Width, t1);
            this.panel2.Size = new Size(this.panel2.Size.Width, t2);
            timer3.Start();
        }

        private void button15_MouseLeave(object sender, EventArgs e)
        {
            timer3.Stop();
            t3 = 45;
        }

        private void Drop_Down_Menu_MouseHover(object sender, EventArgs e)
        {
            this.panel1.Size = new Size(this.panel1.Size.Width, t1);
            this.panel3.Size = new Size(this.panel3.Size.Width, t3);
            this.panel2.Size = new Size(this.panel2.Size.Width, t2);
        }
    }
}


=> OutPut :

drop down menu in c#
C# Drop Down Menu

C# Create a Dynamic Menu With Textboxes

C# Create a Dynamic Menu With Textboxes

C# Create a Dynamic Menu With Textboxes

                                                                                                                                                                  

in this c# tutorial we will see how to make a Dynamic Menu using TextBoxes with C# .
components used "TextBoxes"and  "timer".



an example of a single TextBox.

Project Source Code :

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;
using System.Threading;

namespace Something
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        int t1 = 76;

private void timer1_Tick(object sender, EventArgs e)
        {
            if (t1 > 176)
            {
                timer1.Stop();
                this.textBox1.BorderStyle = BorderStyle.FixedSingle;
            }
            else
            {
                this.textBox1.Size = new Size(t1, this.textBox1.Size.Height);
                t1+=2;
            } 

        }

        private void textBox1_MouseHover(object sender, EventArgs e)
        {
            timer1.Start();
        }

private void textBox1_MouseLeave(object sender, EventArgs e)
        {
            timer1.Stop();
            t1 = 76;
            this.textBox1.Size = new Size(t1, this.textBox1.Size.Height);
            this.textBox1.BorderStyle = BorderStyle.None;
        }

private void textBox1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("something");
        }
    }
}

////////////////////////////////// END