DotNet第三方控件使用笔记

合集下载

第三方控件使用大全

第三方控件使用大全

第三方控件使用大全第三方控件使用大全一、ComboBoxEdit 1、如何使其不可编辑TextEditStyle 设置为:DisableTextEditor 2、如何设置鼠标为手形Cursor 设置为:Hand 二、GridControl 1、如何解决单击记录整行选中的问题View->OptionsBehavior->EditorShowMode 设置为:Click 2、如何新增一条记录(1)、gridView.AddNewRow() (2)、实现gridView_InitNewRow事件3、如何解决GridControl 记录能获取而没有显示出来的问题gridView.populateColumns(); 4、如何让行只能选择而不能编辑(或编辑某一单元格)(1)、View->OptionsBehavior->EditorShowMode 设置为:Click (2)、View->OptionsBehavior->Editable 设置为:false 5、如何禁用GridControl中单击列弹出右键菜单设置Run Design->OptionsMenu->EnableColumnMenu 设置为:false 6、如何隐藏GridControl的GroupPanel表头设置Run Design->OptionsView->ShowGroupPanel 设置为:false 7、如何禁用GridControl中列头的过滤器过滤器如下图所示:设置RunDesign->OptionsCustomization->AllowFilter 设置为:false 8、如何在查询得到0条记录时显示自定义的字符提示/显示如图所示:方法如下://When no Records Are Being Displayed private voidgridView1_CustomDrawEmptyForeground(object sender, CustomDrawEventArgs e) { //方法一(此方法为GridView设置了数据源绑定时,可用)ColumnView columnView = sender as ColumnView; BindingSource bindingSource = this.gridView1.DataSource as BindingSource; if(bindingSource.Count == 0) { string str = "没有查询到你所想要的数据!"; Font f = new Font("宋体", 10, FontStyle.Bold); Rectangle r = new Rectangle(e.Bounds.Top + 5, e.Bounds.Left + 5, e.Bounds.Right - 5, e.Bounds.Height - 5);e.Graphics.DrawString(str, f, Brushes.Black, r); } //方法二(此方法为GridView没有设置数据源绑定时,使用,一般使用此种方法)if (this._flag){ if (this.gridView1.RowCount == 0){ string str = "没有查询到你所想要的数据!"; Font f = new Font("宋体", 10, FontStyle.Bold); Rectangle r =new Rectangle(e.Bounds.Left + 5, e.Bounds.Top + 5,e.Bounds.Width - 5, e.Bounds.Height - 5);e.Graphics.DrawString(str, f, Brushes.Black,r); } } } 9、如何显示水平滚动条?设置this.gridView.OptionsView.ColumnAutoWidth = false; 10、如何定位到第一条数据/记录?设置this.gridView.MoveFirst() 11、如何定位到下一条数据/记录?设置this.gridView.MoveNext() 12、如何定位到最后一条数据/记录?设置this.gridView.MoveLast() 13、设置成一次选择一行,并且不能被编辑this.gridView1.FocusRectStyle =DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFoc us; this.gridView1.OptionsBehavior.Editable = false;this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false; 14、如何显示行号?this.gridView1.IndicatorWidth = 40; //显示行的序号private void gridView1_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e){ if (.IsRowIndicator &&e.RowHandle>=0){ .DisplayText = (e.RowHandle + 1).ToString(); } } 15、如何让各列头禁止移动?设置gridView1.OptionsCustomization.AllowColumnMoving = false;16、如何让各列头禁止排序?设置gridView1.OptionsCustomization.AllowSort = false; 17、如何禁止各列头改变列宽?设置gridView1.OptionsCustomization.AllowColumnResizing = false;三、navBarControl 1、如何在每一个navBarGroup里添加自己想要的控件设置GroupStyle: ControlContainer 2、如何设置navBarGroup有滚动条设置SkinExplorerBarViewScrollStyle:ScrollBar 3、如休把navBarGroup设置成如下样式如图所示:设置navBarGroup的PaintStyleName属性为: SkinNavigationPane 四、toolTipController 效果图如下:1、如何设置显示的时间长短设置this.toolTipController1.AutoPopDelay = 2000; 2、如何在屏幕上显示如上图所示的效果ToolTipControllerShowEventArgs args =this.toolTipController1.CreateShowArgs();this.toolTipController1.SetToolTip(this.sbtnYes, "请选择一条记录!");this.toolTipController1.SetTitle(this.sbtnYes, "提示");this.toolTipController1.SetToolTipIconType(this.sbtnYes, DevExpress.Utils.ToolTipIconType.Exclamation);this.toolTipController1.ShowBeak = true;this.toolTipController1.ShowShadow = true;this.toolTipController1.Rounded = true;this.toolTipController1.ShowHint("请选择一条记录!", "提示"); args.ToolTip = "请选择一条记录!"; args.Title = "提示"; 3、如何设置边框的颜色this.toolTipController1.Appearance.BorderColor = Color.Red; 五、TextEdit 1、如何设置TextEdit为多行,可拉伸设置TextEdit的Propertity->AutoHeight为:False 六、LayoutControl 1、如何设置LayoutItem为隐藏设置LayoutItem.Visibility = Never 七、TreeList 1、如何隐藏TreeList的列头设置TreeListr的OptionsView 的ShowColumns属性为:False 2、如何八、PictureEdit 1、如何禁止PictureEdit的右键菜单?设置PictureEdit的Properties->ShowMenu为:false 九、TreeList 1、如何让TreeList的每个结点高亮显示?效果如下:代码如下:private voidtreeList1_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e) { TreeList node = sender as TreeList;if (e.Node == node.FocusedNode){ e.Graphics.FillRectangle(SystemBrushes. Window, e.Bounds); Rectangle r = new Rectangle(e.EditViewInfo.ContentRect.Left,e.EditViewInfo.ContentRect.Top,Convert.ToInt32(e.Graphics.MeasureString(e.CellText, treeList1.Font).Width + 1),Convert.ToInt32(e.Graphics.MeasureString(e.CellText,treeList1. Font).Height));e.Graphics.FillRectangle(SystemBrushes.Highlight, r);e.Graphics.DrawString(e.CellText, treeList1.Font, SystemBrushes.HighlightText, r);e.Handled = true; } }//============================================= ===============================//===============================以下内容为收集===============================//============================================= =============================== 一、改变grid的样式。

