DataGrid Column header height
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: DataGrid Column header height

  1. #1
    Join Date
    Mar 2004
    Posts
    45

    DataGrid Column header height

    I just want to know if it's possible to change the height of the column header in a DataGrid. I have found options for bouth height and width og the row header, but only width option for the column header.

    Is it changable, and in that case; how do I change it?

    (I need to write two lines of text in the header, and if I can't change the header height, the bottom line will not be shown)

    Thanks for all answers! I am really stuck here...

  2. #2
    Join Date
    Mar 2004
    Posts
    45
    plz! I am really stuck here. If anyone have any idea, that might solve my problem, or you have seen this problem before, plz tell me!

  3. #3
    Join Date
    Jan 2013
    Posts
    2

    Re: DataGrid Column header height

    So I've been unable to find anything on this for two days now and finally decided just go ahead and manually come up with a solution. First I added a thumb to the bottom of the header then I added a couple of event handlers to give the expected functionality:

    private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
    {
    double change = e.VerticalChange;
    RulesGrid.ColumnHeaderHeight = Math.Max(20, RulesGrid.ColumnHeaderHeight + change);
    }

    private void Thumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
    RulesGrid.ColumnHeaderHeight = double.NaN;
    }

    I hope that helps. I really can't understand why this has to be added in the first place...

  4. #4
    Join Date
    Jan 2013
    Posts
    2

    Re: DataGrid Column header height

    This is a more complete answer.

    private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
    {
    double change = e.VerticalChange;
    RulesGrid.ColumnHeaderHeight = double.IsNaN(RulesGrid.ColumnHeaderHeight) ? mousePosition.Y : // mouse position gotten from
    Math.Max(20, RulesGrid.ColumnHeaderHeight + change);
    }

    private void Thumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
    RulesGrid.ColumnHeaderHeight = double.NaN;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center