or
public
class
IntelliBoxColumn : GridViewDataColumn
{
public
IntelliBoxColumn(
string
columnName) :
base
(columnName) { }
public
override
Type GetDefaultEditorType()
{
return
typeof
(IntelliBoxGridEditor);
}
public
override
Type GetCellType(GridViewRowInfo row)
{
if
(row
is
GridViewDataRowInfo)
{
return
typeof
(IntelliBoxCellElement);
}
return
base
.GetCellType(row);
}
}
public
partial
class
IntelliBoxEditorElement : LightVisualElement
{
RadTextBoxItem textBox;
RadButtonElement button;
public
RadTextBoxItem TextBox {
get
{
return
this
.textBox;}}
public
RadButtonElement Button {
get
{
return
this
.button; } }
protected
override
void
CreateChildElements()
{
textBox =
new
RadTextBoxItem();
textBox.RouteMessages =
true
;
button =
new
RadButtonElement(
"..."
);
button.Padding =
new
Padding(2, 0, 2, 0);
this
.Children.Add(textBox);
this
.Children.Add(button);
}
protected
override
SizeF ArrangeOverride(SizeF finalSize)
{
RectangleF clientRect = GetClientRectangle(finalSize);
RectangleF buttonRect =
new
RectangleF(clientRect.Right - button.DesiredSize.Width, clientRect.Top,
button.DesiredSize.Width, clientRect.Height);
RectangleF textRect =
new
RectangleF(clientRect.Left, clientRect.Top + (clientRect.Height - textBox.DesiredSize.Height) / 2,
buttonRect.Left - clientRect.Left - 2, textBox.DesiredSize.Height);
foreach
(RadElement element
in
this
.Children)
{
if
(element ==
this
.textBox)
{
element.Arrange(textRect);
}
else
if
(element ==
this
.button)
{
element.Arrange(buttonRect);
}
else
{
ArrangeElement(element, finalSize);
}
}
return
finalSize;
}
}
public
class
IntelliBoxGridEditor : BaseGridEditor
{
private
bool
endEditOnLostFocus =
false
;
protected
override
Telerik.WinControls.RadElement CreateEditorElement()
{
return
new
IntelliBoxEditorElement();
}
private
IntelliBoxEditorElement IntelliBox
{
get
{
return
(IntelliBoxEditorElement)EditorElement; }
}
public
override
bool
EndEditOnLostFocus
{
get
{
return
endEditOnLostFocus; }
}
public
override
object
Value
{
get
{
return
IntelliBox.Text;}
set
{
string
strValue =
string
.Empty;
if
(value !=
null
&& value != DBNull.Value) strValue = value.ToString();
IntelliBox.TextBox.Text = strValue;
}
}
public
override
Type DataType
{
get
{
return
typeof
(
string
);}
}
public
override
void
BeginEdit()
{
base
.BeginEdit();
IntelliBox.TextBox.TextChanging +=
new
TextChangingEventHandler(TextBox_TextChanging);
IntelliBox.TextBox.TextChanged +=
new
EventHandler(TextBox_TextChanged);
IntelliBox.TextBox.KeyDown +=
new
KeyEventHandler(TextBox_KeyDown);
IntelliBox.Button.Click +=
new
EventHandler(Button_Click);
IntelliBox.TextBox.SelectAll();
IntelliBox.TextBox.Focus();
}
public
override
bool
EndEdit()
{
IntelliBox.TextBox.TextChanging -=
new
TextChangingEventHandler(TextBox_TextChanging);
IntelliBox.TextBox.TextChanged -=
new
EventHandler(TextBox_TextChanged);
IntelliBox.TextBox.KeyDown -=
new
KeyEventHandler(TextBox_KeyDown);
IntelliBox.Button.Click -=
new
EventHandler(Button_Click);
return
base
.EndEdit();
}
void
TextBox_TextChanging(
object
sender, TextChangingEventArgs e)
{
ValueChangingEventArgs args =
new
ValueChangingEventArgs(e.NewValue);
args.OldValue = e.OldValue;
OnValueChanging(args);
e.Cancel = args.Cancel;
}
void
TextBox_TextChanged(
object
sender, EventArgs e)
{
OnValueChanged();
}
void
TextBox_KeyDown(
object
sender, KeyEventArgs e)
{
RadGridView grid = ((RadElement)sender).ElementTree.Control
as
RadGridView;
if
(grid !=
null
)
{
switch
(e.KeyCode)
{
case
Keys.Escape:
case
Keys.Enter:
case
Keys.Up:
case
Keys.Down:
grid.GridBehavior.ProcessKeyDown(e);
break
;
}
}
}
void
Button_Click(
object
sender, EventArgs e)
{
endEditOnLostFocus =
false
;
var gridView = (WPDataGrid)IntelliBox.ElementTree.Control;
gridView.RaiseButtonClicked(
this
);
endEditOnLostFocus =
true
;
gridView.EndEdit();
}
}
public
class
IntelliBoxCellElement : GridDataCellElement
{
private
RadLabelElement _label;
private
IntelliBoxColumn _column;
private
GridRowElement _row;
public
IntelliBoxCellElement(GridViewColumn column, GridRowElement row)
:
base
(column, row)
{
this
.BackColor = Color.White;
}
private
bool
_wasCurrent;
public
override
bool
IsCurrent
{
get
{
return
base
.IsCurrent; }
set
{
base
.IsCurrent = value;
if
(value && value != _wasCurrent)
_row.RowInfo.Cells[_column.Name].BeginEdit();
_wasCurrent = value;
}
}
protected
override
Type ThemeEffectiveType {
get
{
return
typeof
(GridDataCellElement); } }
public
override
void
Initialize(GridViewColumn column, GridRowElement row)
{
_column = (IntelliBoxColumn)column;
_row = row;
base
.Initialize(column, row);
}
protected
override
void
CreateChildElements()
{
_label =
new
RadLabelElement();
_label.Margin =
new
Padding(2, 2, 2, 2);
_label.LabelText.AutoEllipsis =
true
;
_label.LabelText.AutoSize =
true
;
_label.LabelText.AutoSizeMode = RadAutoSizeMode.Auto;
_label.LabelText.TextWrap =
false
;
this
.Children.Add(_label);
}
protected
override
void
DisposeManagedResources()
{
base
.DisposeManagedResources();
}
protected
override
void
SetContentCore(
object
value)
{
if
(value !=
null
)
{
_label.Text = value.ToString();
}
}
public
override
bool
IsCompatible(GridViewColumn data,
object
context)
{
return
data
is
IntelliBoxColumn && context
is
GridDataRowElement;
}
}
How to pageview Content Area Hide?