Error: "Index was outside the bounds of the array" when binding the datatable with datagrid

G

Gerry Viator

Hi again,

I'm still getting this error when I bind the datagrid with a Datatable:

Sorry for the second post on this matter.

A first chance exception of type 'System.IndexOutOfRangeException' occurred
in system.windows.forms.dll
Additional information: Index was outside the bounds of the array.


I have noticed if I keep the Readonly = false on the datagrid I don't get
the error.
I need it to equal true though.

please help

thanks
Gerry
 
G

Gerry Viator

Hi all,
I think I fixed the problem, this seems to work

In the sub where I add new rows to the datatable I just put this at the
beginning

Entrygrid.ReadOnly = False
and then at the end i put this
Entrygrid.ReadOnly = True

At first I didn't have the debug Exceptions to break into the program
when exceptions were thrown. Once I changed it I started getting the error
I was stuck on for awhile. I guess that makes since how can the Datagrid
update if it is set to readonly. Du....

thanks
Gerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top