Click here to Skip to main content
15,895,746 members
Articles / Programming Languages / Visual Basic
Article

To make any column readonly in Datagrid

Rate me:
Please Sign up or sign in to vote.
1.20/5 (2 votes)
28 Jul 2006 45.7K   21  
This is what i used to make a datagrid column readonly.

Introduction

This is one of the way to make a column at any index readonly.

When datagrid is bounded to the datasource, the column and rows are genrated in the datagrid. This means datagrid must have the properties of the datasource. if the column in datasource is readonly then it must be apprear as readonly. Same thing I used to make the datagrid column readonly.

   this is just a piece of code..

   DT.Columns(0).ReadOnly = True '// Make the column(0) readonly and assign to DataGrid.

   Datagrid!.DataSource = DT

  where DT is datatable used to collect the data from database and is datasource to the datagrid Datagrid1.

  For further editing make the column readonly= false and make changes and again turn it into readonly.

 One can changed the index (0) of datatable to any index making that column / more than one column / all coulmn readonly.

if this way works , this will save your tedious job.

 Thanks.

 

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --