Search code examples
devexpresstextedit

Right justify text in Devexpress TextEdit and show text from the end


I would like to right justify text and show text from the end. For example: say textEdit1 has filepath as its content "C:\Users\xxx.xxx\Documents\xxx\CODE\test\inner test\another\another\filename.sdfx"

If the entire text is not visible in the text edit then show text from the end so that filename is always visible.

I know how to right justify text but not sure about the second part. Any help highly appreciated.enter image description here

In the above image the filepath is too long to be shown fully so I would like to show the path from the end so that filename is always visible. Hope I made myself clear.

I am using Devexpress 11.2 for Windows.


Solution

  • I found the solution which is to do with SelectionStart as stated above but it has to be done after the TextEdit is completely loaded.

    protected override void OnShown(EventArgs e)
    {
        base.OnShown(e);
    
        textEdit1.Text = @"C:\Users\xxx.xxx\Documents\xxx\CODE\test\inner test\another\another\filename.xxx";
        textEdit1.SelectionStart = textEdit1.Text.Length;
    }
    

    All thanks to Devexpress.