or
I need a button with 3 images and 3 labels.
Thank you very much.
-----------------------
- Image1 label1 -
- Image2 label2 -
- Image3 label3 -
-----------------------
Hi everyone,
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement.ColumnInfo is GridViewDataColumn && ((GridViewDataColumn)e.CellElement.ColumnInfo).Name == "column1")
{
//if (!(e.CellElement.RowElement is GridHeaderRowElement)) // I can't write this code because my codes can't find GridHeaderRowElement class.
{
if (e.CellElement.Children.Count > 0)
return;
ucTextBoxButton txt = new ucTextBoxButton();
txt.KeyDown += new KeyEventHandler(txt_KeyDown);
e.Column.ReadOnly = true;
ucGridViewTextBoxButtonColumn gridviewclm = new ucGridViewTextBoxButtonColumn(txt);
gridviewclm.StretchHorizontally = true;
gridviewclm.StretchVertically = true;
e.CellElement.Children.Add(gridviewclm);
}
}
}
ucGridViewTextButtonCellElement.cs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.WinControls.UI;
using Telerik.Reporting.Drawing;
using System.Drawing;
namespace FCS.ManagementConsole.Main.Components
{
class ucGridViewTextButtonCellElement : GridDataCellElement
{
private ucTextButtonElement TextBoxButtonElement;
public ucGridViewTextButtonCellElement(GridViewColumn column, GridRowElement row)
: base(column, row)
{
}
public override void Initialize(GridViewColumn column, GridRowElement row)
{
base.Initialize(column, row);
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(GridDataCellElement);
}
}
protected override void CreateChildElements()
{
base.CreateChildElements();
TextBoxButtonElement = new ucTextButtonElement();
TextBoxButtonElement.MinSize = new Size(50, 20);
TextBoxButtonElement.Text = "Red";
this.Children.Add(TextBoxButtonElement);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.WinControls.UI;
namespace FCS.ManagementConsole.Main.Components
{
class ucTextButtonElement:RadTextBoxElement
{
public event EventHandler ButtonClick;
public ucTextButtonElement()
{
RadButtonElement btn = new RadButtonElement();
btn.Size = new System.Drawing.Size(25, 10);
btn.Click += new EventHandler(btn_Click);
btn.BringToFront();
btn.Text = "...";
}
void btn_Click(object sender, EventArgs e)
{
EventHandler handler = ButtonClick;
if (handler != null) handler(this, e);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.WinControls.UI;
namespace FCS.ManagementConsole.Main.Components
{
class ucGridViewTextBoxButtonColumn2 : GridViewDataColumn
{
public ucGridViewTextBoxButtonColumn2(string fieldName)
: base(fieldName)
{
}
public override Type GetCellType(GridViewRowInfo row)
{
if (row is GridViewDataRowInfo)
{
return typeof(ucTextButtonElement);
}
return base.GetCellType(row);
}
}
}
ucGridViewTextBoxButtonColumn2 grid = new ucGridViewTextBoxButtonColumn2("TextBoxColumn");
radGridView1.Columns.Add(grid);
radGridView1.Rows.AddNew();