How to get nowrap vertical string using system.drawing.stringformat

I am working on graphics, and I need the label for the axis on my chart to be the only vertical line of text when rendering my chart. I don't care if some text is turned off, but I need it to trim gracefully.

I use the WebChart library provided by Carlos Ag and pass the System.Drawing.StringFormat object to the chart.

objChartText = New WebChart.ChartText objChartText.Font = New Font("Verdana", 8, FontStyle.Regular, GraphicsUnit.Point) Dim objStringFormat As StringFormat = New StringFormat(StringFormatFlags.DirectionVertical) objStringFormat.LineAlignment = StringAlignment.Center objStringFormat.Alignment = StringAlignment.Center objStringFormat.Trimming = StringTrimming.Word objChartText.StringFormat = objStringFormat 

"StringformatFlags.DirectionVerticle" is an enumeration that defines a position. I am wondering if there is another known non-enum value that I can pass, which will give me the desired result. None of the defined enums gives me what I want. I tried just adding enums, I want 2 (DirectionVertical) and 4096 (nowrap), but this leaves separate characters with a wide spacing below the graph.

Any suggestions?

+4
source share
1 answer

The problem here is cropping and alignment, not enumeration.

An enumeration can be added to combine effects. In this case, the correct value is 4098, so the instance should read

 Dim objStringFormat As StringFormat = New StringFormat(4098) 

and cropping or alignment must be changed. My solution was to change the cropping to

  objStringFormat.Trimming = StringTrimming.Character 

This solved my problem and allowed me to create a beautiful graph.

+3
source

Source: https://habr.com/ru/post/1445137/


All Articles