This project has moved and is read-only. For the latest updates, please go here.

Thousands Comma separator in Label

Topics: SharpMap Project, SharpMap v0.9 / v1.x, SharpMap v2.0, WinForms Controls
Sep 17, 2013 at 11:59 AM

I am displaying values in polygon as labels, i need to have Thousands separator by comma for the labels.I am reading the values from Sql server database using the following line of code.
LayLabel.LabelColumn ="Value";               
LayLabel.Style = new LabelStyle();
LayLabel.Style.ForeColor = Color.Black;
I need the labels to be displayed as 124,000.00 instead of 124000.00 and for the legends i used string format to get the comma separator. Is it possible to get the expected result for labels.

Note: Its an urgent task please respond asap if anybody has the solution.

Arun Mohan
Sep 17, 2013 at 2:23 PM
Edited Sep 18, 2013 at 8:28 AM
sth like:
LayLabel.LabelStringDelegate = fdr => string.Format(NumberFormatInfo.InvariantInfo, "{0:N2}", fdr["Value"]);
Sep 18, 2013 at 7:24 AM
Hi FObermaier,

I am getting the following error

Error 3 'SharpMap.Styles.LabelStyle' does not contain a definition for 'LabelDelegate' and no extension method 'LabelDelegate' accepting a first argument of type 'SharpMap.Styles.LabelStyle' could be found (are you missing a using directive or an assembly reference?)

Please help me in this.

Arun Mohan
Sep 18, 2013 at 8:30 AM
  • the delegate does not belong to the LabelStyle, it is a member of the LabelLayer
  • it is named LabelStringDelegate and has the LabelLayer.GetLabelMethod signature.
Sep 18, 2013 at 10:20 AM
Hi FObermaier,

Thanks a lot , it worked

Arun Mohan