第三方控件的安装与卸载

第三方控件的安装与卸载

BCB6开发经验谈—第三方控件的安装与卸载写下此文章是为了那些还还没有接触过第三方控件的,而又为第三方控件的安装与卸载而烦恼的开发人员。

就我所了解与使用过的有Raize、DevExpress、SuiPack、DBGridEh、FastReport等。

而如何正确的安装与卸载呢?并不像windows的安装程序与卸载那么傻瓜化。

如果是傻瓜化的安装与卸载,那就没必要写下这遍文章指导初学者。

以前刚接触第三方控件时,也曾为安装某一控件使用,又过一段时间将其卸载后,重新新建一个工程就编译不过了而感到烦恼。

第三方控件的安装相对简单一点,像Raize控件,就一个RC.exe文件就可以安装。

DevExpress相对麻烦一点,现在都有一个Auto-Installor自动安装。

在这里主要讲的是卸载第三方控件。

第三方控件的卸载,在BCB6中要经过三个步骤:(1)Remove Packages. 移除相应的软件包。

[1] 打开BCB6,然后File->Close All。

[2] Component->Install Packages…,然后选择要移除的软件包,点击Remove按钮。

(2)Remove Include Path/Lib Path/Palette Pages 移除Include/Lib/Pages信息。

[1] Project->Option->Directories/Conditionals->Include Path,去除要移除第三方控件的Include 路径。

[2] Project->Option->Directories/Conditionals->Lib Path,去除要移除第三方控件的Lib路径。

[3] Tools->Environment Options->Library,去除要移除第三方控件的Lib路径。

[4] Tools->Environment Options->Pallette->Pages,去除第三方控件的所有Page。

数据控件DataGridView添加、删除和修改数据库中的内容

数据控件DataGridView添加、删除和修改数据库中的内容

数据控件DataGridView添加、删除和修改数据库中的内容作者:天涯来源:中国自学编程网发布日期:1214063638介绍一个数据控件DataGridView,它是 3.5中新增加的的重要控件。

