C# Archives - Tech Insights https://reactconf.org/category/add-combobox-in-datagridview-using-c/ Unveiling Tomorrow's Tech Today, Where Innovation Meets Insight Wed, 30 Apr 2014 17:00:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 https://i0.wp.com/reactconf.org/wp-content/uploads/2023/11/cropped-reactconf.png?fit=32%2C32&ssl=1 C# Archives - Tech Insights https://reactconf.org/category/add-combobox-in-datagridview-using-c/ 32 32 230003556 Add ComboBox in DataGridView using C# https://reactconf.org/add-combobox-in-datagridview-using-csharp/ https://reactconf.org/add-combobox-in-datagridview-using-csharp/#respond Wed, 30 Apr 2014 17:00:00 +0000 http://www.sqlneed.com/2014/04/30/add-combobox-in-datagridview-using-c/ This C# program show how to add a ComboBox in cell of a DataGridView Control, Programmatically adding ComboBox on each row in the DataGridView. First you need to create New …

The post Add ComboBox in DataGridView using C# appeared first on Tech Insights.

]]>

This C# program show how to add a ComboBox in cell of a DataGridView Control, Programmatically adding ComboBox on each row in the DataGridView.
First you need to create New Project and give the Name of project is GridViewCombobox. Add the command button and dataGridView control and copy this code and paste. So please change the datasource name,database name and Table name.
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceGridViewCombobox
{
    public partial class Form1 : Form
    {
        stringcon = “Data Source=MachineName;Initial  Catalog=DataBaseName;Integrated Security=True”;
        publicForm1()
        {
            InitializeComponent();
        }
        privatevoid Form1_Load(objectsender, EventArgs e)
        {
            stringsql = “Select Employeeid,FirstName,LastName from Employees”;
            SqlConnectioncnn = new SqlConnection(con);
            SqlDataAdaptersd = new SqlDataAdapter(sql, cnn);
            DataSetds = new DataSet();
            cnn.Open();
            sd.Fill(ds, “Employees”);
            cnn.Close();
            dataGrid.DataSource = ds;
            dataGrid.DataMember = “Employees”;
        }
        privatevoid CmdAddbuttom_Click(object sender, EventArgs e)
        {
           
                    
            DataGridViewComboBoxColumnchkbtn = new  
            DataGridViewComboBoxColumn();
           
            chkbtn.Items.Add(“Male”);
            chkbtn.Items.Add(“Female”);
                       
            dataGrid.Columns.Add(chkbtn);
           
            chkbtn.HeaderText = “Gender”;
          
            chkbtn.Name = “Gender”;
           
           
        }
    }
}

The post Add ComboBox in DataGridView using C# appeared first on Tech Insights.

]]>
https://reactconf.org/add-combobox-in-datagridview-using-csharp/feed/ 0 45