Hi,
I am trying to add more than one text box and label in a cell. I successed in displaying the controls but the textboxes are in non editable mode. Means i can't change their text. I am also facing indefinite loop like thing with radGridView1_CellFormatting() event. It could be poosible i m doing it in wrong way please help me.
Here is my code for refrence:
I am also attaching the snap shot what i want to do.
Regards,
Saurabh Garg
I am trying to add more than one text box and label in a cell. I successed in displaying the controls but the textboxes are in non editable mode. Means i can't change their text. I am also facing indefinite loop like thing with radGridView1_CellFormatting() event. It could be poosible i m doing it in wrong way please help me.
Here is my code for refrence:
using System; |
using System.Collections.Generic; |
using System.ComponentModel; |
using System.Data; |
using System.Drawing; |
using System.Linq; |
using System.Text; |
using System.Windows.Forms; |
using Telerik.WinControls.UI; |
namespace TelerikGridEditing |
{ |
public partial class Form3 : Form |
{ |
public Form3() |
{ |
InitializeComponent(); |
} |
private void bindGrid() |
{ |
DataTable dt = new DataTable(); |
dt.Columns.Add("ProductId"); |
dt.Columns.Add("ProductName"); |
dt.Columns.Add("ProductDesciption"); |
dt.Rows.Add(1, "IPod Classic 80GB", "Description of product"); |
dt.Rows.Add(2, "IPod Touch 32GB", "Description of product"); |
dt.Rows.Add(3, "DishWasher", "Description of product"); |
dt.Rows.Add(4, "Microwave Oven", "Description of product"); |
dt.Rows.Add(5, "WashingMachine", "Description of product"); |
dt.Rows.Add(6, "Coffee Mug", "Description of product"); |
dt.Rows.Add(7, "Umbrella", "Description of product"); |
GridViewDataColumn col5 = new GridViewDataColumn(); |
radGridView1.DataSource = dt; |
radGridView1.MasterGridViewTemplate.Columns.Add(col5); |
} |
private void GridLayout() |
{ |
radGridView1.Columns[0].Width = 50; |
radGridView1.Columns[1].Width = 100; |
radGridView1.Columns[2].Width = 200; |
radGridView1.Columns[3].Width = 250; |
radGridView1.Width = 700; |
radGridView1.MasterGridViewTemplate.Columns[0].HeaderText = "Id"; |
radGridView1.MasterGridViewTemplate.Columns[1].HeaderText = "Name"; |
radGridView1.MasterGridViewTemplate.Columns[2].HeaderText = "Description"; |
radGridView1.MasterGridViewTemplate.Columns[3].HeaderText = "Order Detail"; |
radGridView1.MasterGridViewTemplate.AllowAddNewRow = false; |
radGridView1.MasterGridViewTemplate.EnableGrouping = false; |
} |
private void Form3_Load(object sender, EventArgs e) |
{ |
bindGrid(); |
GridLayout(); |
this.radGridView1.CellFormatting += new CellFormattingEventHandler(radGridView1_CellFormatting); |
} |
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) |
{ |
if (e.CellElement.RowInfo is GridViewDataRowInfo) |
{ |
if (e.CellElement.ColumnIndex == 3) |
{ |
int pos = 10; |
for (int i = 0; i < 2; i++) |
{ |
RadLabelElement lblElement = new RadLabelElement(); |
lblElement.MaxSize = new Size(50,10); |
lblElement.Location = new Point(5, pos); |
lblElement.Text = "Text"; |
e.CellElement.Children.Add(lblElement); |
RadTextBoxElement txtElement = new RadTextBoxElement(); |
txtElement.Text = "Blank"; |
txtElement.MaxSize = new Size(50, 10); |
txtElement.Location = new Point(55, pos); |
e.CellElement.Children.Add(txtElement); |
pos += 25; |
} |
int rowIndex = e.CellElement.RowIndex; |
this.radGridView1.Rows[rowIndex].Height = pos + 10; |
} |
} |
} |
} |
} |
I am also attaching the snap shot what i want to do.
Regards,
Saurabh Garg