它是一种网格形式的控件,能以表格的形式显示数据,它的优势是能多行显示数据,在数据库的操作中会经常用到。

(1)打开VS2008,在D:\C#\ch14目录下建立名为DataGridViewTest的Windows应用程序,打开工程,为当前窗体添加控件,如表14-2所示。

表14-2 添加控件列表控件名NameTextDataGridViewdataGridView1ButtonbtnRef更新设置ButtonbtnDelete删除(2)接下来需要设置DadaAdapter和DataSet,方法同上一节一样。

选中DataGridView的DataSource属性。

(3)单击“下一步”按钮,选择“数据连接”图标。

(4)最后一步需要选择数据库对象,本例是要操作StudentInf数据库中的表,所以选择“表”复选框。

(5)设置完毕后,整个程序界面就设置完了。

程序界面设计完毕后,接下来要做的工作就是通过修改dataGridView1中的数据来更新数据库中的内容。

它实现的原理很简单,通过studentInfDataSet把dataGridView1绑定到Class1表,studentInfDataSet处于中间位置,所以在dataGridView1中修改的数据必须要传递到studentInfDataSet后才能改变数据库中的内容。

(1)双击“更新设置”按钮,添加如下代码。

this.sqlDataAdapter1.Update(this.studentInfDataSet);该代码的功能是调用sqlDataAdapter1的Update()方法实现对studentInfDataSet的更新。

(2)按F5键,程序运行以后,对dataGridView1添加一行新的数据,然后单击“更新设置”按钮,完成后关闭程序再打开。

二维码生成(中、日、英)(DotNetBarcode第三方控件)

二维码生成(中、日、英)(DotNetBarcode第三方控件)
声明并赋 值生成的 二维码保 存的图片 4 的边长 Dim myFileLe ngth As Integer = "1"
给需要转 换的字符 5 串赋值 BarcodeN umber = "はいは いはいは いはい" BarcodeN umber = "的辐的 辐动的辐 动的辐动 动" BarcodeN umber = "1234556 6"
二、下面 是完整实 例代码
'声明二 维码的实 例变量
Dim bc1 As DotNetBa rcode = New DotNetBa rcode(Do tNetBarc ode.Type s.QRCode )
'声明需 要转换成 二维码的 字符串
Dim BarcodeN umber As String
二维码生 成(中、 日、英) (DotNet Barcode 第三方控 件)调查 如下 一、需设 置以下参 数(下面 的大写红 色参数可 写入配置 文件中)
声明二维 码的实例 1 变量 Dim bc1 As DotNetBa rcode = New DotNetBa rcode(Do tNetBarc ode.Type s.QRCode )
'声明并 赋值生成 的二维码 存放的路 径
Dim myFileNa me As String = "D:\Docu ments and Settings \twqian\ 桌面 \11111.b mp"
'声明并 赋值生成 的二维码 保存的图 片的边长
Dim myFileLe ngth As Integer = "12"
'给需要 转换的字 符串赋值

第25章DotNET常用控件操作3

第25章DotNET常用控件操作3

相关代码如下
第16页
Menu
<asp:menu id="NavigationMenu" disappearafter="2000" staticdisplaylevels="2" staticsubmenuindent="10" orientation="Horizontal" font-names="Arial" target="_blank" runat="server"> <staticmenuitemstyle backcolor="#DDDDDD" forecolor="red"/> <statichoverstyle backcolor="#DDDDDD"/> <dynamicmenuitemstyle backcolor="#EEEEEE" forecolor="red"/> <dynamichoverstyle backcolor="#DDDDDD" forecolor="Black"/> <items> <asp:menuitem navigateurl="/" text="首页" tooltip="首页"> <asp:menuitem navigateurl="/ShowList.aspx?id=1" text=" 栏目" tooltip=" 栏目"> <asp:menuitem navigateurl="Classical.aspx" text=" 最新文章" tooltip=" 最新文章"/> <asp:menuitem navigateurl="Rock.aspx" text=" 问与答" tooltip=" 问与答">

控件的使用实验报告

控件的使用实验报告

