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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Specified argument was out of the range of valid values

Thread ID:

Created:

Updated:

Platform:

Replies:

74385 Jun 10,2008 02:01 PM UTC Jun 10,2008 08:17 PM UTC Windows Forms 5
loading
Tags: GridControl
Stephane _
Asked On June 10, 2008 02:01 PM UTC

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

Stephane _
Replied On 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.


Administrator [Syncfusion]
Replied On 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,


Stephane _
Replied On 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


Administrator [Syncfusion]
Replied On June 10, 2008 07:20 PM UTC


Stephane _
Replied On 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 !



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;