riceman0
asked on
Can I disable a button in a DataGridViewButtonCell?
Can I disable a button embedded in a DataGridView, created by adding a DataGridViewButtonColumn?
Thanks.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This is straight from the MSDN site. The problem is that it doesn't work when there are more rows in the grid than can be displayed on the form. The example code only deals with 8 rows. When you try to scroll down, it generates an error.
System.ArgumentOutOfRangeE xception was unhandled by user code
Message="Specified argument was out of the range of valid values.\r\nParameter name: rowIndex"
Source="System.Windows.For ms"
ParamName="rowIndex"
StackTrace:
at System.Windows.Forms.DataG ridViewCel l.GetInher itedStyle( DataGridVi ewCellStyl e inheritedCellStyle, Int32 rowIndex, Boolean includeColors)
at System.Windows.Forms.DataG ridViewCel l.get_Form attedValue ()
at Guggenheim.UI.Grid.DataGri dViewDisab leButtonCe ll.Paint(G raphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates elementState, Object value, Object formattedValue, String errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorder Style advancedBorderStyle, DataGridViewPaintParts paintParts) in C:\Documents and Settings\sddamge\My Documents\Visual Studio 2008\Projects\Class Libraries\GridSolution\Gug genheim.UI .Grid\Data GridViewDi sableButto nCell.vb:l ine 81
at System.Windows.Forms.DataG ridViewCel l.PaintWor k(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, Int32 rowIndex, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorder Style advancedBorderStyle, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataG ridViewRow .PaintCell s(Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow, DataGridViewPaintParts paintParts)
at System.Windows.Forms.DataG ridViewRow .Paint(Gra phics graphics, Rectangle clipBounds, Rectangle rowBounds, Int32 rowIndex, DataGridViewElementStates rowState, Boolean isFirstDisplayedRow, Boolean isLastVisibleRow)
at System.Windows.Forms.DataG ridView.Pa intRows(Gr aphics g, Rectangle boundingRect, Rectangle clipRect, Boolean singleHorizontalBorderAdde d)
at System.Windows.Forms.DataG ridView.Pa intGrid(Gr aphics g, Rectangle gridBounds, Rectangle clipRect, Boolean singleVerticalBorderAdded, Boolean singleHorizontalBorderAdde d)
at System.Windows.Forms.DataG ridView.On Paint(Pain tEventArgs e)
InnerException:
System.ArgumentOutOfRangeE
Message="Specified argument was out of the range of valid values.\r\nParameter name: rowIndex"
Source="System.Windows.For
ParamName="rowIndex"
StackTrace:
at System.Windows.Forms.DataG
at System.Windows.Forms.DataG
at Guggenheim.UI.Grid.DataGri
at System.Windows.Forms.DataG
at System.Windows.Forms.DataG
at System.Windows.Forms.DataG
at System.Windows.Forms.DataG
at System.Windows.Forms.DataG
at System.Windows.Forms.DataG
InnerException:
ASKER
Oh my gosh. In other words, no.
But you've heroically added the functionality that was missing. Standing ovation.
I'll need to think about whether I want to add that much code to my app for such a simple thing, but that is good work.