Advertisement

Responsive Advertisement

III.12- Using DataGridView

 III.12- Using DataGridView

The DataGridView control provides a customizable table for displaying data. The DataGridView class allows customization of cells, rows, columns, and borders through the use of properties such as DefaultCellStyle, ColumnHeadersDefaultCellStyle, CellBorderStyle, and GridColor. For more information, see Basic Formatting and Styling in the Windows Forms DataGridView Control.





1. Create a ColumnHeader




2-Work on Cell of DataGridView



3-Work on Add Data to DataGridView via code



Source Code:

//add item to datagrid

        private void btnAdd_Click(object sender, EventArgs e)

        {

            dgrList.Rows.Add(txtID.Text, txtName.Text, txtPhone.Text);

        }

 

        private void btnDelete_Click(object sender, EventArgs e)

        {

            int i = dgrList.CurrentCell.RowIndex;

            dgrList.Rows.RemoveAt(i);

        }

 

        private void btnClose_Click(object sender, EventArgs e)

        {

            this.Close();

        }

















Post a Comment

0 Comments