How to convert a Checkbox to a Toggle Button?

Asked

Viewed 66 times

0

Guys I created a checkbox column - Datagridviewcheckboxcolumn - in the Datagridview and would like to know if it is possible, and how do I make this column to become a button column to enable or disable, a Toggle Button?

1 answer

0

If you are using the . NET Framework library, see the code below, which will convert all CheckBox from the column to a Togglebutton:

In Visual Basic:

For Each column As DataGridViewCheckBoxColumn in SuaDataGrid.Columns
     For Each item In column.Cells
           CType(item, DataGridViewCheckBoxCell).Appearance = System.Windows.Forms.Appearance.Button
     Next
Next

In C#:

foreach (DataGridViewCheckBoxColumn column in SuaDataGrid.Columns)
{
     foreach (var i in column.Cells) {
          ((DataGridViewCheckBoxCell) i).Appearance = System.Windows.Forms.Appearance.Button;
     }
}

Sources:

Link 1 Link 2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.