or
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
DataTable dtGrid =
new
DataTable();
dtGrid.Columns.Add(
"COL1"
,
typeof
(
string
));
dtGrid.Columns.Add(
"COL2"
,
typeof
(
string
));
for
(
int
j = 0; j < 20; j++)
{
dtGrid.Rows.Add(
"val_0"
,
"val_1"
);
}
radGridView1.DataSource = dtGrid;
}
void
radGridView1_CreateCell(
object
sender, GridViewCreateCellEventArgs e)
{
if
(e.CellType ==
typeof
(GridDataCellElement) && e.Row
is
GridDataRowElement)
{
e.CellType =
typeof
(MyCell);
}
}
}
public
class
MyCell : GridDataCellElement
{
private
RadHostItem _RadHostItem;
private
RadTextBox _RadTextBox;
public
MyCell(GridViewColumn column, GridRowElement row)
:
base
(column, row)
{
}
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
_RadTextBox =
new
RadTextBox();
_RadTextBox.Name =
"_RadTextBox"
;
_RadHostItem =
new
RadHostItem(_RadTextBox);
Children.Add(_RadHostItem);
}
public
override
void
SetContent()
{
_RadTextBox.Text =
"flower"
;
}
protected
override
SizeF ArrangeOverride(SizeF finalSize)
{
SizeF size =
base
.ArrangeOverride(finalSize);
float
width = size.Width;
float
height = size.Height;
_RadHostItem.Arrange(
new
RectangleF(1f, 1f, width - 1f, height - 1f));
return
size;
}
}