DotNetBar第三方控件使用笔记

发布时间 : 星期三 文章DotNetBar第三方控件使用笔记更新完毕开始阅读

图1

图2

仔细想想,Autosize肯定不行,其和Dock在实现上就是是矛盾的,呵呵。 真是懒习惯了,动手加下边几句就可以解决,在这里记录一下。 public partial class Test : Form { // 记录右侧Panel宽度 private int m_RightWidth = 0; public Test() { InitializeComponent(); m_RightWidth = panelEx_Right.Width; }

private void expandableSplitter_Click(object sender, EventArgs e) {

if (expandableSplitter.Expanded) { m_RightWidth = panelEx_Right.Width; this.Width -= m_RightWidth; } else { this.Width += m_RightWidth; } } }

图3

另外记得设置MinExtra属性为0,不然ExpandableSplitter拖不到最边上。

关于控件TabControl的比较高级的用法示例

private void itemPanel1_ItemClick(object sender, System.EventArgs e) { ButtonItem button = sender as ButtonItem; if(button==null) return; eTabStripStyle style = (eTabStripStyle)Enum.Parse(typeof(eTabStripStyle),n.Name); SetTabStyle(style); itemPanel1.RecalcLayout(); }

private void ChangeTabColor(object sender, EventArgs e)

butto {

if(m_TabMouseDown != null) {

m_TabMouseDown.PredefinedColor=(eTabItemColor)Enum.Parse(typeof(eTabItemColor),((BaseItem)sender).Text); }

}

private void SetTabStyle(eTabStripStyle style) { tabControl1.Style=style; foreach(TabItem tab in tabControl1.Tabs) tab.PredefinedColor=eTabItemColor.Default; }

private void tabControl1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) {

if(e.Button != MouseButtons.Right) return; // 转换到上下文菜单的屏幕坐标 Point p=new Point(e.X,e.Y); Point pScreen=tabControl1.PointToScreen(p); TabItem tab=tabControl1.TabStrip.HitTest(p.X,p.Y); if(tab != null) { m_TabMouseDown=tab;

// 创建右键菜单

CreateContextMenu(); ButtonItem item=contextMenuBar1.Items[\] as ButtonItem;

// 弹出右键菜单

item.Popup(pScreen); } }

private void CreateContextMenu() { if(contextMenuBar1.Items.Contains(\)) return; ButtonItem item=new ButtonItem(\,\Colors Context menu\); item.Style=eDotNetBarStyle.Office2003; contextMenuBar1.Items.Add(item);

// 为eTabItemColor的每一个实体创建一个菜单项 string[] names=Enum.GetNames(typeof(eTabItemColor)); foreach(string s in names) { ButtonItem menuItem=new ButtonItem(s,s); // 构建菜单项的图像 TabItem tabTemp=new TabItem(); tabTemp.PredefinedColor=(eTabItemColor)Enum.Parse(typeof(eTabItemColor),s); Bitmap bmp=new Bitmap(16,16,System.Drawing.Imaging.PixelFormat.Format24bppRgb); Graphics g=Graphics.FromImage(bmp); try { g.Clear(SystemColors.Control); Rectangle r=new Rectangle(1,1,14,14); using(System.Drawing.Drawing2D.LinearGradientBrush brush=new System.Drawing.Drawing2D.LinearGradientBrush(r,tabTemp.BackColor,tabTemp.BackColor2,tabTemp.BackColorGradientAngle))g.FillRectangle(brush,r); using(Pen pen=new Pen(Color.DarkGray,1))g.DrawRectangle(pen,r);

} finally

{ g.Dispose(); } bmp.MakeTransparent(SystemColors.Control); menuItem.Image=bmp; menuItem.Click+=new EventHandler(this.ChangeTabColor); item.SubItems.Add(menuItem);

} }

控件Reflection的使用(倒影)

Image与控件Reflection Label可生成如下图所示的效果

联系合同范文客服:xxxxx#qq.com(#替换为@)