Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Align Long String in DataGridView Cell to Show String End

Align Long String in DataGridView Cell to Show String End

Scheduled Pinned Locked Moved Visual Basic
questioncsharp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andraw Tang
    wrote on last edited by
    #1

    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!

    D L 2 Replies Last reply
    0
    • A Andraw Tang

      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!

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      A 1 Reply Last reply
      0
      • A Andraw Tang

        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!

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        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.

        A 1 Reply Last reply
        0
        • D Dave Kreskowiak

          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

          A Offline
          A Offline
          Andraw Tang
          wrote on last edited by
          #4

          Dave, Thanks for reply, The file path string is just for display purpose.

          1 Reply Last reply
          0
          • L Luc Pattyn

            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.

            A Offline
            A Offline
            Andraw Tang
            wrote on last edited by
            #5

            Luc, Thanks for give me the good suggestion.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups