0% found this document useful (0 votes)
24 views

Csharp Datagridview Readonly Column

The document shows how to populate a data grid view with sample data by adding rows and setting column names and values. The data grid view is populated with sample product data including an ID, name and price for four products, and one row is set to read only.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Csharp Datagridview Readonly Column

The document shows how to populate a data grid view with sample data by adding rows and setting column names and values. The data grid view is populated with sample product data including an ID, name and price for four products, and one row is set to read only.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

using

using
using
using

System;
System.Data;
System.Windows.Forms;
System.Data.SqlClient;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
dataGridView1.ColumnCount = 3;
dataGridView1.Columns[0].Name = "Product ID";
dataGridView1.Columns[1].Name = "Product Name";
dataGridView1.Columns[2].Name = "Product Price";
string[] row = new string[] { "1",
dataGridView1.Rows.Add(row);
row = new string[] { "2", "Product
dataGridView1.Rows.Add(row);
row = new string[] { "3", "Product
dataGridView1.Rows.Add(row);
row = new string[] { "4", "Product
dataGridView1.Rows.Add(row);

"Product 1", "1000" };


2", "2000" };
3", "3000" };
4", "4000" };

dataGridView1.Rows[1].ReadOnly = true;
}
}
}

You might also like