Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
336
Best way to assign values to Unbound columns.
posted

I have a grid that will generally have > 25,000 rows.  The user cannot edit any cells in the entire grid.  To minimize memory used and maximize performance I try not to touch gridRow.Cells.  Instead if I need to read a value I will do gridRow.GetCellValue.

At design time I have an UltraGrid bound to an UltraDatasource that has a certain set of bound columns.

At run time the user can choose from a list of fields.  Depending on the input I will add/remove certain unbound columns directly to the ultragrid.  After the columns are added I will query and calculate the values for these new cells.  

To assign the value I am having to use gridRow.Cells("someUnboundCol").Value = someValue.  My understanding, from your Grid Performance Guide, is that Cells are lazily created and if you don't want to use extra memory then don't interact with this collection.  

Question 1:  What would be the best way to assign the cell values for these unbound columns?  Is there any other way to do this without interacting with gridRow.Cells() and thus end up creating extra cell objects?  Is there a way to clear these cells like gridRow.DeallocateCells() or grid.Rows.DeallocateCells.  This appears to loose the values for my unbound column-cells?

Question 2:  Is my method of adding unbound columns to the grid good?  Keep in mind I will sometimes have more than 25,000 rows.  Would it be better to dynamically add/remove columns to the underlying UltraDataSource?  If I did add/remove colums directly to the UltraDataSource (at runtime) I could use DirectCast(gridRow.ListObject, UltraDataRow).SetCellValue("someColumnKey", someValue), but is this more efficient (time or memory wise) than what I am already doing?

Question 3:  Am I worrying too much about allocating/deallocating cells? 


Thanks in advance!

 

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    dzander said:
    Question 1:  What would be the best way to assign the cell values for these unbound columns?  Is there any other way to do this without interacting with gridRow.Cells() and thus end up creating extra cell objects?  Is there a way to clear these cells like gridRow.DeallocateCells() or grid.Rows.DeallocateCells.  This appears to loose the values for my unbound column-cells?

    I don't believe there is any way to set the value on a cell without allocating the cell.

    dzander said:
    Question 2:  Is my method of adding unbound columns to the grid good?  Keep in mind I will sometimes have more than 25,000 rows.  Would it be better to dynamically add/remove columns to the underlying UltraDataSource?  If I did add/remove colums directly to the UltraDataSource (at runtime) I could use DirectCast(gridRow.ListObject, UltraDataRow).SetCellValue("someColumnKey", someValue), but is this more efficient (time or memory wise) than what I am already doing?

    That's an interesting question. To be perfectly honest, I've never done any testing to compare the efficiency of storing  value in the UltraDataSource as opposed to storing it in an unbound column of the grid. My best guess is that it will probably make no significant difference.

    dzander said:
    Question 3:  Am I worrying too much about allocating/deallocating cells? 

    That depends on your goal and your environment. Allocating cells uses memory. If you are running your application on machines where memory is at premium, then you are probably justified in your worries. If you are running on a modern PC and the machine is pretty much dedicated to one application, then you probably don't have to worry about it.

Children
No Data