My combo is configured in the form's AutoGeneratingField event:
e.DataField =
new
DataFormComboBoxField()
{
Label =
"My combo"
,
ItemsSource = ComboTypeList.comboTypes,
DataMemberBinding =
new
Binding(
"FieldName"
)
{
ValidatesOnExceptions =
true
,
NotifyOnValidationError =
true
,
Mode = BindingMode.TwoWay
}
}
I would like my combo to show the "Clear Selection" button, but do not know how to access the property.
7 Answers, 1 is accepted
0
Hello Curt,
This style will be applied to each of the combo boxes in your application.
Kind regards,
Maya
the Telerik team
You can create implicit style targeting RadComboBox and define its clear selection button. For example:
<
UserControl.Resources
>
<
Style
TargetType
=
"telerik:RadComboBox"
>
<
Setter
Property
=
"ClearSelectionButtonContent"
Value
=
"Clear me"
/>
<
Setter
Property
=
"ClearSelectionButtonVisibility"
Value
=
"Visible"
/>
</
Style
>
</
UserControl.Resources
>
This style will be applied to each of the combo boxes in your application.
Kind regards,
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Curt
Top achievements
Rank 1
Iron
answered on 02 Apr 2012, 04:25 PM
Maya
I don't think that solution will work in my situation.
Defining a style for a RadComboBox doesn't apply to a DataFormComboBoxField.
Any other ideas?
Thanks
I don't think that solution will work in my situation.
Defining a style for a RadComboBox doesn't apply to a DataFormComboBoxField.
Any other ideas?
Thanks
0
Accepted
Hi Curt,
Maya
the Telerik team
I am sending you a sample project illustrating the suggested approach. Could you take a look at it and let me know if it will work for you ?
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Curt
Top achievements
Rank 1
Iron
answered on 03 Apr 2012, 06:26 PM
Maya
Your technique works fine in the sample, and I marked your post as an answer.
I need to modify my project to use your technique.
Thanks
Your technique works fine in the sample, and I marked your post as an answer.
I need to modify my project to use your technique.
Thanks
0
Oystein
Top achievements
Rank 1
answered on 12 Jun 2013, 10:48 AM
Sorry for replying to such an old thread.
I solved the problem mentioned by overriding the GetControl() method in the DataFormComboboxField class.
I solved the problem mentioned by overriding the GetControl() method in the DataFormComboboxField class.
public
class
DataFormClearableComboBoxField : DataFormComboBoxField
{
public
DataFormClearableComboBoxField() :
base
() { }
protected
override
Control GetControl()
{
var cBox = (RadComboBox)
base
.GetControl();
cBox.ClearSelectionButtonVisibility = System.Windows.Visibility.Visible;
cBox.ClearSelectionButtonContent =
"Clear selection"
;
return
cBox;
}
}
0
Peter
Top achievements
Rank 1
answered on 27 Jan 2014, 03:08 PM
Hi Maya,
your solution is only viable if all ComboBoxes in the RadDataForm should show the ClearSelectionButton or all should hide this button.
But there are cases when the user wants to show the ClearSelectionButton only for some of the properties beeing displayed. Unfortunately there seems to be no way to show or hide the button in the Autogenerator. There is noting like
DataFormComboBoxField.ClearSelectionButtonVisibility or
DataFormComboBoxField.ContentStyle to modify the appearance of the RadComboBoxes
I have taken Oystein's proposal and derived an extended DataFormComboBoxField class to use in the autogenerator.
Is there no more elegant way?
(See also my question http://www.telerik.com/forums/modify-appearance-of-radcomboboxes-in-raddataform)
your solution is only viable if all ComboBoxes in the RadDataForm should show the ClearSelectionButton or all should hide this button.
But there are cases when the user wants to show the ClearSelectionButton only for some of the properties beeing displayed. Unfortunately there seems to be no way to show or hide the button in the Autogenerator. There is noting like
DataFormComboBoxField.ClearSelectionButtonVisibility or
DataFormComboBoxField.ContentStyle to modify the appearance of the RadComboBoxes
I have taken Oystein's proposal and derived an extended DataFormComboBoxField class to use in the autogenerator.
Is there no more elegant way?
(See also my question http://www.telerik.com/forums/modify-appearance-of-radcomboboxes-in-raddataform)
/// <summary>
/// This class extends Telerik's DataFormComboBoxField, allowing to modify ClearSelectionButton's visibility.
/// This solves the problem, that in the autogenerator the underlying RadComboBox is not accessible and therefore it is not
/// possible to hide or show the ClearSelectionButton from the autogerator.
/// </summary>
public
class
DataFormComboBoxFieldEx
:
DataFormComboBoxField
{
public
DataFormComboBoxFieldEx() :
base
() { }
// Set this field to show or hide the ClearSelectionButton
public
System.Windows.Visibility ClearSelectionButtonVisibility = System.Windows.Visibility.Visible;
protected
override
Control GetControl()
{
RadComboBox cBox = (RadComboBox)
base
.GetControl();
cBox.ClearSelectionButtonVisibility = ClearSelectionButtonVisibility;
return
cBox;
}
}
0
Hi Peter,
I have already answered your ticket containing the same question.
Regards,
Yoan
Telerik
I have already answered your ticket containing the same question.
Regards,
Yoan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>