WinForm 里DataGRID 添加 Button按钮例的问题

cgl1992 2006-06-01 01:42:35
我想在DataGRID 添加 Button按钮例,参照了http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q888q页面,可是运行下来总是报错,Object reference not set to an instance of an object.
如果我把 buttonColStyle.MappingName = "action"; 屏蔽则不会报错,可是按钮不回显示 !
不知道哪里出错,各位帮帮忙啊。
有没有好的解决案例 ?

...全文
145 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
wls12342004 2006-06-01
  • 打赏
  • 举报
回复
public class DataGridTextButtonColumn:BX.DataGridTextColorBoxColumn
{
private int xMargin = 2;
private int yMargin = 1;
public delegate void bxBut_Click(object sender, EventArgs e);
public event bxBut_Click Do_Click;

//private BX.BXButton bxButton1;
private BX.BXLabel bxButton1;

protected override void Edit( CurrencyManager source
, int rowNum
, Rectangle bounds
, bool readOnly
, string instantText
, bool cellIsVisible
)
{
this.bxButton1.Click -=new EventHandler(bxButton1_Click);

//Store the real bounds
Rectangle originalBounds = bounds;

object value = GetColumnValueAtRow(source,rowNum);

if (cellIsVisible)
{
bounds.Offset(xMargin, yMargin);
bounds.Width -= xMargin*2;
bounds.Height -= yMargin;
bounds.Width=bounds.Width/5;
this.bxButton1.Bounds=bounds;
this.bxButton1.Visible=true;
}
else
{
originalBounds.Width=originalBounds.Width/5;
this.bxButton1.Bounds=originalBounds;
this.bxButton1.Visible=false;
}

// this.dateTimePicker.RightToLeft = this.DataGridTableStyle.DataGrid.RightToLeft;
this.bxButton1.Enabled=!this.RealReadOnly;

// if(this.bxButton1.Visible)
// {
// DataGridTableStyle.DataGrid.Invalidate(originalBounds);
// }

this.bxButton1.Click +=new EventHandler(bxButton1_Click);
// this.bxButton1.Focus();
}

}



再用这个类代替要家'按钮的grid中的例就可以了

110,532

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