Profile Picture

NLabel.TextStyle.HorizontalAlign is in the online docs, but not recognized in VB.

Posted By Lee Harris 12 Years Ago

NLabel.TextStyle.HorizontalAlign is in the online docs, but not...

Author
Message
Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Lee,

You use docking which implies that the content alignment is not actually applied. In this case you only need to use FitAlignment - check out the following code snippet:

 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  Dim label As NLabel = Nothing
  Dim right As Boolean

  right = False

  label = NChartControl1.Labels.AddHeader("blah blah blah")


  If right Then
   label.Margins = New NMarginsL(0, 0, 10, 0)
   label.FitAlignment = ContentAlignment.TopRight
   label.Dock = DockStyle.Top
  Else
   label.Margins = New NMarginsL(10, 0, 0, 0)
   label.FitAlignment = ContentAlignment.TopLeft
   label.Dock = DockStyle.Top
  End If
 End Sub

which produces correct results.



Best Regards,
Nevron Support Team



Lee Harris
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 10 Years Ago
Posts: 7, Visits: 12
That looks easy, but it doesn't seem to work. Here's the block of code in question... and I've attached a screenshot of the result... thanks in advance... Lee

Dim sLegend As NLabel = Nothing
If mSLegendLayout <> eLegendLayout.None AndAlso Not (TypeOf chart Is NPieChart) Then
sLegend = chartCtrl.Labels.AddHeader("blah blah blah")
sLegend.ContentAlignment = ContentAlignment.MiddleLeft
'sLegend.TextStyle.horizontalalign = VisualStyles.HorizontalAlign.Left
If mSLegendLayout = eLegendLayout.Right Then
sLegend.Margins = New NMarginsL(10, 0, 0, 0)
sLegend.FitAlignment = ContentAlignment.TopLeft
sLegend.Dock = DockStyle.Right
Else
sLegend.Margins = New NMarginsL(0, 10, 0, 10)
sLegend.FitAlignment = ContentAlignment.BottomCenter
sLegend.Dock = DockStyle.Bottom
sLegend.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Left
sLegend.BoundsMode = BoundsMode.None
End If

End If


Attachments
Chart.png (83 views, 18.00 KB)
Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Lee,

You need set the TextStyle.StringFormatStyle.HorzAlign property:

   NLabel label = new NLabel("Multiline \r\nlabel");
   label.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Left;
   label.BoundsMode = BoundsMode.None;
   nChartControl1.Document.RootPanel.ChildPanels.Add(label);



Best Regards,
Nevron Support Team



Lee Harris
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 10 Years Ago
Posts: 7, Visits: 12
... and I can't find any other way to make the multiple lines of text in my NLabel be left justified, instead of centered. What am I missing here?

Thanks!



Similar Topics


Reading This Topic