DataGridView - conditional button

0
0

I am using a datagrid view bound to a System.ComponentModel.BindingList(Of uiDevice) using a dgv.DataSource = uiDeviceList

The uiDevice.canEdit property can be used to know if the column should have an edit button

The first column of my datagridview is a non bound button column for an Edit button.  I would be ok with a bound button if that works better….

Depending on the user’s security rights, I would like to either have the “edit button” not show or be disabled.  How do I do this at a row level?

Example

[Edit]  Test 1 – editable

Test 2 – not editable

[Edit]  Test 3 – editable

 

In VWG I always used ListViews because of their flexibility.  So DataGridViews are a whole new world to me….

Thanks,

Shawn

 

  • You must to post comments
0
0

See attached modified sample.

The button column’s default cell renderer always shows a button. But you can easily override the column and cell and switch the renderer and change the content to anything you like. You can even have multiple link, buttons, text, images, etc.

  • You must to post comments
0
0

You can use the DataBindingComplete event to go through the rows and adapt the row or the entire column. Use row.DataBoundItem to retrieve the original data used to create the row.

You can use the button column, or you can render any type of html content in a cell, including custom styled buttons, or use “qx-button” to use the css class name of wisej themed buttons. You can use a simple link, or an image, etc. You can also place actual controls in a cell.

See attached small sample.

  • Shawn Ramirez
    Thank you, that was a huge help and will get me where I need to go. I do have a question. Is it possible to not show a button at all on a row that the user doesn’t have “edit” rights to? The method fo gray’ing the button will work, but I was just curious if the button could be removed completely. Thanks, Shawn
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.