Format of a ComboBox
Hello,
I have a combobox which contains several decimal values.
I would like to know how can I configure my combobox in order to view my values as currency for example.
Thanks a lot.
Mike
I have a combobox which contains several decimal values.
I would like to know how can I configure my combobox in order to view my values as currency for example.
Thanks a lot.
Mike
SIGN IN To post a reply.
5 Replies
AD
Administrator
Syncfusion Team
July 12, 2007 08:52 AM UTC
Hi Mike,
You can format the combobox value using "String.Format" method. Please refer this code snippets:
You can format the combobox value using "String.Format" method. Please refer this code snippets:
private void Form1_Load(object sender, EventArgs e)
{
this.comboBoxAdv1.Items.Add(String.Format("{0}134.5","$"));
this.comboBoxAdv1.Items.Add(String.Format("{0}5434.545", "$"));
this.comboBoxAdv1.Items.Add(String.Format("{0}0.5346", "$"));
}
Please refer the small sample in the below link which illustrates the above:
http://websamples.syncfusion.com/samples/Tools.Windows/F63880/main.htm
Kindly let us know if you need any further assistance.
Best Regards,
Jeba.
MP
Mikael Plouhinec
July 13, 2007 09:12 AM UTC
Ok.
But I don't use the method Add of Items. I use this :
this.comboBoxTauxTvaInitial.DataSource = Satori.Tarifs.TauxTVA.GetAllTaux();
this.comboBoxTauxTvaInitial.DisplayMember = "Taux";
this.comboBoxTauxTvaInitial.ValueMember = "OID";
Is there a way to format the displayMember as Currency for example?
Thanks a lot.
Mike
>Hi Mike,
You can format the combobox value using "String.Format" method. Please refer this code snippets:
But I don't use the method Add of Items. I use this :
this.comboBoxTauxTvaInitial.DataSource = Satori.Tarifs.TauxTVA.GetAllTaux();
this.comboBoxTauxTvaInitial.DisplayMember = "Taux";
this.comboBoxTauxTvaInitial.ValueMember = "OID";
Is there a way to format the displayMember as Currency for example?
Thanks a lot.
Mike
>Hi Mike,
You can format the combobox value using "String.Format" method. Please refer this code snippets:
private void Form1_Load(object sender, EventArgs e)
{
this.comboBoxAdv1.Items.Add(String.Format("{0}134.5","$"));
this.comboBoxAdv1.Items.Add(String.Format("{0}5434.545", "$"));
this.comboBoxAdv1.Items.Add(String.Format("{0}0.5346", "$"));
}
Please refer the small sample in the below link which illustrates the above:
http://websamples.syncfusion.com/samples/Tools.Windows/F63880/main.htm
Kindly let us know if you need any further assistance.
Best Regards,
Jeba.
JS
Jeba S
Syncfusion Team
July 16, 2007 12:20 PM UTC
Hi Mike,
You can achieve this using ComboBoxDropDown and GridListControl.
Please refer the modified sample in the below link which illustrates the above:
http://websamples.syncfusion.com/samples/Tools.Windows/F63880Two/main.htm
Kindly let us know if this helps.
Best Regards,
Jeba.
You can achieve this using ComboBoxDropDown and GridListControl.
void Grid_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex > 0)
{
e.Style.CellType = "Currency"; ;
e.Style.CellValueType = typeof(double);
}
if (flag == 1)
{
this.comboDropDown1.TextBox.Text = e.Style.FormattedText;
}
}
Please refer the modified sample in the below link which illustrates the above:
http://websamples.syncfusion.com/samples/Tools.Windows/F63880Two/main.htm
Kindly let us know if this helps.
Best Regards,
Jeba.
MP
Mikael Plouhinec
July 16, 2007 12:48 PM UTC
I don't have any grid.
I just want to know how can I format the display members of my items of my combobox without change the query which give me my DataSource.
Thanks a lot.
Mike
>Hi Mike,
You can achieve this using ComboBoxDropDown and GridListControl.
Please refer the modified sample in the below link which illustrates the above:
http://websamples.syncfusion.com/samples/Tools.Windows/F63880Two/main.htm
Kindly let us know if this helps.
Best Regards,
Jeba.
I just want to know how can I format the display members of my items of my combobox without change the query which give me my DataSource.
Thanks a lot.
Mike
>Hi Mike,
You can achieve this using ComboBoxDropDown and GridListControl.
void Grid_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex > 0)
{
e.Style.CellType = "Currency"; ;
e.Style.CellValueType = typeof(double);
}
if (flag == 1)
{
this.comboDropDown1.TextBox.Text = e.Style.FormattedText;
}
}
Please refer the modified sample in the below link which illustrates the above:
http://websamples.syncfusion.com/samples/Tools.Windows/F63880Two/main.htm
Kindly let us know if this helps.
Best Regards,
Jeba.
JS
Jeba S
Syncfusion Team
July 17, 2007 08:47 AM UTC
Hi Mike,
There is no direct way to format the display members of the items in the combobox.
Best Regards,
Jeba.
There is no direct way to format the display members of the items in the combobox.
Best Regards,
Jeba.
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
-
MP Mikael Plouhinec
- Jul 11, 2007 08:10 AM UTC
- Jul 17, 2007 08:47 AM UTC