Forum  General Visual ...  How do I...?  DataGridView - Hide cells on a row
Previous Previous
 
Next Next
New Post 5/31/2012 12:20 PM
Informative
  asaporta
8 posts
No Ranking


DataGridView - Hide cells on a row 

 Hi There,

I would like to restrict the user in selecting rows.

I was thinking of providing a DataGridViewCheckBoxColumn and hide it for those rows that user should not select.

The .Visible property is read only.

 

Avri

 
New Post 6/1/2012 1:58 PM
  palli
14313 posts
1st Level Poster




Re: DataGridView - Hide cells on a row 

 Hi Avri,

The DataGridView does not support individual Cell hiding, only whole columns. 

Probably the most simiple way you have got is to activate the Panel of the cell and have it span one column and one row, which means it will overlay this one particular cell. Every cell in a DataGridView has a Panel associated with it (DataGridViewCellPanel) which is hidden by default. If you need/want you can add what ever control you want to this panel, but in this case it may be sufficient to just show it in order to hide the checkbox.

To enable/show a panel for a specific cell you can use the following code:

 

this.dataGridView1.Rows[1].Cells[0].Panel.Rowspan = 1;
this.dataGridView1.Rows[1].Cells[0].Panel.Colspan = 1;

 

You also have the option of creating custom column types, in which case you might be able to have a UserControl as the contents of the cell. See more information in this CompanionKit's sample here

Hope this helps,

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
Previous Previous
 
Next Next
  Forum  General Visual ...  How do I...?  DataGridView - Hide cells on a row
.NET HTML5 Web, Cloud and Mobile application delivery | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2012 Visual WebGui®       Visual WebGui weblog on ASP.NET Gizmox Blog Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS