问题中的问题
nekiy 2006-03-24 09:08:29 我用DataGrid自带的编辑、取消、更新的操作,发现那个生成的文本框(TextBox)很宽,我就要往哪里面添两三个数字,我查了如何改变大小,网上有这种代码:
在ItemCreated事件中进行设置
private void DataGrid1_ItemCreated(object sender, DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.EditItem)
{
foreach(TableCell cell in e.Item.Cells)
{
TextBox tb = cell.Controls[0] as TextBox;
if( null != tb)
{
tb.Width = Unit.Parse("100px");
tb.BackColor = System.Drawing.Color.Red;
}
}
}
}
代码是这个,问题是我怎么才能触发它呢?
我们用按钮时在
override protected void OnInit(EventArgs e)
{
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler//这个(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
就可以触发了,可是我怎么才能运行上边那个程序呢??
迷茫中……………………