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

set ClearSelectionButtonVisibilityProperty in code behind

2 Answers 74 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 13 Mar 2013, 04:31 PM
Hi Guys!

Please help me.

I am building a radGridView dynamically from a Databasetable.
So the GridColumns are not defined in XAML.

This dynamically GridView might have some GridViewComboBoxColumns
and the user should be able to delete/deselect the value.

I am trying this in the code behind:

                    GridViewComboBoxColumn ComboBoxCol = new GridViewComboBoxColumn();
                    ComboBoxCol.SetValue(RadComboBox.ClearSelectionButtonVisibilityProperty, "Visible");
                    ComboBoxCol.SetValue(RadComboBox.ClearSelectionButtonContentProperty, null);

But I get a runtime error, that "Visible" is no valid value for the property.

Any suggestions?


Thanks and Regards, Martin



2 Answers, 1 is accepted

Sort by
0
Martin
Top achievements
Rank 1
answered on 14 Mar 2013, 06:46 AM

Well,... Thinking a bit for myself and using the debugger I found my Error.
(A full night of sleep, might also have done the miracle ;-) )

The following is partially working:

ComboBoxCol.SetValue(RadComboBox.ClearSelectionButtonVisibilityProperty, System.Windows.Visibility.Visible);

My "only" problem now is, that the ClearButton is not showing.
The property ist set to visible but control is not showing.

Any suggestions?

Thanks and my best regards, Martin
0
Yoan
Telerik team
answered on 15 Mar 2013, 12:59 PM
Hello Martin,

In order to achieve your goal you will have to inherit  the GridViewComboBoxColumn and override the CreateCellElement method.

However, the easiest way to accomplish this would be to create implicit style targeting RadComboBox, like so:

<Window.Resources>    
    <Style TargetType="telerik:RadComboBox">
        <Setter Property="ClearSelectionButtonContent" Value="Clear me" />
        <Setter Property="ClearSelectionButtonVisibility" Value="Visible" />
    </Style>
</Window.Resources>

This style will be applied to each of the combo boxes in your application.
You can take a look at this forum thread for a reference as well.

Greetings,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Martin
Top achievements
Rank 1
Answers by
Martin
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or