Home Forums WinForms controls Xceed Grid for WinForms SummaryCell or ValueCell – Need text and calc in cell Reply To: SummaryCell or ValueCell – Need text and calc in cell

User (Old forums)
Member
Post count: 23064

We’ve come to the point now that we know we need a valuerow since summary row can’t display text. Valuerows are however not always updated (regardless of virtualization – please leave it on as I don’t want to confuse things, I’m just trying to get it to work) – that’s the problem now.

To duplicate the problem:

Create a grid linked to a dataset with a table having 3 columns (Column1 – string,Column2 – Int32,Column3 – string). Now add a group (On Column1) with a valuerow (footerrow 0) and summaryrow (footerrow 1) as footer rows for the group (Column1) in the designer. Set Column2 in the summaryrow as type int32 and statfunction = SUM. Ensure both summary and valuerows have VisibleWhenCollapsed set to true. Collapse the group and also add the code below.

The problem here is that some of the valuerows (Column2) are NOT DISPLAYED, well sometimes and sometimes not etc. etc. I’m running 3.7.8465.14130 or the grid control.

private void button1_Click(object sender, EventArgs e)

{

dataSet1.Tables[“Table1”].Rows.Clear();

dataSet1.Tables[“Table1”].AcceptChanges();

for (int I=0;I<20;I++)

{

for (int J=0;J<20;J++)

{

System.Data.DataRow ADataRow = dataSet1.Tables[“Table1”].NewRow();

ADataRow[“Column1”] = I.ToString();

ADataRow[

“Column2”] = J+I;

dataSet1.Tables[

“Table1”].Rows.Add(ADataRow);

ADataRow.AcceptChanges();

}

}

}

private

void Form1_Load(object sender, EventArgs e)

{

dataRowTemplate1.Cells[

“Column2”].ValueChanged += new EventHandler(Form1_ValueChanged);

}

void Form1_ValueChanged( object sender, EventArgs e )

{

Xceed.Grid.

DataCell cell = sender as Xceed.Grid.DataCell;

ACellGroup = cell.ParentRow.ParentGroup

as Xceed.Grid.Group;

Application.Idle += new EventHandler(Application_Idle);

}

void Application_Idle( object sender, EventArgs e )

{

Application.Idle -= new EventHandler( Application_Idle );

if (ACellGroup != null)

{

if (ACellGroup.FooterRows.Count == 2)

{

ValueRow valueRow = ACellGroup.FooterRows[0] as ValueRow;

SummaryRow sumRow = ACellGroup.FooterRows[1] as SummaryRow;

if(sumRow != null && valueRow != null)

{

try

{

valueRow.Cells[

“Column2” ].Value = sumRow.Cells[“Column2”].Value;

}

catch

{

}

}

}

}

}

 

 

Imported from legacy forums. Posted by Comodo (had 980 views)