Hello,
I am using ultrachart in ultragrid. I have 8 different columns : Name, Id, scorePoints, ultrachart ( for showing score w.r.t. timing tick) & other columns.
my datasource for ultraGrid is datatable and for ultraChart column(in datatable) , I am using list<ChartDataLive> as datatype ( scorePoint, timeTick)
my datatable is updating every minute. when m doing ultraGrid1.datasource = myDatatable every minute, chart is showing fine.
but when updating grid cell individually, the data updating perfectly for other columns except ultrachart column.
means, ultrachart column is showing data , it has consumed at first attempt of ultraGrid1.datasource , not the updated one.
My requirement is to update cell individually after first attempt of datasource.
please suggest better approach for this.
Just to expand a bit on Mike's answer...
If you bind the UltraWinGrid to a DataSet, DataTable, or any BindingList<T>, then the data source itself will track when a cell value changes (is set) and send a notification that something has changed. And then a bound control, like the grid, can listen to that notification and update the display. But if you have a cell that contains a complex object, like a List<T>, then unless you are setting the value of that field in the data source to a new List object, the data source won't know that anything changed. If you are adding or removing items from the List, or if you are getting an item in the list and changing the properties of that item, then the DataSource has no way of knowing that and cannot know that the value of the field has changed, because as far as it's concerned, the field is still holding a reference to the same object. There are ways around that. You could create your own DataSource that hooking into the events of the List and then your List would have to hook into the notifications of the items within that list and bubble up those notifications. And you are using your DataSource to bind to a bunch of different control, it might be worthwhile to do that. But if you are only binding to the grid, then the simplest thing to do is to just send a notification to the grid whenever you know your code has modified the list. And the way to do that is to call the Refresh method on the row:
this.ultraGrid1.Rows[0].Refresh(RefreshRow.ReloadData);
I tried to upload full code, but able to upload files only.
Following is the sample code which displaying the issue I stated above.
check if I rightly put this.ultraGrid1.Rows[0].Refresh(RefreshRow.ReloadData);
Please let me know the right approach.
SampleCode.zip
this.ultraGrid1.Rows.Refresh(RefreshRow.FireInitializeRow);
this do the wonder for my requirement.
Thanks Mike & Michael.
Hello, I put together a runnable sample and things are working with both radio buttons. Please review this and share your thoughts.
SampleCode (3).zip
Hi Lizzy,
Lizzy De said:thing is when using ColumnChooser, everytime ColumnChooser get refreshed if doing ultraGrid1.datasource = myDatatable everytime.
I'm not sure what you mean by this or where you are getting that impression from. There is no reason why the ColumnChooser would ever set the grid's DataSource. Settings the DataSource property of the grid is a very destructive thing. It causes the entire layout to get reset and it will lose any state information like selection. So the ColumnChooser does not, and would not, ever set the DataSource on the grid. And you should not do that, either. Typically, you set the DataSource on the grid once and that's it. And then refreshing the data is handled by notifications that the grid received from the data source via IBindingList.
Anyway, I took a look at your sample project. I can't run the sample becuase there are a whole bunch of files missing. But I can see what what you are doing here is using the InitializeRow event to make an Image of an UltraChart control and apply that Image as the ImageBackground of the cell.
This probably isn't the most efficient way to do things but it seems like it should work. The only thing you have to make sure of is that when you change the data, you have to make sure InitializeRow fires for that row. As I explained, ordinarily, the data source will send a notification when you set the value of a field in the data. But your code is not doing that here. Instead, you are getting the field value - which is a List<ChartData> - and you are modifying the properties and items within that list. So the DataSource (your table) doesn't know you did that. And so the grid doesn't update automatically.
Anyway... since your timer1_Tick is altering the value of every chart cell in every grid row. So I can't test it... but I think all you need to do for this sample is to force the InitializeRow event to fire for every row in the grid. And you can do that very easily like so: this.ultraGrid1.Rows.Refresh(RefreshRow.FireInitializeRow);
Having said that... constantly refreshing the grid like this might cause you some problems. For example, if you want the users to be able to edit the grid, that's going to be tough, because I think it might come out of edit mode every time this code gets called. So... if you don't allow editing, it might be okay, but if you need the users to be able to edit, that could be tricky.
Here is an example of loading our UltraChart in the UltraGrid directly in case you are interested. 0654.WindowsFormsApplication7.zip