作者a2975313 (GN)
看板C_Sharp
标题[问题] 对自订控制项的疑问?
时间Mon Apr 5 18:27:42 2010
public class GridVieweE : System.Web.UI.WebControls.GridView, INamingContainer
{
private System.Web.UI.WebControls.Panel pnlScroll ;
/// <summary>
/// 设定滚动容器的宽度
/// </summary>
public Unit ScrollWidth
{
get{ return pnlScroll.Width; }
set{ pnlScroll.Width = value; }
}
/// <summary>
/// 设定滚动容器的高度
/// </summary>
public Unit ScrollHeight
{
get{ return pnlScroll.Height; }
set( pnlScroll.Height = value; }
}
protected override void CreateChildControls()
{
pnlScroll = new System.Web.UI.WebControls.Panel();
Control parent = this.Parent;
if (DesignMode == false)
{
try
{
Control gridView = this;
parent.Controls.Remove(gridView);
pnlScroll.Style.Add("width", this.ScrollWidth.ToString());
pnlScroll.Style.Add("height", this.ScrollHeight.ToString());
pnlScroll.Style.Add("overflow", "auto");
pnlScroll.Controls.Add(gridView);
parent.Controls.Add(pnlScroll);
ChildControlsCreated = true;
}
catch
{
}
}
base.CreateChildControls();
}
}
这段是我从网路上找到的code,他的用意是把旧的GridView加进Panel里面,然後编译成
新的GridviewE,简单讲就是让GridView有卷轴的功能,可是我编译後用起来都没效果@@
不知道哪里错了~"~
请大家帮我看一下...
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.33.182.163