C#—Dev XtraTabControl操作总结如动态增加Tab和关闭选项卡方法等

1:显示行号

找到gridview属性 点击事件 CustomDrawRowIndicator

  private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
this.gridView1.IndicatorWidth = ;
if (e.Info.IsRowIndicator && e.RowHandle >= )
{
e.Info.DisplayText = Convert.ToString(e.RowHandle + );
} }

2: 隐藏GridControl的“Drag a column header here to group by that column” 也就是窗体最上边的边框.

打开设计器,找到OptionsView,往下拉设置showGroupPanel为false

C#—Dev XtraTabControl动态增加Tab和关闭选项卡方法,有需要的朋友可以参考下。

记录一下以免以后忘了

添加using DevExpress.XtraTab;

双击listview增加相应的tabpage,禁止重复添加:

private void listView_index_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (listView_index.SelectedItems.Count > 0)
{
ListViewItem lvi = listView_index.SelectedItems[0];//得到选中的项
string name = lvi.Text;
//判断是否已创建过
foreach (XtraTabPage page in xtraTabControl.TabPages)
{
if (page.Text == name)
{
xtraTabControl.SelectedTabPage = page;//显示该页
return;
}
}
//增加tabpage
XtraTabPage xpage = new XtraTabPage();
xpage.Name = name;
xpage.Text = name;
xpage.Controls.Add(ListView_Tec);//添加要增加的控件
xtraTabControl.TabPages.Add(xpage);
xtraTabControl.SelectedTabPage = xpage;//显示该页
}
}

若要tabpage显示关闭按钮,把xtraTabControl的ClosePageButtonShowMode属性设为InAllTabPageHeaders;若想要首页不显示关闭按钮:

xtraTab_index.ShowCloseButton = DevExpress.Utils.DefaultBoolean.False;//首页不显示关闭按钮

添加xtraTabControl的CloseButtonClick事件:

private void xtraTabControl_CloseButtonClick(object sender, EventArgs e)//关闭选项卡方法
{
DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs EArg = (DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs)e;
string name = EArg.Page.Text;//得到关闭的选项卡的text
foreach (XtraTabPage page in xtraTabControl.TabPages)//遍历得到和关闭的选项卡一样的Text
{
if (page.Text == name)
{
xtraTabControl.TabPages.Remove(page);
page.Dispose();
return;
}
}
}
上一篇:easyUI-右键菜单,关闭选项卡


下一篇:(转)android自定义组合控件