一、实验目的1. 熟悉常见控件的功能和使用方法。

2. 学习控件在应用程序中的布局和事件处理。

3. 提高编程实践能力。

二、实验环境1. 操作系统:Windows 102. 开发工具:Visual Studio 20193. 编程语言:C#三、实验内容本次实验主要使用Windows窗体应用程序进行控件的使用,具体内容包括:1. 控件的创建和添加2. 控件的属性设置3. 控件的布局4. 控件的事件处理四、实验步骤1. 创建Windows窗体应用程序(1)打开Visual Studio 2019,选择“创建新项目”。

(2)在“创建新项目”对话框中,选择“Windows窗体应用程序”,命名为“控件实验”。

(3)点击“创建”按钮,完成应用程序的创建。

2. 添加控件(1)在工具箱中找到所需控件,例如:文本框(TextBox)、按钮(Button)、标签(Label)等。

(2)将控件拖拽到窗体上,即可添加控件。

3. 设置控件属性(1)选中控件,在属性窗口中查看和修改控件的属性。

(2)例如,设置文本框的Text属性为“请输入内容”,设置按钮的Text属性为“提交”。

4. 控件布局(1)使用布局工具对控件进行布局,例如:使用水平布局、垂直布局、网格布局等。

(2)调整控件的大小和位置,使界面美观。

5. 控件事件处理(1)双击控件,打开代码编辑器。

(2)在事件处理函数中编写代码,实现所需功能。

(3)例如,在按钮的点击事件中,获取文本框的值并显示在标签中。

五、实验结果与分析1. 创建了包含文本框、按钮、标签的Windows窗体应用程序。

2. 添加并设置了控件的属性。

3. 对控件进行了布局,使界面美观。

4. 编写了按钮点击事件处理函数,实现了获取文本框值并显示在标签中的功能。

六、实验总结通过本次实验,我掌握了以下内容:1. 常见控件的功能和使用方法。

2. 控件在应用程序中的布局和事件处理。

3. 提高了编程实践能力。

在实验过程中,我发现以下问题:1. 对部分控件属性设置不够熟悉,需要加强学习。

Dotnetbar的使用方法

Dotnetbar的使用方法

DOTNETBAR的使用方法我这里讨论的版本是DotNetBar 6.7.0.1 for VS2005的破解版本,其他版本我一个是没有时间找到,另外也是因为大同小异下载地址,见这里,如果还有哪个朋友下载不了,就加我QQ吧,如果你能提供一个群,我会写在这里,然后利用群空间来整理控件,方便你我下载地址是/soft/show.asp?id=2879&showasp=1&details.html在VS2005中的添加方法与IRISSKIN2类似,不过我这里再说一次:先把控件拷到你的程序BIN/Debug下,再到程序里,先引用,然后再工具栏新个一个选项,然后右键选择“选择项”菜单,在这个对话框里点浏览,里把这个DLL重新添加进来,这样,就可以把控件加到先项框里,接下来就是把控件拖到界面上,在代码里加上上面的说明的代码,就可以使用了。

有好几十个空间,可以把你的程序装扮成office2007。

很COOL!这里转几篇使用的日志:1----------------------------------------------------- DotNetBar的SuperTooltip控件使用技巧DotNetBar是一个顶尖的.net第三方表示层空间。

作出来的窗口可以说是非常非常非常的cool!SuperTooltip控件主要可以用于实现提示框。

在它提供的sample 中,实现了树视图中,鼠标移动到树节点上时显示的提示框。

我的一个项目中用到了树视图,在项目完成以后我决定把它用DotNetBar美化一下。

在参考着sample的代码对我的代码进行修改和调试的过程中,我发现sample 的代码并不是拿来用就行了的,还是需要理解以后进行修改。

按照sample的代码,假设我们的Form Form1中有控件TreeView treeView1,那么为treeView1实现提示框的方法如下:(我没用窗口编辑器,只修改代码来着)1在项目的引用中添加DevComponents.DotNetBar。

asp.net常用的第三方控件-shuanghusun的专栏-CSDN博客

asp.net常用的第三方控件-shuanghusun的专栏-CSDN博客

