Hi Kenneth,
Currently,
RadListView does not support different column types, but you can achieve this using its events.
I am not sure if you want to use custom cells or custom editors. In case you want the third column to be edited by drop-down editors you can handle the
EditorRequired event the following way:
If you want to use visually customized cells, then you can use the
CellCreating event to apply your custom cell. Here is a short example:
public
partial
class
Form45 : Form
{
public
static
ListViewDetailColumn checkBoxColumn;
public
Form45()
{
InitializeComponent();
this
.radListView1.CellCreating +=
new
Telerik.WinControls.UI.ListViewCellElementCreatingEventHandler(radListView1_CellCreating);
checkBoxColumn =
this
.radListView1.Columns[2];
}
void
radListView1_CellCreating(
object
sender, Telerik.WinControls.UI.ListViewCellElementCreatingEventArgs e)
{
DetailListViewDataCellElement cellElement = (e.CellElement
as
DetailListViewDataCellElement);
if
(cellElement ==
null
)
{
return
;
}
DetailListViewVisualItem visualItem =
this
.radListView1.ListViewElement.ViewElement.GetElement(cellElement.Row)
as
DetailListViewVisualItem;
if
(visualItem ==
null
)
{
return
;
}
if
(e.CellElement.Data == checkBoxColumn)
{
e.CellElement =
new
CheckBoxCell(
visualItem,
e.CellElement.Data);
}
else
{
e.CellElement =
new
DefaultCell(
visualItem,
e.CellElement.Data);
}
}
}
public
class
CheckBoxCell : DetailListViewDataCellElement
{
private
RadCheckBoxElement checkBox;
public
CheckBoxCell(DetailListViewVisualItem owner, ListViewDetailColumn column)
:
base
(owner, column)
{
}
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
checkBox =
new
RadCheckBoxElement();
checkBox.StretchHorizontally = checkBox.StretchVertically =
true
;
this
.Children.Add(checkBox);
}
public
override
void
Synchronize()
{
base
.Synchronize();
this
.checkBox.Text = (
string
)
this
.Row[
this
.Data];
this
.Text =
""
;
}
public
override
bool
IsCompatible(ListViewDetailColumn data,
object
context)
{
return
Form45.checkBoxColumn == data;
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(DetailListViewDataCellElement);
}
}
}
public
class
DefaultCell : DetailListViewDataCellElement
{
public
DefaultCell(DetailListViewVisualItem owner, ListViewDetailColumn column)
:
base
(owner, column)
{
}
public
override
bool
IsCompatible(ListViewDetailColumn data,
object
context)
{
return
Form45.checkBoxColumn != data;
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(DetailListViewDataCellElement);
}
}
}
In this case it seems better to use
GridView instead, since it provides typed columns which you can use out of the box.
I hope this was helpful. Should you have further questions, do not hesitate to contact me.
Best wishes,
Ivan Todorov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the
Telerik Public Issue Tracking system and vote to affect the priority of the items