Hello Jeff,
The main element of the
RadMaskedEditBox is initialized in the
CreateElement method of the control. The logic for adding the custom elements can be moved there. Please check my code snippet below:
public
class
CustomMaskedEditBox : RadMaskedEditBox
{
public
override
string
ThemeClassName
{
get
{
return
typeof
(RadMaskedEditBox).FullName;
}
}
protected
override
void
OnLoad(Size desiredSize)
{
base
.OnLoad(desiredSize);
searchButton.ButtonFillElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
searchButton.ShowBorder =
false
;
}
RadButtonElement searchButton =
new
RadButtonElement();
protected
override
RadMaskedEditBoxElement CreateElement()
{
RadMaskedEditBoxElement baseElement =
base
.CreateElement();
baseElement.TextBoxItem.NullText =
"Custom Mask"
;
searchButton.Click +=
new
EventHandler(button_Click);
searchButton.Margin =
new
Padding(0, 0, 0, 0);
searchButton.Text =
"Btn"
;
StackLayoutElement stackPanel =
new
StackLayoutElement();
stackPanel.Orientation = Orientation.Horizontal;
stackPanel.Margin =
new
Padding(1, 0, 1, 0);
stackPanel.Children.Add(searchButton);
RadTextBoxItem tbItem = baseElement.TextBoxItem;
baseElement.Children.Remove(tbItem);
DockLayoutPanel dockPanel =
new
DockLayoutPanel();
dockPanel.Children.Add(stackPanel);
dockPanel.Children.Add(tbItem);
DockLayoutPanel.SetDock(tbItem, Telerik.WinControls.Layouts.Dock.Left);
DockLayoutPanel.SetDock(stackPanel, Telerik.WinControls.Layouts.Dock.Right);
baseElement.Children.Add(dockPanel);
return
baseElement;
}
public
class
SearchBoxEventArgs : EventArgs
{
private
string
searchText;
public
string
SearchText
{
get
{
return
searchText;
}
set
{
searchText = value;
}
}
}
public
event
EventHandler<SearchBoxEventArgs> Search;
private
void
button_Click(
object
sender, EventArgs e)
{
SearchBoxEventArgs newEvent =
new
SearchBoxEventArgs();
newEvent.SearchText =
this
.Text;
SearchEventRaiser(newEvent);
}
private
void
SearchEventRaiser(SearchBoxEventArgs e)
{
if
(Search !=
null
)
Search(
this
, e);
}
}
Should you have further questions please do not hesitate to write back.
Regards,
Hristo
Progress Telerik
Get
quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers.
Learn More.