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
20
How to add rows of data to an ultrawingrid (Partly static and partly dynamic data)
posted

Hi all, I have a C# program in which I have a function called ScanMainDirectory() that uses a FileSystemWatcher to monitor the contents of the directory and if any files are present, they're processed. In this function, I have 5 variables that store values such as FileCount, ProcessingStartTime, ProcessingEndTime, NumberOfFilesProcessed and Path.

My aim is to add one new row of data to the ultrawingrid each time the function is called and the row will hold 5 values as listed above(which will be across 5 columns in that row). My issue is that I'm not making a call to add an entire row at a time toward the end of the ScanMainDirectory() function body. Instead, I need to add variable values directly to the ultragrid's cells for row#1,row#2 and so on. What this is expected to look like is (the following table structure):

FileCount |ProcessingStartTime |ProcessingEndTime |NumberOfFilesProcessed |Path ===============================================================

35                 10:36:52.621            10:38:26.537               30                              c:\abc

20                 10:54:21.236            10:24:51.258               20                              c:\def


================================================================

Within the ScanMainDirectory() function, once I have a value for path, I'd like to add that value to the cell[0] of row[1] i.e. second row at the bottom of the Path Column. Next, when I have the ProcessingStartTime, I'd like to add that value to the cell[1] at the bottom of the ProcessingStartTime column of row[1] and so on until I make up the whole second row in the datagrid. However, the filecount value (20) can change in real time in the bottom-most(current / row[1] ) row and so can the value for NumberOfFilesProcessed value (20) depending on the number of files yet to be processed and the number that have been. With the ScanMainDirectory is called next, I'd like to make up another row of data by adding in values into each cell of that row.

I was wondering if there is a "best approach" to solving a problem such as this one wherein, I can't use a datatable as I don't have an entire "row" of data before hand to add to the dataTable but all I have is bits of information that need to be added in individually "on the fly" as they are calculated and by the time the function has been executed(one full cycle), a row of data should be visible on the UltraWinGrid.

Moreover, FileCount value and NumberOfFilesProcessed value can keep changing in real time and must be reflected on the datagrid's current row(i.e. the most recent row added. In the example above, these values can change in the second row (i.e. row being updated) but not the first(which was completed before moving on to create the second row). Once I start adding in bits of information to make up the third row, it can change in that third row but not the first nor second and so on...) and the other bits of information such as path and start time are more or less static(i.e. once the values are determined, they don't change within the row like time and filecount values). Any tips/suggestions will be greatly appreciated.

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

    I'm not really sure exactly what the issue is. I got a little fuzzy around your third paragraph. But it seems to me that one issue you are having is that you want to add a blank row to the grid and only fill in some cells while leaving others temporarily blank. 

    If that's the case, then I'm not sure I see the problem. You can certainly add an empty row to your grid or to your data source and set the Value on individual cells.  The only reason this would not work is if the data source did not allow nulls in certain columns - in which case you would not be able to commit the row until those fields were filled in. I assume you have control over the data source, so this should not be an issue. But if you do not have control over the data source, then what you could do is create an additional layer in between the grid and the real data source. You could use another DataTable or maybe an UltraDataSource component as the grid's DataSource and then only update the "real" data source when the rows are completely filled in.

Children
No Data