Directly to the left hint text of C #

Using WinForms, I have a line that I want to set in ToolTip. The line is separated by lines using Environment.NewLine, for example:

x.ToolTipText = "aaaaaa" + Environment.NewLine + "bbb";

when this line is set to a tooltip, it looks:

aaaaaa
bbb

But my problem is when I want it to be localized in Arabic, and ToolTip does not support the RightToLeft property by default, so it looks really bad. I want it to look like this:

aaaaaa
   bbb

Also: String.PadLeftdoes not help!

Any idea?

+3
source share
4 answers

. . , , .

:

string tip = "aaaaaa" + Environment.NewLine + "bbb";           
toolTip1.OwnerDraw = true;
toolTip1.Draw += toolTip1_Draw;
toolTip1.SetToolTip(textBox1, tip);

:

private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
{
    e.Graphics.FillRectangle(SystemBrushes.Info, e.Bounds);
    e.DrawBorder();           
    e.DrawText(TextFormatFlags.RightToLeft | TextFormatFlags.Right);
}
+8

ToolTip . , , , . :

using System;
using System.Windows.Forms;

namespace WindowsFormsApplication1 {
    public partial class Form1 : Form {
        ToolTip mTip = new ToolTip();
        public Form1() {
            InitializeComponent();
            this.RightToLeft = RightToLeft.Yes;
            this.RightToLeftLayout = true;
        }
        protected override void OnMouseDown(MouseEventArgs e) {
            mTip.Show("Hi\nthere", this);
        }
    }
}
+4

, , , RTL.

string myToolTipText = "aaaaaa"+Environment.newLine+"bbb";
char rle_char = (char)0x202B;// RLE embedding 
control.RightToLeft = RightToLeft.Yes;
control.ToolTipText = rle_char + myToolTipText;

RTL- . .

-, w3c RTL-. , Windows, RLE.

+2

, , : tooltip , . - , RTL vs LTR (, ).

: Unicode RTL, , : none .

- (ab) TextBox . , , , .

0

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


All Articles