Hi Syncfusion Team,
Following code doesn''t work with Syncfusion 4.2 version, Some of the cellvalues not set correctly. When I use the same code in Syncfusion 1.6 version it works.
for(int i = 0; i < numRowsInGrid; i++)
{
grid[i+1, colIndex].CellValue = "XYZ"
}
When I modify the above code as follows then it works in 4.2 version.
for(int i = 0; i < numRowsInGrid; i++)
{
grid.CurrentCell.MoveTo(i + 1, colIndex);
grid[i+1, colIndex].CellValue = "XYZ"
}
I want to know that is it a Syncfusion 4.2 version bug? If not then which is the correct way to set the grid cellvalues in a loop? Consider "CellValueType" and other required properties set correctly.
Regards,
-Ravi.
AD
Administrator
Syncfusion Team
September 11, 2006 08:35 AM UTC
Hi Ravi,
Are you using DataBoundGrid? If so, you can do this by handling Model.QueryCellInfo or PrepareviewStyleInfo.
By default, DataBoundGrid doesn''t store any style info properties. You can not set any cell or row specific properties for the DataBoundGrid other than the CellValue.You need to handle the PrepareViewStyleInfo (or Model.QueryCellInfo) Event to do this.Through this event you can set the style properties for the grid.
To set the CellValueType for a cell, you check for the e.RowIndex/e.ColIndex, if that points to the row you desired, set the e.Style.CellValueType for it.
See the KnowledgeBase Articles for more info.
QueryCellInfo event : http://www.syncfusion.com/Support/article.aspx?id=10351
PrepareViewStyleInfo event : http://www.syncfusion.com/Support/article.aspx?id=560
You can use the below code snippet to set the cellValue of the cell in a grid.
this.grid.Model[2,2].CellValue = "New Value";
Please let me know if this helps.
Regards,
Haneef
RA
Ravi
September 11, 2006 12:44 PM UTC
Hi Haneef,
Yes, Iam using DataBoundGrid.
this.grid.Model[2,2].CellValue = "New Value";
code doesn''t work. the properties are set in QueryCellInfo.
grid[rowIndex, colIndex].CellValue = "New Value" works when i set the value for a single time. When I keep the same code in loop by changing rowIndex and colIndex it doesn''t work. Doesn''t work means only some values are not set correctly, most of the time first row value is not set correctly.
Please Note that the problem exists after I migrate my code from 1.6 version to 4.2 version.
Regards,
-Ravi.
RA
Ravi
September 11, 2006 12:44 PM UTC
Hi Haneef,
Yes, Iam using DataBoundGrid.
this.grid.Model[2,2].CellValue = "New Value";
code doesn''t work. the properties are set in QueryCellInfo.
grid[rowIndex, colIndex].CellValue = "New Value" works when i set the value for a single time. When I keep the same code in loop by changing rowIndex and colIndex it doesn''t work. Doesn''t work means only some values are not set correctly, most of the time first row value is not set correctly.
Please Note that the problem exists after I migrate my code from 1.6 version to 4.2 version.
Regards,
-Ravi.
AD
Administrator
Syncfusion Team
September 12, 2006 04:15 AM UTC
Hi Ravi,
I tried to reproduce the issue in this sample, but could not get this issue using Essential version 4.2.
http://www.syncfusion.com/Support/user/uploads/DataBoundCellValue_9c222d0d.zip
Are you doing anything different than what the sample does?
Regards,
Haneef
RA
Ravi
September 12, 2006 05:39 AM UTC
Hi Haneef,
Replace this.gridDataBoundGrid1.Model[i,j].CellValue = "SetValueUsingModel"; line with the following line in your sample
"this.gridDataBoundGrid1.Model[i,j].CellValue = i.ToString()+","+j.ToString();"
You can observe that the first line and the last line values are same.
Thanks,
-Ravi.
AD
Administrator
Syncfusion Team
September 12, 2006 07:19 AM UTC
Hi Ravi,
Try calling the Binder.EndEdit method to resolve this.
for(int i = 1 ;i <= RowCount;i++)
{
for(int j = 1 ;j<= ColCount;j++)
{
this.grid.Model[i,j].CellValue = i.ToString()+","+j.ToString();
this.grid.Binder.EndEdit();
}
}
Thanks,
Haneef
RA
Ravi
September 12, 2006 07:39 AM UTC
Hi Haneef,
It works with your workaround code. Is this bug exists in 4.2 version. If yes, will it be fixed in future versions?
Thanks,
-Ravi.