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