我有一個Devexpress Tabcontrol。 在Tabcontrol裏面我有Devexpress Grid。 在那個網格里面我按照代碼在運行時加載按鈕。如何在Devexpress TabControl上添加按鈕點擊的標籤頁?
GridViewCommandColumn col = new GridViewCommandColumn();
GridViewCommandColumnCustomButton CusButton = new GridViewCommandColumnCustomButton();
CusButton.ID = "btn1";
CusButton.Image.Url = "~/Images/color.jpg";
col.ButtonType = ButtonType.Image;
col.CustomButtons.Add(CusButton);
gridview.Columns.Add(col);
現在對按鈕點擊,我需要在DevExpress的自定義的Tabcontrol添加一個標籤頁保留第一個選項卡上這個網格。
但它沒有得到補充,它得到刷新該按鈕點擊
我剛剛創建的對象爲標籤頁,加載具有的DevExpress GridView的Gridcontrol.ascx用戶控制。 之後我就叫addTabPages方法在我TabPage的用戶控件和it.In通過這個標籤頁對象作爲參數下面的代碼tabPreview是自定義的Tabcontrol用戶控件的對象。
tabpagenew = new TabPage();
Gc = (GridControl)Page.LoadControl(@"GridControl.ascx");
Gc.ID = "GC" + currDDIndex;
ASPxGridView grdPreview = (ASPxGridView)Gc.FindControl("ggc_preview");
grdPreview.ID = "grd" + currDDIndex;
tabpagenew.Controls.Add(Gc);
tabPreview.addTabPages(tabpagenew);
在addTabPages方法,我只是說由它的索引Tab頁,
public void addTabPages(TabPage tab_Page)
{
ActiveIndex = ASPxPageControl1.ActiveTabIndex + 1;
int index = ASPxPageControl1.TabPages.Count + 1;
ASPxPageControl1.TabPages.Add(tab_Page);
tab_Page.ToolTip = tab_Page.Text;
tab_Page.Name = tab_Page.Name;
ImageButton button = new ImageButton();
button.ImageUrl = "~\\Images\\close.png";
button.Style.Add(HtmlTextWriterStyle.Cursor, "Hand");
button.Click += new ImageClickEventHandler(Close_Click);
button.Attributes.Add("onclick", "TabClose('" + hdnCurrentTab.ClientID + "','" + tab_Page.Index + "');");
tab_Page.TabTemplate = new AddTabHeading(button, tab_Page.Text, ASPxPopupMenu1, ASPxPageControl1.ActiveTabPage.VisibleIndex, ASPxPageControl1);
}
你可以發佈完整的代碼或至少是添加標籤頁的部分嗎? – Filip 2012-01-11 07:56:13
@Filip:我只是通過添加Tab頁面代碼簡單地編輯了描述。 – 2012-01-18 07:48:40
按鈕點擊後是否執行addTabPages? – Filip 2012-01-18 10:24:13