常用的第三方控件-shuanghusun的专栏-CSDN博

分页控件,文本编辑器,皮肤控件
DYLIKEBUTTON:超稳定按钮皮肤控件
DYD.DLL :一句代码实现透明PNG窗体
WORKINGMASK :动态透明忙碌遮罩控件
MPB.DLL :超酷动态仿MAC进度条控件
一般来说,我们就用"FCKeditor"这个就可以了。

里面的界面可以通过一个js来控制,你可以找一下那个js文件,名字好像叫fckconfig.js。

用法很简单,就跟一个文本框一样。

推荐FreeTextBox,在工具箱添加控件FreeTextBox.dll即可,然后像使用普通控件一样,拖放.
一般用freetextbox和DotNetT extBox,还有FCKeditor 也常用,
推荐你用Dotnettextbox,我用过那个,感觉功能挺好的,配置也容易,因为这是一个成熟的商业软件,有很详细的帮助文档教你怎么用,而且还有免费版本
本文来自CSDN博客,转载请标明出处:/shuanghusun/archive/2010/07/17/5742692 .aspx。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

DotNet第三方控件使用笔记0、1)ButtonX控件可实现如下效果:在ButtonX上,是否显示“图像,取决于“images“属性2)在“buttomItem“控件中,是否“只是显示图像”,”只是文本”,还是“图像和文本都显示”,取决于1、BalloonTio控件(气泡提示)(1)使用效果1)效果一:在鼠标在控件上面停留时,出现提示信息,如下图:2)效果二:当控件获得焦点时,也出现如上图一样的信息。

(2)实现上述两种效果的途径1)将BalloonTip控件的“ShowBalloonOnFacus”属性设置为“False”即可实现,效果一。

2)将“ShowBalloonOnFacus”属性设置为“True”,即可实现效果二。

(3)设置BalloonTip显示的内容:在欲设置该属性的控件的“BalloonTioOnFocus上的BalloonCaption”和“BalloonTioOnHover上的BalloonCaption”属性中,分别设置这两种效果的“标题”属性;在“BalloonTioOnFocus上的BalloonText”和在“BalloonTioOnHover上的BalloonText”属性中,分别设置这两种效果的“显示内容”的属性。

(4)属性“AlerAnimation”设置“BalloonTip”出现的效果,(5)“BalloonTip”除了出现在该控件附近,还可以出现在屏幕的右下角,示例程序如下:private AlertCustom m_AlertOnLoad=null;m_AlertOnLoad=new AlertCustom();Rectangle r=Screen.GetWorkingArea(this);m_AlertOnLoa d.Location=newPoint(r.Right-m_AlertOnLoad.Width,r.Bottom-m_AlertOnLoad.Height);m_AlertOnLoad.AutoClose=true;m_AlertOnLoad.AutoCloseTimeOut=15;m_AlertOnLoad.AlertAnimation=eAlertAnimation.BottomToTop;m_AlertOnLoad.AlertAnimationDuration=300;m_AlertOnLoad.Show(false);//false::指示该控件是否需要获得焦点才出现“BalloonTip”(6)“BalloonTip”除了可以通过“添加控件”的方式使用,也可以通过编程的方式使用,示例程序如下:DevComponents.DotNetBar.Balloon b=new DevComponents.DotNetBar.Balloon();b.Style=eBallonStyle.Alert;b.CaptionImage=balloonTipFocus.CaptionImage.Clone() as Image;b.CaptionText="Balloon Status Information";b.Text="Balloons are now enabled for Balloon Tip Test area. Hover mouse overthe area and set the focus to any control.";b.AlertAnimation=eAlertAnimation.TopToBottom;b.AutoResize();b.AutoClose=true;b.AutoCloseTimeOut=4;b.Owner=this;//指示父控件b.Show(button2,false);//button2::指示在那个控件附近出现“BalloonTip”(7)还可以对“BalloonTip”出现时的效果进行程序控制,如下:// BalloonTriggerControl property returns control that invoked balloon// BalloonTriggerControl属性返回触发“BalloonTip”的控件if(balloonTipHover.BalloonTriggerControl==groupBox1){// BalloonControl is already prepared Balloon control that is just about to be displayed // Setting BalloonControl to null will cancel balloon displayPoint p=Control.MousePosition;// Adjust cursor position so cursor is below tipp.Offset(-balloonTipHover.BalloonControl.TipOffset,balloonTipHover.BalloonControl.TipLength+ 4);//Offset属性将点p进行平移balloonTipHover.BalloonControl.Location=p;}(8)与之类似的是DotNetToolTip所有控件都有的“ToolTip”属性,也可以是控件在鼠标划过时出现类似的东西,如下图2、DotNetBarManager控件与Bar控件的使用示例效果如下图:(1)DotNetBarManager控件----将该控件添加到工程后,将给Bar控件提供了“停靠点(DockSite)”,可以实现是工具栏在窗体的“上、下、左、右“摆放。

