on 08-20-2015 3:29 PM
Hi, everybody
I am developing an SDK add-on using VB.NET.
I don't use Screen Painter or any other visual tools. All dimensions are specified by coding.
For ex. This is how I code a Static Text
oItem = Form1.Items.Add("Static3", SAPbouiCOM.BoFormItemTypes.it_STATIC)
oItem.FontSize = 16
oItem.Left = 150
oItem.Top = 190
oItem.Width = 200
Static1 = oItem.Specific
Static1.Caption = "Transfer of Goods From"
Is there a way to center the Caption within the item width of 200 specified?
By default, the caption is left justified.
I think there is no direct way to achieve this.
But is there a workaround?
Any ideas are most welcome.
Thanks
Leon
Hi Leon,
For center the Caption in the Static Text, I believe that not exists a direct way to achieve this.
But the item has a member called RightJustified, maybe this can help you in a workaround.
Regards,
Diego
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Leon,
I would go use something like this:
SAPbouiCOM.Item oItem = null;
SAPbouiCOM.StaticText oStatic = null;
oItem = oForm.Items.Add("stExample", SAPbouiCOM.BoFormItemTypes.it_STATIC);
oItem.Top = oForm.Items.Item("2").Top; //I set the top of my static text as the top of cancel button
oItem.Height = oForm.Items.Item("2").Height; //I set the height of my static text, equals the height of cancel button
oItem.Left = oForm.Items.Item("2").Left + oForm.Items.Item("2").Width + 5; //I set the position of my static text beside the cancel button
oItem.Width = 260;
oItem.RightJustified = true;
The result:
The black area is my space in the form, and the red area is my static text area, that I define with width 260, and set the RightJustified for true..
To achieve something "similar" to centering, all that you have to do is to make sure that the font size of your text and the width of your StaticText field correlate with each other in such a way that the text goes all the way to the end of the StaticText field - no longer, and no shorter. Then you simply place the StaticText field EXACTLY where you want it to go. Then "centering" will not be necessary.
It will take some trial and error to get exactly the right numbers you need for the right effect, but you can do it. It's just not nicely automatic, it will be a manual process.
To explain another way, make sure that your Label field is exactly as wide as the text that you wish to display without any extra whitespace, then put the text exactly where you want it to appear. It's as simple as that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
10 | |
6 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.