How do I add text to a Group and have that text be centered?
Where can I find this answer in the online help?
Take a gander at the Alignment property of an IText element; this property allows you to specify a horizontal and vertical alignment for the text. The following code worked for me as a quick test:
Report r = new Report();IText text = r.AddSection().AddGroup().AddText();text.Alignment.Horizontal = Alignment.Center;text.AddContent("Centered text");
-Matt
Okay, that looks like that will work, but how do I pass an Alignment enumeration into a method and use it inside that method?
public void SomeMethod(Alignment txtAlign)
{
IText text ... blah blah ...
text.Alignment.Horizontal = txtAlign. << the enumerated list does not show up>>
}
No enumerated list is going to show up because your method takes an instance of the Alignment enumeration as it is, so you'd just have:
text.Alignment.Horizontal = txtAlign;
The Alignment enum does contain both vertical and horizontal alignments, so you may want to validate the entries before setting the property if you're not sure what will be passed into the method.
Alternatively, you could have meant to pass in a TextAlignment instance into the method, in which case you could do:
text.Alignment = txtAlign;
Thank you for your time and effort on this.
It's working now.