可以通过程序实现,也可以通过“属性页“的”Dock“属性进行设置。

bar.DockSide = eDockSide.Top;(2)DotNetBarManager控件,通过右键菜单可以轻松实现如下图所示的布局。

通过拖动也可以轻易的实现如下视图的布局与上图相应的代码:// Create new document and add it to existing barDevComponents.DotNetBar.DockContainerItem dockItem=new DevComponents.DotNetBar.DockContainerItem();dockItem.Text="Custom Document";// Add control to itTextBox t=new TextBox();t.AutoSize=false;t.Multiline=true;t.Text=dockItem.Text;// PanelDockContainer will be used to host any controls. It provides automatic focus management so focused// document tab appears boldDevComponents.DotNetBar.PanelDockContainer panel = new DevComponents.DotNetBar.PanelDockContainer();t.Dock = DockStyle.Fill;panel.Controls.Add(t);dockItem.Control=panel;bar1.Items.Add(dockItem);if(!bar1.Visible)bar1.Visible=true;elsebar1.RecalcLayout();// Optimize display by disabling layout for all dock sitesdotNetBarManager1.SuspendLayout=true;try{foreach(DevComponents.DotNetBar.Bar bar in dotNetBarManager1.Bars){if(bar.DockSide==DevComponents.DotNetBar.eDockSide.Document){foreach(DevComponents.DotNetBar.DockContainerItem dock in bar.Items)dock.Visible=true;}if(!bar.Visible)bar.Visible=true;}}finally{dotNetBarManager1.SuspendLayout=false;}(2×)下面的代码通过编程的方式实现如下图所示的功能private void Form1_Load(object sender, System.EventArgs e){dotNetBarManager1.DockTabChange+=newDotNetBarManager.DockTabChangeEventHandler(this.DockTabChanged);CreateBottomBarAutoHide();CreateLeftDockedBars();}private void DockTabChanged(object sender, DockTabChangeEventArgs e){// Sync caption of the bar with the currently selected dock tabBar bar=sender as Bar;if(bar==null || e.NewTab==null)return;bar.Text=e.NewTab.Text;}private void CreateBottomBarAutoHide(){Bar bar=new Bar("Bottom Bar in auto-hide state");="bottomBar";youtType=eLayoutType.DockContainer; // Dock Container Layout needed for dockable windows bar.Stretch=true; // Dockable windows stretch to fill containerbar.AutoHideAnimationTime=0; // Some controls do not support animation so turn it offbar.GrabHandleStyle=eGrabHandleStyle.Caption; // Dockable Windows have captions dotNetBarManager1.Bars.Add(bar); // DotNetBar needs to be aware of the bar so it can manage it's docking etc.// Create hosted controlsDockContainerItem dockItem=new DockContainerItem("bottomDockItem1","First dock item");bar.Items.Add(dockItem);// Create control that we want to host on dockable windowUserControl1 dockedControl=new UserControl1();bel1.Text=+" - "+dockItem.Text;dockedControl.BackColor=Color.Azure;dockItem.Control=dockedControl; // Specify that control is hosted on the dock container dockItem.Height=128; // Specify the height of the dockable container and at the same time control// Create second dock container and add it to the bardockItem=new DockContainerItem("bottomDockItem2","Second dock item");bar.Items.Add(dockItem);dockedControl=new UserControl1();bel1.Text=+" - "+dockItem.Text;dockedControl.BackColor=Color.Aquamarine;dockItem.Control=dockedControl; // Specify that control is hosted on the dock container// Dock bar to bottom dock sitedotNetBarManager1.BottomDockSite.GetDocumentUIManager().Dock(bar);dockItem.Height=128; // Specify the height of the dockable container and at the same time controlbar.RecalcLayout(); // Apply all changes...bar.AutoHide=true; // Place bar in auto-hide mode. Bar needs to be docked before it can be places in auto-hide mode}private void CreateLeftDockedBars(){// Dock first two bars side by side and dock third bar next to them...Bar bar=new Bar("Bar1");="leftBar1";youtType=eLayoutType.DockContainer; // Dock Container Layout needed for dockable windows bar.Stretch=true; // Dockable windows stretch to fill containerbar.AutoHideAnimationTime=0; // Some controls do not support animation so turn it offbar.GrabHandleStyle=eGrabHandleStyle.Caption; // Dockable Windows have captionsbar.CanHide=true;// Create DockContainerItem for the bar. The item should be added before the bar is docked. DockContainerItem dockItem=new DockContainerItem("leftDockItem1","Top Left Dock Container"); bar.Items.Add(dockItem);// Create control that is hosted on dock containerUserControl1 dockedControl=new UserControl1();bel1.Text=+" - "+dockItem.Text;dockedControl.BackColor=Color.Khaki;dockItem.Control=dockedControl; // Specify that control is hosted on the dock containerdotNetBarManager1.Bars.Add(bar); // DotNetBar needs to be aware of the bar so it can manage it's docking etc.dotNetBarManager1.LeftDockSite.GetDocumentUIManager().Dock(bar); //Performs actual docking of the Bar to the specified dock sitedockItem.Width=128; // Specify Width of dock container item after it is docked// Create second bar and dock it below the first bar but still on the same lineBar bar2=new Bar("Bar2");="leftBar2";youtType=eLayoutType.DockContainer; // Dock Container Layout needed for dockable windowsbar2.AutoHideAnimationTime=0; // Some controls do not support animation so turn it offbar2.Stretch=true; // Dockable windows stretch to fill containerbar2.CanHide=true;bar2.GrabHandleStyle=eGrabHandleStyle.Caption; // Dockable Windows have captions// Add new Dock Container to the bar, should be done before adding the bar so size can be calculated properlydockItem=new DockContainerItem("leftDockItem2","Bottom Left Dock Container");bar2.Items.Add(dockItem);// Create control that is hosted on dock containerdockedControl=new UserControl1();bel1.Text=+" - "+dockItem.Text;dockedControl.BackColor=vender;dockItem.Control=dockedControl; // Specify that control is hosted on the dock container dotNetBarManager1.Bars.Add(bar2); // DotNetBar needs to be aware of the bar so it can manage it's docking etc.dotNetBarManager1.LeftDockSite.GetDocumentUIManager().Dock(bar, bar2, eDockSide.Bottom); // Dock new bar2 below the bar that we created previously// Create third bar that is docked next to the first and second// i.e. on the line 1bar=new Bar("Bar3");="leftBar3";youtType=eLayoutType.DockContainer; // Dock Container Layout needed for dockable windows bar.AutoHideAnimationTime=0; // Some controls do not support animation so turn it offbar.Stretch=true; // Dockable windows stretch to fill containerbar.CanHide=true;bar.GrabHandleStyle=eGrabHandleStyle.Caption; // Dockable Windows have captionsdockItem=new DockContainerItem("leftDockItem3","Left Dock Container line 1");bar.Items.Add(dockItem);// Create control that is hosted on dock containerdockedControl=new UserControl1();bel1.Text=+" - "+dockItem.Text;dockedControl.BackColor=Color.LemonChiffon;dockItem.Control=dockedControl; // Specify that control is hosted on the dock container dotNetBarManager1.Bars.Add(bar); // DotNetBar needs to be aware of the bar so it can manage it's docking etc.dotNetBarManager1.LeftDockSite.GetDocumentUIManager().Dock(bar);// Setting the width of the dock site will also scale the bars docked inside,// however the size should be large enough to accomodate all bars including the constraints like MinimumSize etc.dotNetBarManager1.LeftDockSite.Width = 150;}BaseItem::Defines the base class for items that are used by DotNetBar示例:BaseItem item = sender as BaseItem;(3)添加“菜单项“也可以通过两种方式实现1)“可视化“的方式在“设计器“里可以通过”右键“来实现;2)程序的方法private void CreateBar(){// Create a new Bar//创建BarBar bar=new Bar("Standard");bar.CanHide=true;bar.Style=eDotNetBarStyle.Office2003;bar.GrabHandleStyle=eGrabHandleStyle.StripeFlat;bar.WrapItemsDock=true;bar.WrapItemsFloat=false;// Add Items to it//向Bar内添加项ButtonItem item, fileItem;// New添加新建item=new ButtonItem("bNew");-----------------------------------------------------item.ImageIndex=0;// item.Image = imageList1.Images[0];-------------------------------------------------item.Text="&New";item.Shortcuts.Add(eShortcut.CtrlN);item.Category="Standard";bar.Items.Add(item);m_DotNetBar.Items.Add(item.Copy()); // This will create Category Entry// Openitem=new ButtonItem("bOpen");item.ImageIndex=1;item.Text="&Open";item.Shortcuts.Add(eShortcut.CtrlO);item.Category="Standard";bar.Items.Add(item);m_DotNetBar.Items.Add(item.Copy());// Add Sub items to the Open, something like recently used files... fileItem=new ButtonItem("file1");fileItem.Text="&1. File1.txt";item.SubItems.Add(fileItem);fileItem=new ButtonItem("file2");fileItem.Text="&2. File2.txt";item.SubItems.Add(fileItem);fileItem=new ButtonItem("file3");fileItem.Text="&3. File3.txt";item.SubItems.Add(fileItem);fileItem=new ButtonItem("file4");fileItem.Text="&4. File4.txt";item.SubItems.Add(fileItem);fileItem=new ButtonItem("file5");fileItem.Text="&5. File5.txt";item.SubItems.Add(fileItem);// Closeitem=new ButtonItem("bClose");item.ImageIndex=2;item.Text="&Close";item.Shortcuts.Add(eShortcut.CtrlX);item.Category="Standard";bar.Items.Add(item);m_DotNetBar.Items.Add(item.Copy());// Saveitem=new ButtonItem("bSave");item.ImageIndex=3;item.Text="&Save";item.Shortcuts.Add(eShortcut.CtrlS);item.Category="Standard";bar.Items.Add(item);m_DotNetBar.Items.Add(item.Copy());// Print Previewitem=new ButtonItem("bPrintPreview");item.ImageIndex=6;item.Text="Print Pre&view";item.Category="Standard";item.BeginGroup=true;bar.Items.Add(item);m_DotNetBar.Items.Add(item.Copy());// Printitem=new ButtonItem("bPrint");item.ImageIndex=5;item.Text="&Print";item.Category="Standard";item.Shortcuts.Add(eShortcut.CtrlP);bar.Items.Add(item);m_DotNetBar.Items.Add(item.Copy());// E-Mailitem=new ButtonItem("bEmail");item.ImageIndex=4;item.Text="&Email";item.Category="Standard";item.BeginGroup=true;bar.Items.Add(item);m_DotNetBar.Items.Add(item.Copy());// Customize Item添加“添加/删除“按钮CustomizeItem citem=new CustomizeItem();bar.Items.Add(citem);// Since we will be using ImageList bar have to be added to the DotNetBar Manager //将Bar加入DotNetBar Managerm_DotNetBar.Bars.Add(bar);bar.DockSide=eDockSide.Top;}(4)为所有选项添加“事件“this.m_DotNetBar.ItemClick += new System.EventHandler(this.BarItemClick);-----------------------------------------------------------------private void BarItemClick(object sender, EventArgs e){BaseItem item = sender as BaseItem;if (item == null || == "" || item.SystemItem)return;MessageBox.Show("Item '" + + "' clicked");}(4)//设置窗体的大小AutoScaleBaseSize属性的值在窗体显示时使用,用来计算该窗体的缩放因子。

相关文档
最新文档