using
System;
using
Telerik.WinControls;
using
Telerik.WinControls.UI;
namespace
MCCBCustomRadGridView
{
public
partial
class
RadFormCustomGrid : Telerik.WinControls.UI.RadForm
{
public
RadFormCustomGrid()
{
InitializeComponent();
}
private
void
RadFormCustomGrid_Load(
object
sender, EventArgs e)
{
this
.customersTableAdapter.Fill(
this
.nwindDataSet.Customers);
}
}
public
class
MyRadMultiColumnComboBox : RadMultiColumnComboBox
{
public
override
string
ThemeClassName
{
get
{
return
typeof
(RadMultiColumnComboBox).FullName;
}
}
protected
override
RadMultiColumnComboBoxElement CreateMultiColumnComboBoxElement()
{
return
new
MyRadMultiColumnComboBoxElement();
}
}
public
class
MyRadMultiColumnComboBoxElement : RadMultiColumnComboBoxElement
{
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(RadMultiColumnComboBoxElement);
}
}
protected
override
RadPopupControlBase CreatePopupForm()
{
MultiColumnComboPopupForm popupForm =
new
MyMultiColumnComboPopupForm(
this
);
popupForm.EditorControl.Focusable =
false
;
popupForm.MinimumSize =
this
.DropDownMaxSize;
popupForm.MaximumSize =
this
.DropDownMaxSize;
popupForm.Height =
this
.DropDownHeight;
popupForm.VerticalAlignmentCorrectionMode = AlignmentCorrectionMode.SnapToOuterEdges;
popupForm.HorizontalAlignmentCorrectionMode = AlignmentCorrectionMode.Smooth;
popupForm.RightToLeft =
this
.RightToLeft ? System.Windows.Forms.RightToLeft.Yes : System.Windows.Forms.RightToLeft.Inherit;
this
.WirePopupFormEvents(popupForm);
return
popupForm;
}
}
public
class
MyMultiColumnComboPopupForm : MultiColumnComboPopupForm
{
internal
bool
closed;
public
MyMultiColumnComboPopupForm(RadMultiColumnComboBoxElement element)
:
base
(element)
{ }
protected
override
GridViewHostItem CreateEditorElement()
{
return
new
MyGridViewHostItem();
}
/// <summary>
/// Fires when the popup is opened.
/// </summary>
protected
override
void
OnPopupOpened()
{
base
.OnPopupOpened();
closed =
false
;
}
/// <summary>
/// Fires when the popup is closed.
/// </summary>
/// <param name="args">A RadPopupClosedEventArgs instance
/// that contains information about what caused the popup to close.</param>
protected
override
void
OnPopupClosed(RadPopupClosedEventArgs args)
{
base
.OnPopupClosed(args);
closed =
true
;
}
}
public
class
MyGridViewHostItem : GridViewHostItem
{
public
MyGridViewHostItem()
:
base
(
new
MyRadGridView())
{ }
}
public
class
MyRadGridView : RadGridView
{
#region Ctor
public
MyRadGridView()
{
this
.GridBehavior =
new
MultiColumnComboGridBehavior();
}
protected
override
void
OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
MyMultiColumnComboPopupForm form =
this
.Parent
as
MyMultiColumnComboPopupForm;
if
(form !=
null
&& form.closed)
{
return
;
}
base
.OnMouseDown(e);
}
#endregion
#region Methods
protected
override
bool
ProcessFocusRequested(RadElement element)
{
return
false
;
}
public
override
string
ThemeClassName
{
get
{
return
"Telerik.WinControls.UI.RadGridView"
;
}
set
{
base
.ThemeClassName = value;
}
}
#endregion
}
}