Hi
I do:
grid.Model[row, col].CellValue = c._value
grid.InvalidateRange(GridRangeInfo.Cell (row,col));
But it does not refresh graphically this single cell.
If i call grid.beginupdate /End update without parameter, no graphical update
if i use the Syncfusion.Windows.Forms.BeginUpdateOptions.Invalidate option it invalidates all the screen causing a huge CPU usage.
As my refresh occur often this is a problem
Any idea
thanks
B. Cliford
AD
Administrator
Syncfusion Team
February 11, 2005 01:03 PM UTC
Also what is the difference between
RefreshRange and InvalidateRange
AD
Administrator
Syncfusion Team
February 11, 2005 01:03 PM UTC
Hi,
I tried to reproduce the problem but it seems fine.
In GridPad, SampleGrid.cs add the following lines:
protected override void OnCurrentCellControlDoubleClick(ControlEventArgs e)
{
trace = true;
int o = 0;
for (int n = 2; n < 10; n++)
{
for (int c = 4; c < 8; c++)
{
if (o % 2 == 0)
{
BeginUpdate(BeginUpdateOptions.InvalidateAndScroll);
Model[n, c].CellValue = o;
EndUpdate(true);
}
o++;
}
}
trace = false;
base.OnCurrentCellControlDoubleClick (e);
}
bool trace = false;
protected override void OnCellDrawn(GridDrawCellEventArgs e)
{
if (trace)
Console.WriteLine("OnCellDrawn: {0} / {1}", e.RowIndex, e.ColIndex);
base.OnCellDrawn (e);
}
You can kick off the test by double-clicking in a cell.
If you want to go the InvalidateRange route you could use the following code:
GridStyleInfo style = new GridStyleInfo();
style.CellValue = o;
Model.SetCellInfo(n, c, style, StyleModifyType.Override, true, true);
InvalidateRange(GridRangeInfo.Cell (n, c));
Update();
If you keep having problems that might be specific to your app then. Best is then to upload a sample project that demonstrates the problem.
Stefan
>Hi
>
>I do:
>grid.Model[row, col].CellValue = c._value
>grid.InvalidateRange(GridRangeInfo.Cell (row,col));
>
>But it does not refresh graphically this single cell.
>If i call grid.beginupdate /End update without parameter, no graphical update
>if i use the Syncfusion.Windows.Forms.BeginUpdateOptions.Invalidate option it invalidates all the screen causing a huge CPU usage.
>As my refresh occur often this is a problem
>Any idea
>thanks
>B. Cliford
AD
Administrator
Syncfusion Team
February 11, 2005 01:21 PM UTC
I actually use the GrifPerf sample where i update frequently the cells.
is it of any importance ?
Thanks
AD
Administrator
Syncfusion Team
February 11, 2005 01:30 PM UTC
2 questions :
-on the code you gave me i don''t understand why do you have to go through:
Model.SetCellInfo(n, c, style, StyleModifyType.Override, true, true);
InvalidateRange(GridRangeInfo.Cell (n, c));
Update();
Using directly
grid.Model[row+1, col+1].CellValue is not good ?
What the update does ? CAn i call it for all my changes ?
Thanks
-why this method is never called on the gridperf sample :OnDrawCellDisplayText
AD
Administrator
Syncfusion Team
February 11, 2005 01:30 PM UTC
2 questions :
-on the code you gave me i don''t understand why do you have to go through:
Model.SetCellInfo(n, c, style, StyleModifyType.Override, true, true);
InvalidateRange(GridRangeInfo.Cell (n, c));
Update();
Using directly
grid.Model[row+1, col+1].CellValue is not good ?
What the update does ? CAn i call it for all my changes ?
Thanks
-why this method is never called on the gridperf sample :OnDrawCellDisplayText
AD
Administrator
Syncfusion Team
February 11, 2005 08:34 PM UTC
When you call
Model[row, col].CellValue = newValue
a lot is happening under the hood. Events are raised, possibly undo generation is created, notification is send out to all view to repaint.
SetCellInfo is a more advanced method. It allows suppressing events being sent out. It also gives a faster way for setting the style information directly into a cell.
See also the PopulateGrid sample for different method for filling the grid.
Stefan
>2 questions :
>-on the code you gave me i don''t understand why do you have to go through:
>Model.SetCellInfo(n, c, style, StyleModifyType.Override, true, true);
>InvalidateRange(GridRangeInfo.Cell (n, c));
>Update();
>
>Using directly
>grid.Model[row+1, col+1].CellValue is not good ?
>
>What the update does ? CAn i call it for all my changes ?
>
>Thanks
>
>-why this method is never called on the gridperf sample :OnDrawCellDisplayText
AD
Administrator
Syncfusion Team
February 12, 2005 09:25 PM UTC
Stefan
Excuse me to come back with the same question but it looks like all the grid if invalidated.
I actually use the GrifPerf sample where i update frequently the cells.
Is the Gridperf could affect the refresh method ?
Thanks again
AD
Administrator
Syncfusion Team
February 13, 2005 04:24 PM UTC
Which grid are you using? I made the changes below in the virtual grid code in that sample, and RefreshRange only seems to be triggering drawing the single cell being changed.
private void btnInitGrid_Click(object sender, System.EventArgs e)
{
this.useDataTableList = this.checkBoxUseDataViewSort.Checked;
this.calculateMaxColumnWidth = this.checkBoxCalculateMaximumWidth.Checked;
this.recordCount = Convert.ToInt32(this.textBoxRecordCount.Text);
this.zipCount = Convert.ToInt32(this.textBoxZipCount.Text);
this.useOptimizedListChangedEvent = checkBoxUseOptimizedListChangedEvent.Checked;
this.InitializeGrid();
this.grid.DrawCell += new GridDrawCellEventHandler(grid_DrawCell);
t = new Timer();
t.Tick += new EventHandler(t_Tick);
t.Interval = 500;
t.Start();
}
Timer t;
Random r = new Random();
private void t_Tick(object sender, EventArgs e)
{
this.grid[2,2].CellValue = r.Next(100);
this.grid.RefreshRange(GridRangeInfo.Cell(2,2));
}
int a = 0;
private void grid_DrawCell(object sender, GridDrawCellEventArgs e)
{
Console.WriteLine(string.Format("{0}-({1},{2}", a++, e.RowIndex, e.ColIndex));
}