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. WCF and WF
  4. How to get the Actual Width of a Grid Column whose width is Auto.

How to get the Actual Width of a Grid Column whose width is Auto.

Scheduled Pinned Locked Moved WCF and WF
csstutorial
4 Posts 3 Posters 1 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.
  • N Offline
    N Offline
    Nitheesh George
    wrote on last edited by
    #1

    Hi, I want to get the actual width of a grid column whose width is set to Auto at run time. I need to dynamically add a control to the grid and want to set its marign depends on some value. So i want to get the Actual column width dynamically. thanks, Nitheesh

    Jose Jo Martin http://www.simpletools.co.in

    C S 2 Replies Last reply
    0
    • N Nitheesh George

      Hi, I want to get the actual width of a grid column whose width is set to Auto at run time. I need to dynamically add a control to the grid and want to set its marign depends on some value. So i want to get the Actual column width dynamically. thanks, Nitheesh

      Jose Jo Martin http://www.simpletools.co.in

      C Offline
      C Offline
      ColinM123
      wrote on last edited by
      #2

      How about the ActualWidth property? :-D

      Online Guitar Tools

      N 1 Reply Last reply
      0
      • C ColinM123

        How about the ActualWidth property? :-D

        Online Guitar Tools

        N Offline
        N Offline
        Nitheesh George
        wrote on last edited by
        #3

        Hi, thank you for the reply. But when the minWidth is set then only the ActualWidth gives the value and if the Width property is set then the ActualWidth is 0 and Width.Value returns the correct width. But when the Column width='Auto' both properties returns 0. Any idea. thanks Nitheesh

        Jose Jo Martin http://www.simpletools.co.in

        1 Reply Last reply
        0
        • N Nitheesh George

          Hi, I want to get the actual width of a grid column whose width is set to Auto at run time. I need to dynamically add a control to the grid and want to set its marign depends on some value. So i want to get the Actual column width dynamically. thanks, Nitheesh

          Jose Jo Martin http://www.simpletools.co.in

          S Offline
          S Offline
          schiebel t
          wrote on last edited by
          #4

          Hi, try to add an SizeChanged event to you grid. The SizeChangedEventArgs have a property NewSize. And with this you can easy calculate the grid column width GridColumnWidth = (windowWidth / 100) * GridColumnProcent

          public partial class Window1 : Window
          {
          double windowWidth;

              public Window1()
              {
                  InitializeComponent();
                  this.SizeChanged += new SizeChangedEventHandler(Window1\_SizeChanged);
              }
          
              void Window1\_SizeChanged(object sender, SizeChangedEventArgs e)
              {
                  windowWidth = e.NewSize.Width;
              }
          }
          
          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