2

I'm creating a map layout with a measured grid using visual studio and ArcGIS Engine 10.4. I was able to change all the properties for the grid label (color, font and font size), except for the part after the decimal point. In other words, the changes I apply on the label using the code below are only applied on the part before the decimal point.

enter image description here

What I want to do is to hide the decimal part of the label. Anyone know how to access the decimal part and hide it or set the number of digits after the decimal to zero as in ArcMap for desktop?

 IGridLabel gridLabel = pMapGrid.LabelFormat;
 gridLabel.LabelOffset = 6;
 gridLabel.Color = color;

 gridLabel.LabelAlignment[esriGridAxisEnum.esriGridAxisRight] = false;
 gridLabel.LabelAlignment[esriGridAxisEnum.esriGridAxisLeft] = false;
  • 1
    Color it with white color ;-) – nagib Apr 22 '18 at 18:24
  • @nagib I'm unable to color it because any property I change is only applied on the part before the decimal – Awwad Apr 22 '18 at 19:32
1

Can you give this a try:

INumericFormat pNumForm = new NumericFormatClass();
pNumForm.RoundingValue = 0;
pNumForm.RoundingOption = esriRoundingOptionEnum.esriRoundNumberOfDecimals;

IGridLabel gridLabel = pMapGrid.LabelFormat;
IFormattedGridLabel pFormGridLabel = (IFormattedGridLabel)gridLabel; 
pFormGridLabel.Format = (INumberFormat)pNumForm;

A NumericFormat interface specifies the number of decimals (or significant digits by enum), to get this property on to your IGridLabel you should be able to interface by IFormattedGridLabel.Format which is of type INumberFormat which is implemented by INumericFormat (hopefully, I haven't tested this).

I would have posted this as a comment because I'm not 100% sure of the inheritance having not tested it but there's too many words.. hopefully it works or gets you closer to a working result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.