This is a migrated thread and some comments may be shown as answers.

[Solved] GridViewDataColumn IsVisible="False"... Error

3 Answers 111 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paloma
Top achievements
Rank 1
Paloma asked on 27 Apr 2009, 06:59 AM
Hi everybody!
I'm trying to set the isVisible="False" property in a GridViewDataColumn. But when I execute the application I get the next error:
"Object reference not set to an instance of an object."
Does anybody know why does this happen?
Thanks

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 27 Apr 2009, 12:18 PM
Hello Paloma,

Can you elaborate more about this issue. When is this happening? I've tried to set it in XAML and it is working as expected (no exceptions). Can you share the code snippet that you use to get the column?

Thanks.

Best wishes,
Hristo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Paloma
Top achievements
Rank 1
answered on 28 Apr 2009, 06:49 AM
Yeah!
That's for sure, I paste you my code. I get the error when loading the page that contains the view:

 

<gridView:RadGridView x:Name="dgArrendamiento" ColumnsWidthMode="Fill" AutoGenerateColumns="False" Width="Auto" Height="700"

 

 

CanUserReorderColumns="False" MaxHeight="160" ShowGroupPanel="False">

 

 

<gridView:RadGridView.Columns>

 

 

<gridView:GridViewColumn Width="27" IsSortable="False" >

 

 

<gridView:GridViewColumn.CellStyle>

 

 

<Style TargetType="grid:GridViewCell">

 

 

<Setter Property="Template">

 

 

<Setter.Value>

 

 

<ControlTemplate TargetType="grid:GridViewCell">

 

 

<Border BorderThickness="0,0,0,1" BorderBrush="#FFB3B3B3">

 

 

<Grid>

 

 

<Border Margin="4" CornerRadius="3" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="16" Height="16">

 

 

<Image Source="../../Resources/edit.png" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Top" Height="16" Width="16" ToolTipService.ToolTip="Modificar Referencia" MouseLeftButtonUp="btnEditar_Click" Cursor="Hand"/>

 

 

</Border>

 

 

<Rectangle Width="{TemplateBinding VerticalLineThickness}" Fill="{TemplateBinding VerticalLineFill}" HorizontalAlignment="Right"

 

 

Visibility="{TemplateBinding VerticalLineVisibility}" />

 

 

</Grid>

 

 

</Border>

 

 

</ControlTemplate>

 

 

</Setter.Value>

 

 

</Setter>

 

 

</Style>

 

 

</gridView:GridViewColumn.CellStyle>

 

 

</gridView:GridViewColumn>

 

 

<gridView:GridViewColumn Width="27" IsSortable="False" >

 

 

<gridView:GridViewColumn.CellStyle>

 

 

<Style TargetType="grid:GridViewCell">

 

 

<Setter Property="Template">

 

 

<Setter.Value>

 

 

<ControlTemplate TargetType="grid:GridViewCell">

 

 

<Border BorderThickness="0,0,0,1" BorderBrush="#FFB3B3B3">

 

 

<Grid>

 

 

<Border Margin="4" CornerRadius="3" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="16" Height="16">

 

 

<Image Source="{Binding Ruta}" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Top" Height="16" Width="16" MouseLeftButtonUp="btn_DeleteRefCat"/>

 

 

</Border>

 

 

<Rectangle Width="{TemplateBinding VerticalLineThickness}" Fill="{TemplateBinding VerticalLineFill}" HorizontalAlignment="Right"

 

 

Visibility="{TemplateBinding VerticalLineVisibility}" />

 

 

</Grid>

 

 

</Border>

 

 

</ControlTemplate>

 

 

</Setter.Value>

 

 

</Setter>

 

 

</Style>

 

 

</gridView:GridViewColumn.CellStyle>

 

 

</gridView:GridViewColumn>

 

 

<gridView:GridViewDataColumn IsSortable="False" IsReadOnly="True" HeaderText="Id" DataMemberPath="Id" Width="Auto" TextAlignment="Right"/>

 

 

<gridView:GridViewDataColumn IsSortable="False" IsReadOnly="True" HeaderText="Referencia Catastral" DataMemberPath="Descripcion" Width="Auto"/>

 

 

<gridView:GridViewDataColumn IsSortable="False" IsReadOnly="True" HeaderText="Estado" DataMemberPath="Estado" IsVisible="False"/>

 

 

</gridView:RadGridView.Columns>

 

 

</gridView:RadGridView>

 

0
Pavel Pavlov
Telerik team
answered on 01 May 2009, 12:27 PM
Hi Paloma,

I have finally reproduced the problem. Thanks for the XAML provided! It helped  a lot. It seems  that the combination causing the problem is :
setting the ColumnsWithMode to Fill  and the first two columns width to 'Auto.  We are preparing a fix for this. Meanwhile here is the solution you may apply:

Remove the :

1 .ColumnsWidthMode

="Fill" 

 

2. 

Set the First and the Second columns width to 'Auto'
3. Set the third column width to '*'

Hope this helps .

One more time thanks for the reported problem. I have updated your Telerik points.

Greetings,
Pavel Pavlov
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Paloma
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Paloma
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or