PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms The ListManager's position must be equal to rowNum

Reply

The ListManager's position must be equal to rowNum

 
Thread Tools Rate Thread
Old 03-09-2003, 05:12 PM   #1
Rob Oldfield
Guest
 
Posts: n/a
Default The ListManager's position must be equal to rowNum


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


  Reply With Quote
Old 04-09-2003, 08:55 AM   #2
Dmitriy Lapshin [C# / .NET MVP]
Guest
 
Posts: n/a
Default Re: The ListManager's position must be equal to rowNum

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=...ogle.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
>
>


  Reply With Quote
Old 04-09-2003, 11:09 AM   #3
Rob Oldfield
Guest
 
Posts: n/a
Default Re: The ListManager's position must be equal to rowNum

Thanks for that Dmitriy. It's good to know that I'm not the only one that's
been beating my head against a wall over this one.

Sadly, I'm too much of a beginner at this to be able to convert the C#
example you've linked to VB. I don't suppose you know of anywhere with a VB
version of the same thing?

--
Rob Oldfield
www.realuk.co.uk


"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=...ogle.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
> >
> >

>



  Reply With Quote
Old 04-09-2003, 11:53 AM   #4
Dmitriy Lapshin [C# / .NET MVP]
Guest
 
Posts: n/a
Default Re: The ListManager's position must be equal to rowNum

Rob,

There is a custom column style example in the MSDN Library and the example
is available in both C# and VB .NET. Please do a search for the
"DataGridColumnStyle Class" topic.

--
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:eTW3xyscDHA.1072@TK2MSFTNGP12.phx.gbl...
> Thanks for that Dmitriy. It's good to know that I'm not the only one

that's
> been beating my head against a wall over this one.
>
> Sadly, I'm too much of a beginner at this to be able to convert the C#
> example you've linked to VB. I don't suppose you know of anywhere with a

VB
> version of the same thing?
>
> --
> Rob Oldfield
> www.realuk.co.uk


  Reply With Quote
Old 04-09-2003, 01:56 PM   #5
Rob Oldfield
Guest
 
Posts: n/a
Default Re: The ListManager's position must be equal to rowNum

OK. I'll try that. Thanks.

--
Rob Oldfield
www.realuk.co.uk

"Dmitriy Lapshin [C# / .NET MVP]" <x-code@no-spam-please.hotpop.com> wrote
in message news:etfuWLtcDHA.2112@TK2MSFTNGP10.phx.gbl...
> Rob,
>
> There is a custom column style example in the MSDN Library and the example
> is available in both C# and VB .NET. Please do a search for the
> "DataGridColumnStyle Class" topic.
>
> --
> 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:eTW3xyscDHA.1072@TK2MSFTNGP12.phx.gbl...
> > Thanks for that Dmitriy. It's good to know that I'm not the only one

> that's
> > been beating my head against a wall over this one.
> >
> > Sadly, I'm too much of a beginner at this to be able to convert the C#
> > example you've linked to VB. I don't suppose you know of anywhere with

a
> VB
> > version of the same thing?
> >
> > --
> > Rob Oldfield
> > www.realuk.co.uk

>



  Reply With Quote
Old 17-09-2003, 09:26 AM   #6
Rob Oldfield
Guest
 
Posts: n/a
Default Re: The ListManager's position must be equal to rowNum

Just to follow this up if anyone else is looking for information on
this one...

I found that even using a custom checkbox column, I was still getting
the same error. One other piece of information: if the datagrid's
dock style is set to Full then you can always get the error by
clicking the last 'half visible' checkbox.

I took the case up with MS support and they have now confirmed that
it's a bug which is fixed in VS 2003. No word of whether they're
going to produce a fix for 2002.


"Rob Oldfield" <rob(an a in a circle)realuk.co.uk> wrote in message news:<OBEP$PucDHA.2436@TK2MSFTNGP12.phx.gbl>...
> OK. I'll try that. Thanks.
>
> --
> Rob Oldfield
> www.realuk.co.uk
>
> "Dmitriy Lapshin [C# / .NET MVP]" <x-code@no-spam-please.hotpop.com> wrote
> in message news:etfuWLtcDHA.2112@TK2MSFTNGP10.phx.gbl...
> > Rob,
> >
> > There is a custom column style example in the MSDN Library and the example
> > is available in both C# and VB .NET. Please do a search for the
> > "DataGridColumnStyle Class" topic.
> >
> > --
> > 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:eTW3xyscDHA.1072@TK2MSFTNGP12.phx.gbl...
> > > Thanks for that Dmitriy. It's good to know that I'm not the only one

> that's
> > > been beating my head against a wall over this one.
> > >
> > > Sadly, I'm too much of a beginner at this to be able to convert the C#
> > > example you've linked to VB. I don't suppose you know of anywhere with

> a
> VB
> > > version of the same thing?
> > >
> > > --
> > > Rob Oldfield
> > > www.realuk.co.uk

> >

  Reply With Quote
Old 17-09-2003, 03:18 PM   #7
Luca
Guest
 
Posts: n/a
Default Re: The ListManager's position must be equal to rowNum

thank you for your job... i was looking for that error....
i'll wait to install VS 2003.
If u know about fix write her..
bye Bye
Luca

"Rob Oldfield" <rob@realuk.co.uk> ha scritto nel messaggio
news:b3130439.0309170026.2c806d4@posting.google.com...
> Just to follow this up if anyone else is looking for information on
> this one...
>
> I found that even using a custom checkbox column, I was still getting
> the same error. One other piece of information: if the datagrid's
> dock style is set to Full then you can always get the error by
> clicking the last 'half visible' checkbox.
>
> I took the case up with MS support and they have now confirmed that
> it's a bug which is fixed in VS 2003. No word of whether they're
> going to produce a fix for 2002.
>
>
> "Rob Oldfield" <rob(an a in a circle)realuk.co.uk> wrote in message

news:<OBEP$PucDHA.2436@TK2MSFTNGP12.phx.gbl>...
> > OK. I'll try that. Thanks.
> >
> > --
> > Rob Oldfield
> > www.realuk.co.uk
> >
> > "Dmitriy Lapshin [C# / .NET MVP]" <x-code@no-spam-please.hotpop.com>

wrote
> > in message news:etfuWLtcDHA.2112@TK2MSFTNGP10.phx.gbl...
> > > Rob,
> > >
> > > There is a custom column style example in the MSDN Library and the

example
> > > is available in both C# and VB .NET. Please do a search for the
> > > "DataGridColumnStyle Class" topic.
> > >
> > > --
> > > 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:eTW3xyscDHA.1072@TK2MSFTNGP12.phx.gbl...
> > > > Thanks for that Dmitriy. It's good to know that I'm not the only

one
> > that's
> > > > been beating my head against a wall over this one.
> > > >
> > > > Sadly, I'm too much of a beginner at this to be able to convert the

C#
> > > > example you've linked to VB. I don't suppose you know of anywhere

with
> > a
> > VB
> > > > version of the same thing?
> > > >
> > > > --
> > > > Rob Oldfield
> > > > www.realuk.co.uk
> > >



  Reply With Quote
Old 19-09-2003, 06:53 AM   #8
Luca
Guest
 
Posts: n/a
Default Re: The ListManager's position must be equal to rowNum

I installed VS 2003 and i have the same problem :-(

Can someone help me ?

Thank you.



"Rob Oldfield" <rob@realuk.co.uk> ha scritto nel messaggio
news:b3130439.0309170026.2c806d4@posting.google.com...
> Just to follow this up if anyone else is looking for information on
> this one...
>
> I found that even using a custom checkbox column, I was still getting
> the same error. One other piece of information: if the datagrid's
> dock style is set to Full then you can always get the error by
> clicking the last 'half visible' checkbox.
>
> I took the case up with MS support and they have now confirmed that
> it's a bug which is fixed in VS 2003. No word of whether they're
> going to produce a fix for 2002.
>
>
> "Rob Oldfield" <rob(an a in a circle)realuk.co.uk> wrote in message

news:<OBEP$PucDHA.2436@TK2MSFTNGP12.phx.gbl>...
> > OK. I'll try that. Thanks.
> >
> > --
> > Rob Oldfield
> > www.realuk.co.uk
> >
> > "Dmitriy Lapshin [C# / .NET MVP]" <x-code@no-spam-please.hotpop.com>

wrote
> > in message news:etfuWLtcDHA.2112@TK2MSFTNGP10.phx.gbl...
> > > Rob,
> > >
> > > There is a custom column style example in the MSDN Library and the

example
> > > is available in both C# and VB .NET. Please do a search for the
> > > "DataGridColumnStyle Class" topic.
> > >
> > > --
> > > 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:eTW3xyscDHA.1072@TK2MSFTNGP12.phx.gbl...
> > > > Thanks for that Dmitriy. It's good to know that I'm not the only

one
> > that's
> > > > been beating my head against a wall over this one.
> > > >
> > > > Sadly, I'm too much of a beginner at this to be able to convert the

C#
> > > > example you've linked to VB. I don't suppose you know of anywhere

with
> > a
> > VB
> > > > version of the same thing?
> > > >
> > > > --
> > > > Rob Oldfield
> > > > www.realuk.co.uk
> > >



  Reply With Quote
Old 19-09-2003, 11:26 PM   #9
yanna
Guest
 
Posts: n/a
Default Re: The ListManager's position must be equal to rowNum

Hi Luca,

You're not the only one who has found the problem. I'm using
VS 2003 and I found the similar problem.

I can check/uncheck each cell as long as I don't sort the CheckboxColumn.
The error message will appear after I do the sorting and then check or
uncheck a cell.

In my case, I have to disable the sorting for the whole datagrid
which is not desired at all. Has anybody have a solution for this
one as well?

Yanna

"Luca" <luca@levon.it> wrote in message news:<uXyT$HnfDHA.2400@TK2MSFTNGP11.phx.gbl>...
> I installed VS 2003 and i have the same problem :-(
>
> Can someone help me ?
>
> Thank you.

  Reply With Quote
Old 25-09-2003, 02:48 PM   #10
Rob Oldfield
Guest
 
Posts: n/a
Default Re: The ListManager's position must be equal to rowNum

Hmm. I'm afraid that I'm going to be very little help here. I was getting
the problem in VS 2002 even after I tried Dmitriy's idea of using a custom
column. Contacted MS support and they basically said that it was a bug in
2002 but fixed in 2003. I already had a copy of 2003 on order which turned
up a couple of days afterwards. Installed that and I no longer get the
error.

If you're getting this error in 2003 then all I can suggest is to go to
Microsoft. If it's a bug in 2002 then it'll almost certainly be a bug in
2003 (I would have thought). One question though - if you change the
docking for the datagrid, then do you still get the same error? I actually
noticed (in 2002) that if you have the dock style set to full and then click
on a 'half visible' check box at the bottom of the grid, then you always got
the error.

One other thing as well. The code I was using (originally stolen from MS)
fell over in another way in 2003. Clicking on that last 'half visible'
check box always created problems - the scroll event was kicking in to
reposition the row you click on and moving it before the click event fires.
I managed to get a solution for this one out of Microsoft as well, basically
to catch the cell clicked in the mouse down event instead....

Top of class...
Private row As Integer, column As Integer
Private hti As DataGrid.HitTestInfo
Private pt As Point


Private Sub ClientsDG_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ClientsDG.Click
Dim SendColNo As Integer = 2
If afterCurrentCellChanged AndAlso hti.Type = DataGrid.HitTestType.Cell Then
If column = SendColNo Then
Me.ClientsDG(row, SendColNo) = Not CBool(Me.ClientsDG(row, SendColNo))
End If
End If
afterCurrentCellChanged = False
End Sub

Private Sub ClientsDG_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles ClientsDG.MouseDown
Dim myHitTest As System.Windows.Forms.DataGrid.HitTestInfo
myHitTest = ClientsDG.HitTest(e.X, e.Y)
row = myHitTest.Row
column = myHitTest.Column
pt = Me.ClientsDG.PointToClient(Control.MousePosition)
hti = Me.ClientsDG.HitTest(pt)
End Sub


--
Rob Oldfield
www.realuk.co.uk

"yanna" <liu_yanna@hotmail.com> wrote in message
news:6830e309.0309191426.1c19e6f7@posting.google.com...
> Hi Luca,
>
> You're not the only one who has found the problem. I'm using
> VS 2003 and I found the similar problem.
>
> I can check/uncheck each cell as long as I don't sort the CheckboxColumn.
> The error message will appear after I do the sorting and then check or
> uncheck a cell.
>
> In my case, I have to disable the sorting for the whole datagrid
> which is not desired at all. Has anybody have a solution for this
> one as well?
>
> Yanna
>
> "Luca" <luca@levon.it> wrote in message

news:<uXyT$HnfDHA.2400@TK2MSFTNGP11.phx.gbl>...
> > I installed VS 2003 and i have the same problem :-(
> >
> > Can someone help me ?
> >
> > Thank you.



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off