如何显示c1flexgrid单元格中按钮
1个回答
2017-05-19 · 互联网+时代高效组织信息化平台
关注
展开全部
可以使用以下代码,但是有一点需要注意,如果你FlexGrid中数据行数过多不建议采用该方法,你可以设置该单元显示为一个图片,如何判断该单元格的单击事件:
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
c1FlexGrid1.DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw;
c1FlexGrid1.OwnerDrawCell += c1FlexGrid1_OwnerDrawCell;
c1FlexGrid1.Rows.Count = 20;
}
void c1FlexGrid1_OwnerDrawCell(object sender,C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
{
if (e.Col == 2 && e.Row > 0)
{
Button button = new Button();
button.Name = string.Format("FG_Button_{0}",e.Row);
button.Text = "修改";
button.Click += button_Click;
c1FlexGrid1.Controls.Add(button);
button.Location = new Point(e.Bounds.Left, e.Bounds.Top);
button.Size = new Size(e.Bounds.Width, e.Bounds.Height);
}
}
void button_Click(object sender, EventArgs e)
{
}
}
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
c1FlexGrid1.DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw;
c1FlexGrid1.OwnerDrawCell += c1FlexGrid1_OwnerDrawCell;
c1FlexGrid1.Rows.Count = 20;
}
void c1FlexGrid1_OwnerDrawCell(object sender,C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
{
if (e.Col == 2 && e.Row > 0)
{
Button button = new Button();
button.Name = string.Format("FG_Button_{0}",e.Row);
button.Text = "修改";
button.Click += button_Click;
c1FlexGrid1.Controls.Add(button);
button.Location = new Point(e.Bounds.Left, e.Bounds.Top);
button.Size = new Size(e.Bounds.Width, e.Bounds.Height);
}
}
void button_Click(object sender, EventArgs e)
{
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询