Thanks for that Dmitriy. It's good to know that I'm not the only one that's
example you've linked to VB. I don't suppose you know of anywhere with a VB
"Dmitriy Lapshin [C# / .NET MVP]" <x-code@no-spam-please.hotpop.com> wrote
in message news:uy$03nrcDHA.1180@TK2MSFTNGP11.phx.gbl...
> Hi Rob,
>
> I feel your pain as I was fighting hard with this error a couple of months
> ago.
>
> Here are some of my observations:
>
> 1. This error is somehow related to CheckBoxColumn
> 2. The message box you see is displayed from within the column style class
> itself (you can check this with stack trace window). Seems that the column
> style has an internal exception handler that traps exceptions and displays
a
> message box. If this is true, I'd wholeheardetly wish it should change in
> the next version of .NET Framework.
> 3. In your case, it will be easier and quicker to develop your own
checkbox
> column, based on several custom column samples found here:
>
>
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&newwindow=1&selm=c80d616.0201310841.648f7ab2%40posting.google.com&rnum=8
>
> (mind the line wraps)
>
> P.S. I am racking my brain how data grid column styles themselves trap
mouse
> events, as this cannot be done in a custom column style. Probably there is
> some private event?
>
> --
> Dmitriy Lapshin [C# / .NET MVP]
> X-Unity Test Studio
>
http://x-unity.miik.com.ua/teststudio.aspx
> Bring the power of unit testing to VS .NET IDE
>
> "Rob Oldfield" <rob(an a in a circle)realuk.co.uk> wrote in message
> news:uwiA6YjcDHA.620@TK2MSFTNGP11.phx.gbl...
> > I have a datagrid on a windows form that is tripping an error. The
> > details...
> >
> > Windows form created in Visual Studio using VB with a data adapter, a
> > dataset and a dataview included. Load code looks pretty standard...
> >
> > ClientsDS1.Clear()
> > ClientsDA.Fill(ClientsDS1)
> > ClientsDS1.Tables("Clients").Columns("Sel").ReadOnly=False
> >
> > The form is basically just a datagrid, with the Sel column (which is
> > Boolean) populating a check box. The idea is that the user can just
> scroll
> > through the list and select whichever clients they're interested in.
> >
> > (The datagrid is actually bound to a dataview which allows users to
filter
> > the list of clients that they see - but I can't see that that has any
> > bearing on this problem.)
> >
> > So the TableStyle of the datagrid is set at design time. The last
column
> > being bound to this Sel boolean value.
> >
> > Up to here everything works fine with no errors.
> >
> > Next though I want to get rid of the annoying behaviour of the datagrid
so
> > that if you click on the first checkbox to select the first client it
just
> > selects the 'cell' with the first click and it's only the second click
> that
> > changes the value of the checkbox. So I stole some code from somewhere
> > else....
> >
> > This is defined at the top of the class...
> >
> > Private afterCurrentCellChanged As Boolean = False
> >
> > and.this is in the datagrid click event...
> >
> > Dim SendColNo As Integer = 2, dr As DataRow
> > Dim pt As Point = Me.ClientsDG.PointToClient(Control.MousePosition)
> > Dim hti As DataGrid.HitTestInfo = Me.ClientsDG.HitTest(pt)
> > If afterCurrentCellChanged AndAlso hti.Type = DataGrid.HitTestType.Cell
> Then
> > If hti.Column = SendColNo Then
> > Me.ClientsDG(hti.Row, hti.Column) = Not
> CBool(Me.ClientsDG(hti.Row,
> > hti.Column))
> > End If
> > End If
> > afterCurrentCellChanged = False
> >
> > (the 2 is the column number of the boolean column i.e. it's the third
> column
> > in the datagrid)
> >
> > ...so now when you click the boolean column it immediately changes the
> state
> > of the check. But....
> >
> > About one time in ten when I click a check box I get this...
> >
> > Error when committing the row to the original data store
> >
> > The ListManager's position must be equal to rowNum.
> > Parameter name: rowNum Do you want to correct the value?
> >
> > I can't seem to trap this error. Even if I put the entire datagrid
click
> > event in a try catch block then the error just comes up.
> >
> > So... two questions...
> >
> > Any ideas what's going and how to fix it?
> > Any different ways to get the datagrid to respond correctly to the first
> > click from a mouse?
> >
> > Thanks.
> >
> > --
> > Rob Oldfield
> >
www.realuk.co.uk > >
> >
>