We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Specified argument was out of the range of valid values

Hi,

When I handle the QueryColCount and QueryRowCount I get the error "Specified argument was out of the range of valid values. Parameter name: rowIndex" when trying to write something in the cells.

If I set the size AND remove the event then everything is working. If I keep the even then it will make the error.

I must be missing a line of code somewhere.

Thanks!


Here is my sample code:

Imports Syncfusion.Windows.Forms.Grid

Public Class Form1

Private Sub GridControl1_QueryColCount(ByVal sender As System.Object, ByVal e As GridRowColCountEventArgs) Handles GridControl1.QueryColCount

e.Count = 10
e.Handled = True

End Sub

Private Sub GridControl1_QueryRowCount(ByVal sender As System.Object, ByVal e As GridRowColCountEventArgs) Handles GridControl1.QueryRowCount

e.Count = 10
e.Handled = True

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

''GridControl1.ColCount = 10
''GridControl1.RowCount = 10

GridControl1.Refresh()

End Sub

End Class



WindowsApplication1_50fd4da.zip

5 Replies

S_ Stephane _ June 10, 2008 05:48 PM UTC

I found a way to use

GridControl1.ColCount = 10
GridControl1.RowCount = 10

Instead of the events. But I'm still curious why the problem occured.



AD Administrator Syncfusion Team June 10, 2008 07:03 PM UTC

You are using clauses like Handles GridControl1.QueryColCount on the sub's declaration to subscribe to the events. This means VB (and not you) decides when this event will start being raised. I suspect that this event is getting hit prior to the grid's complete initialization and that is causing this glitch. If so, then removing the Handles clause, and instead using the AddHandler statement to subscribe to the events gives you control. I would suggest doing it in Form.Load right before your call to grid.Refresh,



S_ Stephane _ June 10, 2008 07:07 PM UTC

Still hapenning with:

Public Class Form1

Private Sub GridControl1_QueryColCount(ByVal sender As System.Object, ByVal e As GridRowColCountEventArgs)

e.Count = 10
e.Handled = True

End Sub

Private Sub GridControl1_QueryRowCount(ByVal sender As System.Object, ByVal e As GridRowColCountEventArgs)

e.Count = 10
e.Handled = True

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

AddHandler GridControl1.QueryColCount, AddressOf GridControl1_QueryColCount
AddHandler GridControl1.QueryRowCount, AddressOf GridControl1_QueryRowCount

GridControl1.Refresh()

End Sub

End Class



AD Administrator Syncfusion Team June 10, 2008 07:20 PM UTC



S_ Stephane _ June 10, 2008 08:17 PM UTC

With your sample I found the difference.

In the InitializeComponent, for some reason I have:

_
Private Sub InitializeComponent()
Me.GridControl1 = New Syncfusion.Windows.Forms.Grid.GridControl
CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'GridControl1
'
Me.GridControl1.ColCount = 1
Me.GridControl1.RowCount = 1


When this is done, if the user write in a cell which is beyond the initial value then the error will happen. Both method of changing the Col/Row count can't be combined.

This cleared things out for me. Thanks !



Loader.
Live Chat Icon For mobile
Up arrow icon