Full width home advertisement

Post Page Advertisement [Top]

//Add a CheckBox Column to the DataGridView at the first position.
    DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn();
    checkBoxColumn.HeaderText = "";
    checkBoxColumn.Width = 30;
    checkBoxColumn.Name = "checkBoxColumn";
    dataGridView1.Columns.Insert(0, checkBoxColumn);






private void btnGet_Click(object sender, EventArgs e)
{
    string message = string.Empty;
    foreach (DataGridViewRow row in dataGridView1.Rows)
    {
        bool isSelected = Convert.ToBoolean(row.Cells["checkBoxColumn"].Value);
        if (isSelected)
        {
            message += Environment.NewLine;
            message += row.Cells["Name"].Value.ToString();
        }
    }

    MessageBox.Show("Selected Values" + message);
}

No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by Colorlib