public
partial class Test : Form
{
DataTable dtMain;
DataTable dtChild;
public Test()
{
InitializeComponent();
SetTableData();
radGridView1.DataSource = dtMain;
}
private void CreateMainTable()
{
dtMain =
new DataTable("MainTable");
dtMain.Columns.Add(
new DataColumn("Id", typeof(System.Int32)));
dtMain.Columns.Add(
new DataColumn("Desc", typeof(System.String)));
dtMain.Columns.Add(
new DataColumn("Type", typeof(System.String)));
}
private DataTable CreateChildTable()
{
dtChild =
new DataTable("ChildTable");
dtChild.Columns.Add(
new DataColumn("Id", typeof(System.Int32)));
dtChild.Columns.Add(
new DataColumn("Value", typeof(System.String)));
return dtChild;
}
private void SetTableData()
{
CreateMainTable();
CreateChildTable();
DataRow dr = dtMain.NewRow();
dr[
"Id"] = 1;
dr[
"Desc"] = "FT Status";
dr[
"Type"] = "lookup";
dtMain.Rows.Add(dr);
dr = dtMain.NewRow();
dr[
"Id"] = 2;
dr[
"Desc"] = "UT Status";
dr[
"Type"] = "lookup";
dtMain.Rows.Add(dr);
dr = dtMain.NewRow();
dr[
"Id"] = 3;
dr[
"Desc"] = "Test";
dr[
"Type"] = "userentry";
dtMain.Rows.Add(dr);
DataRow childRow = dtChild.NewRow();
childRow[
"Id"] = 1;
childRow[
"Value"] = "Test1";
dtChild.Rows.Add(childRow);
childRow = dtChild.NewRow();
childRow[
"Id"] = 1;
childRow[
"Value"] = "Test2";
dtChild.Rows.Add(childRow);
childRow = dtChild.NewRow();
childRow[
"Id"] = 1;
childRow[
"Value"] = "Test3";
dtChild.Rows.Add(childRow);
childRow = dtChild.NewRow();
childRow[
"Id"] = 2;
childRow[
"Value"] = "New1";
dtChild.Rows.Add(childRow);
childRow = dtChild.NewRow();
childRow[
"Id"] = 2;
childRow[
"Value"] = "New2";
dtChild.Rows.Add(childRow);
}
private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
}
private void FillCustomLookupData(GridViewLookUpColumn gridViewLookUpColumn, int customLookupId)
{
if (gridViewLookUpColumn != null)
{
//DataTable dtNew = dtChild.Select("Id=" + Convert.ToString(customLookupId));
DataView dv = dtChild.DefaultView;
dv.RowFilter =
"Id=" + Convert.ToString(customLookupId);
gridViewLookUpColumn.DataSource = dv.ToTable();
gridViewLookUpColumn.UniqueName =
"Value";
gridViewLookUpColumn.DisplayMember =
"Value";
gridViewLookUpColumn.DropDownStyle =
RadDropDownStyle.DropDownList;
}
}
private void radGridView1_CreateRow(object sender, GridViewCreateRowEventArgs e)
{
}
private void radGridView1_DataBindingComplete(object sender, GridViewBindingCompleteEventArgs e)
{
}
private void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)
{
RadTextBoxElement rtxtElement;
if (radGridView1.CurrentRow.Cells["Value"] == null)
return;
GridViewLookUpColumn gridViewLookUpColumn = ((Telerik.WinControls.UI.GridViewLookUpColumn)(radGridView1.CurrentRow.Cells["Value"].ColumnInfo));
if (radGridView1.CurrentRow.Cells["Type"].Value.ToString().Trim() == "lookup")
{
FillCustomLookupData(gridViewLookUpColumn,
Convert.ToInt32(radGridView1.CurrentRow.Cells["Id"].Value));
radGridView1.CurrentRow.Cells[
"ValuesBound"].Value = "1";
}
else
{
rtxtElement =
new RadTextBoxElement();
if (radGridView1.CurrentRow.Cells["Value"].CellElement != null)
{
if (radGridView1.CurrentRow.Cells["Value"].CellElement.Children.Count == 0)
{
rtxtElement.TextChanged +=
new EventHandler(rtxtElement_TextChanged);
radGridView1.CurrentRow.Cells[
"Value"].CellElement.Children.Add(rtxtElement);
}
radGridView1.CurrentRow.Cells[
"ValuesBound"].Value = "1";
}
}
}
void rtxtElement_TextChanged(object sender, EventArgs e)
{
}
private void radCheckBox1_Enter(object sender, EventArgs e)
{
radCheckBox1.BackColor =
Color.Beige;
}
private void radCheckBox1_Leave(object sender, EventArgs e)
{
radCheckBox1.BackColor =
Color.Red;
}
}