Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have datagridview in my application with four columns, I have made col 1 and col 4 as read only,but col 2 is of type string and col 3 is of type date time,how do i edit these columns and replace the new value.(this is just a simple appln no databinding involved)

thanks in advance,
Posted
Updated 29-Mar-11 18:14pm
v3

1 solution

Some code would be nice.

I would say that you don't edit the datagridview directly. You bind a datatable to it.
If you insist:
C#
dataGridView1.Rows.Add(new object[]{11, "Some text", DateTime.Now, 33});
dataGridView1.Rows[0].Cells[1].Value = "Some other text";
dataGridView1.Rows[0].Cells["Column3"].Value = DateTime.UtcNow; 



BTW. As datagridveiw is not available in WPF, I don't understand why you have tagged this with WPF.
 
Share this answer
 
v2
Comments
Tarun.K.S 29-Mar-11 9:25am    
He had asked this question a number of times and he won't reply or vote at your answer at all!
Amund Gjersøe 29-Mar-11 12:49pm    
I see. I guess he is just spamming the Q&A instead of googling it. Many basic tutorials would had answered his questions, I think.
Tarun.K.S 29-Mar-11 13:39pm    
Exactly!
girish sp 29-Mar-11 23:56pm    
thanks for ur answer..
girish sp 29-Mar-11 23:54pm    
@tarun-dont be so rude dude..i did not know i have to vote the answers..sorry for that..i wont repeat this again..sorry.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900