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

Store an object in a column for faster data access

Hi,

I have implemented a virtual grid which is hooked up to an external data source. Inside GridQueryCellInfo I am currently using the row & column index to obtain each cell’s data. Instead of using the indexes, I want to store and Object in each column. The Object would be a pointer to a column in my data source. Then in GridQueryCellInfo, I could cast the Object & ask it directly for its cell value at e.RowIndex. Is there a property or way that I can store an Object that is associated with a single column?

Thanks,
Shawn

3 Replies

AD Administrator Syncfusion Team October 4, 2006 06:42 AM UTC

Hi Shawn,

You can directly access/store the GridData object instead of using an indexer on the grid. This will avoid events and probably be a factor of 5 - 10 times faster. Please refer the below thread for more details.

http://www.syncfusion.com/Support/forums/message.aspx?MessageID=8704

Another technique that quickly populate things and avoids the events that slow down using an indexer is to use SetCellInfo, passing true and false for the last two arguments.

///
/// Changes the cell contents at a specific row and column index and allows you to suppress raising events
/// and also avoid copying the style objects.
///
/// The row index.
/// The column index.
/// The object that holds cell information.
/// A that specifies the style operation to be performed.
/// A that indicates if the operation was successful.
/// If True, the method will not raise the event.
/// If True, the method will try to assign the style object directly. This is only possible if the
/// existing cell was empty before or if modifyType is . Otherwise it will apply the object as
/// specified in modifyType.
public bool SetCellInfo(int rowIndex, int colIndex, GridStyleInfo style, StyleModifyType modifyType, bool dontRaiseSaveCellInfoEvent, bool copyReferenceOnly)

And also you can use the SetCells method to update the range of cells in a grid.

Thanks,
Haneef


SN Shawn Neidig October 4, 2006 01:24 PM UTC

Hi,

I think the "faster data access" portion of the subject was misleading. A better explanation of my problem is: I need to store a C# Object in each column of my virtual grid.

Each time a column is added to my external data source I get notified & provided two pieces of information column added index & a C# Object to that column. At this point, I want to store that Object in my grid for the specific column index.

Thanks,
Shawn


AD Administrator Syncfusion Team October 5, 2006 08:51 AM UTC

Hi Shawn,

You can use the Hashtable/ArrayList to store the column information in the virtual grid.

Hashtable hash= new Hashtable();
hash.Add(e.ColIndex) = Csharpobject;

Thanks,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon