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. WPF
  4. Dock DataGrid's column to the right

Dock DataGrid's column to the right

Scheduled Pinned Locked Moved WPF
question
4 Posts 3 Posters 3 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.
  • M Offline
    M Offline
    Mc_Topaz
    wrote on last edited by
    #1

    I have this DataGrid with three columns:

    I would like 'Col3' to always be at the right side of the DataGris regardless how wide the DataGrid is. Since 'Col1' and 'Col3' has fixed widths, 'Col2' is free to dynamically change width. Is this possible to "Dock" 'Col3' to the right side of the DataGrid? I'm looking for a solution simular to a DockPanel:

    L Richard DeemingR 2 Replies Last reply
    0
    • M Mc_Topaz

      I have this DataGrid with three columns:

      I would like 'Col3' to always be at the right side of the DataGris regardless how wide the DataGrid is. Since 'Col1' and 'Col3' has fixed widths, 'Col2' is free to dynamically change width. Is this possible to "Dock" 'Col3' to the right side of the DataGrid? I'm looking for a solution simular to a DockPanel:

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You mean "visible"? If you define it "on the right", it stays there. If the preceding columns are "too wide", you have to add scroll bars.

      It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

      1 Reply Last reply
      0
      • M Mc_Topaz

        I have this DataGrid with three columns:

        I would like 'Col3' to always be at the right side of the DataGris regardless how wide the DataGrid is. Since 'Col1' and 'Col3' has fixed widths, 'Col2' is free to dynamically change width. Is this possible to "Dock" 'Col3' to the right side of the DataGrid? I'm looking for a solution simular to a DockPanel:

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        You can "freeze" one of more columns, but only on the left-hand side: DataGrid.FrozenColumnCount Property (System.Windows.Controls) | Microsoft Docs[^] You might be able to make it appear on the right-hand side with a custom template, but it would probably require a lot of work. If you just want column 2 to fill the remaining space, set its width to *:

        <DataGridTextColumn Header="Col2" Width="*" />


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        M 1 Reply Last reply
        0
        • Richard DeemingR Richard Deeming

          You can "freeze" one of more columns, but only on the left-hand side: DataGrid.FrozenColumnCount Property (System.Windows.Controls) | Microsoft Docs[^] You might be able to make it appear on the right-hand side with a custom template, but it would probably require a lot of work. If you just want column 2 to fill the remaining space, set its width to *:

          <DataGridTextColumn Header="Col2" Width="*" />


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          M Offline
          M Offline
          Mc_Topaz
          wrote on last edited by
          #4

          Hum... too bad... Thanks for the reply anyway!

          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