Connecting Tech Pros Worldwide Forums | Help | Site Map

How to set the DataTable rows into non-edit mode?

nayana kalkur's Avatar
Newbie
 
Join Date: Dec 2008
Location: Bangalore
Posts: 4
#1: Dec 31 '08
Hi,

I have developed a new tool window for my addin. I have added a user control to the tool window so that i can populate the output of some function in that data grid present in the tool window.
In the data grid i have created a data table which has rows. When i click on the rows in the data table, i am able to edit them. I want them to be set to non-edit mode, so that the data displayed in the row of the data table is not editable. how can i achieve this?

below is the code about how i have created the data table:

Expand|Select|Wrap|Line Numbers
  1. DataTable d = new DataTable();
  2. DataColumn col = new DataColumn("line_no", typeof(string));
  3. DataColumn col1 = new DataColumn("words", typeof(string));
  4. d.Columns.Add(col);
  5. d.Columns.Add(col1);
  6. foreach (line_num_keywords c in v)
  7.             {
  8.                 DataRow dr = d.NewRow();
  9.                 dr["line_no"] = c.line_number;
  10.                 dr["words"] = c.captured_keyword;
  11.                 d.Rows.Add(dr); 
  12.             }
  13. dataGridView1.DataSource = d;
  14.  
Is there any fucntion which helps me to set the data table to non-edit mode?

Thanks,
Nayana

vekipeki's Avatar
Expert
 
Join Date: Nov 2007
Posts: 231
#2: Dec 31 '08

re: How to set the DataTable rows into non-edit mode?


I'm not sure if this what you are looking for, but there is a ReadOnly property which you can set for a cell, or entire row/column/DataGridView to make them read-only:

DataGridView.ReadOnly Property (System.Windows.Forms)
nayana kalkur's Avatar
Newbie
 
Join Date: Dec 2008
Location: Bangalore
Posts: 4
#3: Dec 31 '08

re: How to set the DataTable rows into non-edit mode?


yup! thanks. it helped :)
Reply


Similar C# / C Sharp bytes