Need better idea to display too-long path in textBox?

  • Thread starter Thread starter Ed Sutton
  • Start date Start date
E

Ed Sutton

I am GUI neanderthal looking for better ideas for displaying a too-long
path in a texBox.

Currently I am thinking it is better to right-justify, or somehow
scroll-right to display the file name to the user when the path is
longer than the textBox width. I can not figure out how to do this.

Setting the textBox TextAllign property to right behaves as expected
until the path is longer than the textBox at which point it reverts to
left-allign behavior.

Any other UI approaches or ideas to this problem is greatly appreciated.
Thanks in advance,

-Ed
 
Whenever you add text to the TextBox just set the SelectionStart property:

this.textBox1.Text = @"C:\Program
Files\MyApplication\AnotherFolder\MyDocument.txt";
this.textBox1.SelectionStart = this.textBox1.Text.Length;
this.textBox1.Focus();
 
* Ed Sutton said:
I am GUI neanderthal looking for better ideas for displaying a
too-long path in a texBox.

Currently I am thinking it is better to right-justify, or somehow
scroll-right to display the file name to the user when the path is
longer than the textBox width. I can not figure out how to do this.

I would left-align the text, then set the selection position after the
last character by using the overloarded 'Select' method and then call
the textbox's 'ScrollToCaret' method.
 
I kind of like the way that, for example, Word handles it when you go to
Tools, Options and the File Location tab. The dots are a useful cue that
the full path isn't being displayed (though I don't have a clue how to
actually achieve that). As to what you should _always_ have visible then
I'd agree that the last part of the path/file is the most important.
 
If it is going out of the textbox but you want it displayed, show the
initial folders and the last ones with "..." in between. for example a path
like,
C:\Documents and Settings\All Users\Start Menu\Programs\Oracle -
OraHome92\Enterprise Management Packs\Change\

could be represented as

C:\Documents and Settings\All Users\Start Menu\Programs\...\Change\

Where to break the path depend on your application

--Saurabh
 
Rob,

Thanks for the idea.

I took a look at my MSWord File Locations and copied the displayed paths
below. In these examples, Word is displaying file folder locations, not
files.

"C:\...\esutton\My Documents"
"C:\Program Files\Microsoft Office\O..."

I like the first example. I did not like the second example which
displayed the "..." at the end, I am not sure why.

I supposeI could make the rule:
<driveLetter>...<rightPartOfPath>

Thanks again,

-Ed
 
Herfried,
I would left-align the text, then set the selection position after the
last character by using the overloarded 'Select' method and then call
the textbox's 'ScrollToCaret' method.

Thanks! Originally that was the approach I was taking, but I could not
figure out how 'ScrollToCaret' was supposed to work.

-Ed
 
* Ed Sutton said:
Thanks! Originally that was the approach I was taking, but I could not
figure out how 'ScrollToCaret' was supposed to work.

If you are using a RichTextBox, the control /must/ have the focus in
order to be scrolled.
 
Back
Top