Align Long String in DataGridView Cell to Show String End
-
Hi, dear all, I create a project using VB.net in 2005, I need to list a set of file path to a datagridview table. I put horizontal scrollbar as auto, everything is fine. Now client complains that when the file path is too long, they cannot see the file name, they wish if the file path is too long, he want to see the last text (string end) than the first text(begining of the string) of the file path. How can I achieve this? Thanks!
-
Hi, dear all, I create a project using VB.net in 2005, I need to list a set of file path to a datagridview table. I put horizontal scrollbar as auto, everything is fine. Now client complains that when the file path is too long, they cannot see the file name, they wish if the file path is too long, he want to see the last text (string end) than the first text(begining of the string) of the file path. How can I achieve this? Thanks!
Well, the first thing I thought of was custom formatting the string on render and just displaying the filename, maybe with an ellipses (...) before the name, like this: "...\SomeFile.txt". But, then you've got to take into consideration whether the user is going to click on this and be able to select that data to do something with it or edit it in place.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Hi, dear all, I create a project using VB.net in 2005, I need to list a set of file path to a datagridview table. I put horizontal scrollbar as auto, everything is fine. Now client complains that when the file path is too long, they cannot see the file name, they wish if the file path is too long, he want to see the last text (string end) than the first text(begining of the string) of the file path. How can I achieve this? Thanks!
You could use the CellFormatting event to alter the way the cell shows the data, or to alter the data that gets displayed. And you could shorten the file path any way you want, maybe as suggested here[^]. Finally you can still get a ToolTip for the cell in another way if you want, see the CellToolTipTextNeeded event. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
Well, the first thing I thought of was custom formatting the string on render and just displaying the filename, maybe with an ellipses (...) before the name, like this: "...\SomeFile.txt". But, then you've got to take into consideration whether the user is going to click on this and be able to select that data to do something with it or edit it in place.
A guide to posting questions on CodeProject[^]
Dave KreskowiakDave, Thanks for reply, The file path string is just for display purpose.
-
You could use the CellFormatting event to alter the way the cell shows the data, or to alter the data that gets displayed. And you could shorten the file path any way you want, maybe as suggested here[^]. Finally you can still get a ToolTip for the cell in another way if you want, see the CellToolTipTextNeeded event. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
Luc, Thanks for give me the good suggestion.