C# Readonly | C# Controls Datagridview Read Only Columns - c# - c# tutorial - c# net
What is Datagridview ?
- The DataGridView control is designed to be a complete solution for displaying tabular data with Windows Forms.
- The DataGridView control is highly configurable and extensible, and it provides many properties, methods, and events to customize its appearance and behavior.
- The DataGridView control provides TextBox, CheckBox, Image, Button, ComboBox and Link columns with the corresponding cell types.
Read Only Columns:
- In the DataGridView control, the ReadOnly Column property value determines whether users can edit cells in that column.
- In C#, a table is read-only if the value of the ReadOnly property is true for the cell, the cell's row, the cell's column, or the DataGridView.
- Here in the below table is representing to Windows Forms:
- Here Fetch Data button will display the data values from the SQL and displays it by clicking it.
- Go to tool box and click on the DataGridview option the form will be open.
- Go to tool box and click on the button option and put the name as Read Only Column in the button.
C# Sample Code - C# Examples
Read Also
dot net training institute near me , summer internship with stipend , dot net training center in chennaiCode Explanation
- Here private void button2_Click(object sender, EventArgs e) click event handler for button2 specifies, which is a normal Button control in Windows Forms.Ý The two parameters, "object sender" and "EventArgs e" parameters of function of event of a button such as private void button2_Click(object sender, EventArgs e).
- Here dataGridView1.Columns[1].ReadOnly = true; read-only if the value of the ReadOnly property is true for the cell, the cell's row, the cell's column, or the DataGridView.
Sample C# examples - Output :
- Here in this output the Fetch Data button will display the data values from the SQL and displays it by clicking it.
- Here in this output table displays the Id "1,2,3" and name "venkat, jln, arun".
- Here in this output table displays the Id "1,2,3" and name "venkat, jln, arun".
- Here in this output table displays Read Only Column which specifies to read the "jln" column in the DataTable.