We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Different currency symbol per row

I was able to show the currency symbol by setting the CurrencyEdit. My problem is how to show a different currency per row. You see I have this datatable that holds the symbol base on column name and primary key of the row. I tried using the QueryCellStyleInfo event, I use e.TableCellIdentity.Column.Name to identify the column which is ok. Problem is the row, I cannot get the correct row index that match on what is in the datatable. I used e.TableCellIdentity.RowIndex, not correct. Another solution (codes below)...it's quite slow and it only works on 1 level tale, it doesn't work on nested table...

Table table = q_dgsView.TableControl.Table;
Element el = table.DisplayElements
[e.TableCellIdentity.RowIndex];
int dataRowPos = 0;

if (el != null)
{
Record rIndex = el.ParentRecord;
dataRowPos = table.UnsortedRecords.IndexOf (rIndex);
}

hope someone can help me...thanks in advance


6 Replies

NA Nisha Arockiya A Syncfusion Team December 8, 2008 07:37 AM UTC

Hi KenP,

Thanks for your interest in syncfusion Products.

To set the individual cell style properties, you need to handle either the QueryCellStyleInfo or the TableControl's PrepareViewStyleInfo.


private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.RowIndex > 0 && e.TableCellIdentity.ColIndex > 0)
{
if(flag)
{
Table table = this.gridGroupingControl1.Table;
Element el = table.DisplayElements[e.TableCellIdentity.RowIndex];
Record r = el.ParentRecord;
int dataRowPos = table.UnsortedRecords.IndexOf(r);

if(dataRowPos == 5)
{
if(e.TableCellIdentity.ColIndex == 4)
{
e.Style.CurrencyEdit.CurrencySymbol = "CHF ";
e.Handled = true;
}
}
}
}
}


Sample:
Here is the sample.

Let us know if this helps.
Regards,
Nisha



KP Kenleith Primaylon December 8, 2008 09:32 AM UTC

hi. thank you for helping. Yes I use QueryCellStyleInfo. But my problem is what row indexer to use in accessing datatable

DataRow dr = DataTable.Rows[e.TableCellIdentity.RowIndex - 1]

this doesn't give the correct row position...

>Hi KenP,

Thanks for your interest in syncfusion Products.

To set the individual cell style properties, you need to handle either the QueryCellStyleInfo or the TableControl's PrepareViewStyleInfo.


private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.RowIndex > 0 && e.TableCellIdentity.ColIndex > 0)
{
if(flag)
{
Table table = this.gridGroupingControl1.Table;
Element el = table.DisplayElements[e.TableCellIdentity.RowIndex];
Record r = el.ParentRecord;
int dataRowPos = table.UnsortedRecords.IndexOf(r);

if(dataRowPos == 5)
{
if(e.TableCellIdentity.ColIndex == 4)
{
e.Style.CurrencyEdit.CurrencySymbol = "CHF ";
e.Handled = true;
}
}
}
}
}


Sample:
Here is the sample.

Let us know if this helps.
Regards,
Nisha





NA Nisha Arockiya A Syncfusion Team December 9, 2008 12:09 PM UTC

Hi KenP,

Thanks for your Updates.

Try working directly with the row instead of its parent.


if(e.TableCellIdentity.ColIndex > 0 && e.TableCellIdentity.RowIndex > 0 &&
e.TableCellIdentity.DisplayElement is GridRecordRow
&& e.TableCellIdentity.Column != null) //make sure a column is being requested
{
GridRecordRow row = e.TableCellIdentity.DisplayElement as GridRecordRow;
if(row != null)
{
DataRowView drv = row.GetData() as DataRowView;
if(drv != null)
{
string name = e.TableCellIdentity.Column.Name;
Console.WriteLine(e.Style.Text + " " + drv[name].ToString());
}
}
}


Please let me know if this helps.

Regards,
Nisha



KP Kenleith Primaylon January 11, 2009 12:23 PM UTC

it worked! thank you so much!



KP Kenleith Primaylon January 11, 2009 01:09 PM UTC

it worked! thank you so much!



NA Nisha Arockiya A Syncfusion Team January 12, 2009 07:18 AM UTC


Hi KenP,

Thanks for the updates.

Please let us know any other concerns.

Regards,
Nisha.


Loader.
Live Chat Icon For mobile
Up arrow icon