New to Telerik UI for WinForms? Start a free 30-day trial
Custom Editors
Updated over 1 year ago
This article demonstrates a sample approach how to create and replace the default editor with a track bar editor to allow editing numeric values.
Figure 1: Custom track bar editor

Custom editor
C#
public class MyTrackBarEditor : BaseInputEditor
{
public override object Value
{
get
{
RadTrackBarElement editor = (RadTrackBarElement)this.EditorElement;
return editor.Value;
}
set
{
RadTrackBarElement editor = (RadTrackBarElement)this.EditorElement;
if (value != null && value != DBNull.Value)
{
editor.Value = Convert.ToInt32(value);
}
else
{
editor.Value = 0;
}
}
}
public override void BeginEdit()
{
base.BeginEdit();
this.EditorElement.Focus();
((RadTrackBarElement)this.EditorElement).ValueChanged += new EventHandler(TrackBarEditor_ValueChanged);
}
void TrackBarEditor_ValueChanged(object sender, EventArgs e)
{
this.OnValueChanged();
}
public override bool EndEdit()
{
((RadTrackBarElement)this.EditorElement).ValueChanged -= TrackBarEditor_ValueChanged;
return base.EndEdit();
}
protected override RadElement CreateEditorElement()
{
return new RadTrackBarElement();
}
public override Type DataType
{
get
{
return typeof(int);
}
}
}
Here is the sample code snippet how to replace the default editor with the custom one handling the EditorRequired event:
Replace default editor
C#
private void RadListView_EditorRequired(object sender, ListViewItemEditorRequiredEventArgs e)
{
//if you use DetailsView and the current column is a specific one, replace the editor
if (this.radListView1.CurrentColumn.Name == "Quantity")
{
e.EditorType=typeof(MyTrackBarEditor);
}
}