Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to disable a particular row in the GridView

$
0
0

This example demonstrates how to create a helper class that allows you to enable/disable rows with ease. A disabled row is a row that has a specific appearance, and its in-place editors can't be activated.

Example Comments

Added By: Anthony Rich at: 7/8/2013 7:01:19 PM    

This seems like a bug in RowStateHelper.cs:
public GridView GridView
{
     set { UnSubscribeEvents(value); _GridView = value; SubscribeEvents(value); }
}

Shouldn't it be this:
public GridView GridView
{
     set { UnSubscribeEvents(_GridView); _GridView = value; SubscribeEvents(value); }
}
private void UnSubscribeEvents(GridView view)
{
     if (view != null)
     {
          view.RowCellStyle -= view_RowCellStyle;
          view.ShowingEditor -= view_ShowingEditor;
     }
}

Added By: Mary Xin at: 10/31/2013 8:52:47 AM    

I have a grid and it's showing a list of invoices from the table. If the invoice has been posted then I want the row disabled so a user can't edit it.

I am using vb.net. Can you tell me the steps how to do it? I am new to this grid control.

Thanks

Added By: Dean Martin at: 3/6/2014 12:51:27 PM    

This does not handle the situation where rows above a disabled row are deleted. Say I disable rows 5 thru 10. I can delete the rows above row 5 (rows 1 thru 4). And as I do that, what were rows 5 thu 10 now scroll up and I can now edit them or even delete them.

Added By: Dimitros (DevExpress Support) at: 3/6/2014 11:15:04 PM    

Yes, you are right, this example doesn't handle this situation. In this example, we just show the main idea how to accomplish this task. To simplify our code, we use a row datasource index to identify rows. If you want to add/delete rows and save their disabled state, I suggest that you use a key field value to identify rows. In this case, this approach will work correctly.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>