nonsense scrollbars in grid

Nov 4, 2009 at 3:36 PM
Edited Nov 4, 2009 at 3:39 PM

i'm creating grid control with header and two lines, it's a bit higher than necessary for this contents

than inserting columns (their widths sum fits to column width (minus borders, in fact making it even a bit less wide does not help))

and rows (as we know there is enough height for them)

bug -> finally grid appears with two scrollbars even final contents size does not require it (manually making one column smaller and return to original width removes them)

my theory:

it seems during control initialization sometimes appears vertical scrollbar (temporary height of contents is too big? see next 1.)
because of this appears also horizontal scrollbar
so finaly there are two scrollbars even final layout of header and cells does not require it

bug does not appear when i make 1. grid even higher or 2. (temporary) set

grid->HorizontalScrollBarVisibility = System::Windows::Controls::ScrollBarVisibility::Hidden;

or 3. making columns widths smaller than "fit to contents minus horizontal scroll width" (but i need fill full width by columns)

Nov 9, 2009 at 9:16 AM

also calling InvalidateMeasure(); does not hide them

any other trick?

Nov 23, 2009 at 2:20 AM
real_name wrote:

also calling InvalidateMeasure(); does not hide them

any other trick?

 Sounds weird... try making one of the colums Width="*"

R

Nov 27, 2009 at 3:20 PM
Edited Nov 27, 2009 at 3:21 PM

my try (see down source) crashes on

column->Width = System::Double::NaN;

with throw new ArgumentException somewhere else:

WPFToolkit.dll!Microsoft.Windows.Controls.DataGridLength.DataGridLength(double value = NaN, Microsoft.Windows.Controls.DataGridLengthUnitType type = Pixel, double desiredValue = NaN, double displayValue = NaN) Line 87    C#
     WPFToolkit.dll!Microsoft.Windows.Controls.DataGridLength.DataGridLength(double value = NaN, Microsoft.Windows.Controls.DataGridLengthUnitType type = Pixel) Line 59    C#
     WPFToolkit.dll!Microsoft.Windows.Controls.DataGridLength.DataGridLength(double pixels = NaN) Line 39    C#
     WPFToolkit.dll!Microsoft.Windows.Controls.DataGridLength.implicit operator Microsoft.Windows.Controls.DataGridLength(double value = NaN) Line 336 + 0x2c bytes    C#
>    NemAll_DialogFramework.dll!AllWpfControls::AllGridControl::OnContextMenuOpening(System::Windows::Controls::ContextMenuEventArgs^ e = 0x16968a04) Line 2622 + 0x17 bytes    C++

 

void AllWpfControls::AllGridControl::OnContextMenuOpening(ContextMenuEventArgs^ e)
{
    __super::OnContextMenuOpening(e);

    int NoOfColumns = Columns->Count;
    if(NoOfColumns)
    {
        Microsoft::Windows::Controls::DataGridColumn^ column = Columns[0];
        double itemWidth = column->ActualWidth;
        column->Width = System::Double::NaN;
        InvalidateMeasure();
        column->Width = itemWidth;
    }
}

Nov 27, 2009 at 3:31 PM

the same crash when i do it sooner = in Loaded handler =  just before Add:

static int i = 0;
column->Width = i ? 100 : System::Double::NaN;
i++;
this->Columns->Add(column);

WPFToolkit.dll!Microsoft.Windows.Controls.DataGridLength.DataGridLength(double value = NaN, Microsoft.Windows.Controls.DataGridLengthUnitType type = Pixel, double desiredValue = NaN, double displayValue = NaN) Line 87    C#
     WPFToolkit.dll!Microsoft.Windows.Controls.DataGridLength.DataGridLength(double value = NaN, Microsoft.Windows.Controls.DataGridLengthUnitType type = Pixel) Line 59    C#
     WPFToolkit.dll!Microsoft.Windows.Controls.DataGridLength.DataGridLength(double pixels = NaN) Line 39    C#
     WPFToolkit.dll!Microsoft.Windows.Controls.DataGridLength.implicit operator Microsoft.Windows.Controls.DataGridLength(double value = NaN) Line 336 + 0x2c bytes    C#
>    NemAll_DialogFramework.dll!AllWpfControls::AllGridControl::CreateColumns() Line 1712 + 0x33 bytes    C++

i just thought in previous case was any grid length crashing - now can see it's column's problem