Domanda

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.

È stato utile?

Soluzione 2

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.

Altri suggerimenti

I think the caret position in the editor can be set using the SelectionStart and SelectionLength properties. After that, all you have to do is to implement both GotFocus and LostFocus events so that even when there is no focus, the end of the text is shown.

More details here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top