Hello,
I found some problems trying to use the RadHostItem control to customize the cells of a RadGridView.
I developed a class (MyCell) that derives from GridDataCellElement; in such class, the RadHostItem hosts a RadTextBox control.
In the CreateCell event of the RadGridView, I set the cell tyle as typeof(MyCell).
Everything works fine, the RadTextBox control appears in the Grid cells but, and this is the problem I'd need to solve, when I scroll down the Grid, the RadTextBox controls cover and hide the Column Headers of the Grid.
I'm using RadControls for WinForms Q1 2010 SP2.
As attachment "scroll.JPG" shows what happens.
Could you please help me ? Many thanks in advance
Stefano
The entire source code is:
​
I found some problems trying to use the RadHostItem control to customize the cells of a RadGridView.
I developed a class (MyCell) that derives from GridDataCellElement; in such class, the RadHostItem hosts a RadTextBox control.
In the CreateCell event of the RadGridView, I set the cell tyle as typeof(MyCell).
Everything works fine, the RadTextBox control appears in the Grid cells but, and this is the problem I'd need to solve, when I scroll down the Grid, the RadTextBox controls cover and hide the Column Headers of the Grid.
I'm using RadControls for WinForms Q1 2010 SP2.
As attachment "scroll.JPG" shows what happens.
Could you please help me ? Many thanks in advance
Stefano
The entire source code is:
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;
}
}
​