out of range error

I have a problem when I try to access my cellstyleinfo. When I try to access them using ex. Grid[0,2] I get an out of range in colindex exception although the number of rows and cols far exceed 0 and 2. Other examples seems to work just fine, so it must have something to do with my grid setup. Any ideas ? Regards Per Millard Senior Software Architect PBJ Consult A/S

3 Replies

AD Administrator Syncfusion Team November 3, 2003 12:11 PM UTC

Are you using a GridControl, or a GridDataBoundGrid? If you are using a GridDataBoundGrid, then use the GridBoundColumn[col].HeaderText property to get/set the header text. If you have dynamically changed the row/column count of a GridControl at runtime, also make sure you call grid.ResetVolatileData. If you cannot spot something, if you can post a little sample project showing the problem, we should be able to spot something here.


PM Per Millard November 3, 2003 12:58 PM UTC

Hi Clay It seems that I manually set RowCount and ColCount to 0 at grid creation and subsequently supplied them in the Query event handlers. Not resetting the values when creating the grid seemed to eliminate the error. However, I still have a problem changing the style properties outside the QueryGridInfoHandler event handler. No matter what I try to change, be it cellstyle, cellvalue etc., the changes are just ignored. Again, this works fine in a simple example, but in my applikation, the grid ignores ex. Grid[0,2].CellType="Static" Any ideas ? > Are you using a GridControl, or a GridDataBoundGrid? > > If you are using a GridDataBoundGrid, then use the GridBoundColumn[col].HeaderText property to get/set the header text. > > If you have dynamically changed the row/column count of a GridControl at runtime, also make sure you call grid.ResetVolatileData. > > If you cannot spot something, if you can post a little sample project showing the problem, we should be able to spot something here.


AD Administrator Syncfusion Team November 3, 2003 02:25 PM UTC

You mentioned QueryCellInfo. Do you have code like if(e.ColIndex > 0 && e.RowIndex > 0) {// to prevent trying to set values when e.RowIndex == 0? You should if you want the grid to provide these values from its store. Also, are you handling SaveCellInfo? If so, you should not be setting e.Handled = true when e.RowIndex == 0. If you do this, it will prevent the grid from saving the changes for row 0 to its data store. If you are dynamically providing the rowcount through QueryRowCount for a virtual grid, you can also try setting grid.Model.Data.RowCount = 1 so the grid will allocate the storage for this header row.

Loader.
Up arrow icon