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.
Unfortunately, activation email could not send to your email. Please try again.

Different currency symbol per row

Thread ID:

Created:

Updated:

Platform:

Replies:

78259 Dec 5,2008 08:50 AM Jan 12,2009 02:18 AM Windows Forms 6
loading
Tags: Grouping
Kenleith Primaylon
Asked On December 5, 2008 08:50 AM

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


Nisha Arockiya A [Syncfusion]
Replied On December 8, 2008 02:37 AM

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


Kenleith Primaylon
Replied On December 8, 2008 04:32 AM

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




Nisha Arockiya A [Syncfusion]
Replied On December 9, 2008 07:09 AM

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


Kenleith Primaylon
Replied On January 11, 2009 07:23 AM

it worked! thank you so much!


Kenleith Primaylon
Replied On January 11, 2009 08:09 AM

it worked! thank you so much!


Nisha Arockiya A [Syncfusion]
Replied On January 12, 2009 02:18 AM


Hi KenP,

Thanks for the updates.

Please let us know any other concerns.

Regards,
Nisha.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;