Red cross on datagrid

  • Thread starter Thread starter Rob Oldfield
  • Start date Start date
R

Rob Oldfield

I have a VB windows forms app that generally works fine. Just occasionally
though users are getting an error message (I still haven't managed to get
any of them to behave themselves and make a note of it) and then the
datagrid on the form is replaced with a red cross. I've tried lots of
testing to try to recreate the error but with no success. I have seen
suggestions on the web about using CancelBinding and ResumeBinding to
suspend the datagrid's dependence on it's datasource as a solution to the
problem but have so far not figured out how to put it into practise. So...

The datagrid is based on a dataview based on a typed dataset. How do I
either Cancel and Resume binding, or (the sledgehammer approach) just
completely remove the datasource so that I can reapply it later?

Any ideas?
 
Rob,

Do you have any custom data grid styles in your data grid? From what I have
experienced, the red X occurs when an exception is thrown during the Paint
method of the grid style. Also, what version of .Net are you using? (We
used to get seemingly random red X's in 1.0)

Don
 
Yes. The datagrid has a button column in there and also a combo box added
to one of the text box columns. And version 1.1

I do have some code in the paint event.... but it's nothing that I'd expect
to be going wrong.....

If MyDV.Count > 0 Then
If MyDG.CurrentCell.ColumnNumber = 7 Then
cboComm.Width = MyDG.GetCurrentCellBounds.Width
End If
End If

.....just setting the combo in column 7 to the appropriate width if there are
any rows of data to display.
 
Wow. Nice bug. Don't think it's the same as my issue though as all of my
columns fit without scrolling.... but you have answered my original question
with the SetDataBinding(Nothing, Nothing) syntax. Many thanks. I'll give
it a go and see what happens.
 
I'm amazed that we even found it, considering the *very*
specific conditions that triggers it

If you don't scroll *all* the way to the right, or if you use the
keyboard to scroll, or if you set focus to the last column
everything works fine!

/claes
 
Back
Top