DotNet第三方控件使用笔记1.docx
- 文档编号:8114650
- 上传时间:2023-01-28
- 格式:DOCX
- 页数:84
- 大小:802.19KB
DotNet第三方控件使用笔记1.docx
《DotNet第三方控件使用笔记1.docx》由会员分享,可在线阅读,更多相关《DotNet第三方控件使用笔记1.docx(84页珍藏版)》请在冰豆网上搜索。
DotNet第三方控件使用笔记1
DotNet第三方控件使用笔记
1)ButtonX控件
可实现如下效果:
在ButtonX上,是否显示“图像,取决于“images“属性
2)在“buttomItem“控件中,是否“只是显示图像”,”只是文本”,还是“图像和文本都显示”,取决于
2、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”除了出现在该控件附近,还可以出现在屏幕的右下角,示例程序如下:
privateAlertCustomm_AlertOnLoad=null;
m_AlertOnLoad=newAlertCustom();
Rectangler=Screen.GetWorkingArea(this);
m_AlertOnLoad.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.Balloonb=newDevComponents.DotNetBar.Balloon();
b.Style=eBallonStyle.Alert;
b.CaptionImage=balloonTipFocus.CaptionImage.Clone()asImage;
b.CaptionText="BalloonStatusInformation";
b.Text="BalloonsarenowenabledforBalloonTipTestarea.Hovermouseovertheareaandsetthefocustoanycontrol.";
b.AlertAnimation=eAlertAnimation.TopToBottom;
b.AutoResize();
b.AutoClose=true;
b.AutoCloseTimeOut=4;
b.Owner=this;//指示父控件
b.Show(button2,false);//button2:
:
指示在那个控件附近出现“BalloonTip”
(7)还可以对“BalloonTip”出现时的效果进行程序控制,如下:
//BalloonTriggerControlpropertyreturnscontrolthatinvokedballoon
//BalloonTriggerControl属性返回触发“BalloonTip”的控件
if(balloonTipHover.BalloonTriggerControl==groupBox1)
{
//BalloonControlisalreadypreparedBallooncontrolthatisjustabouttobedisplayed
//SettingBalloonControltonullwillcancelballoondisplay
Pointp=Control.MousePosition;
//Adjustcursorpositionsocursorisbelowtip
p.Offset(-balloonTipHover.BalloonControl.TipOffset,balloonTipHover.BalloonControl.TipLength+4);
//Offset属性将点p进行平移
balloonTipHover.BalloonControl.Location=p;
}
(8)与之类似的是DotNetToolTip所有控件都有的“ToolTip”属性,也可以是控件在鼠标划过时出现类似的东西,如下图
3、DotNetBarManager控件与Bar控件的使用
示例效果如下图:
(1)DotNetBarManager控件
----将该控件添加到工程后,将给Bar控件提供了“停靠点(DockSite)”,可以实现是工具栏在窗体的“上、下、左、右“摆放。
可以通过程序实现,也可以通过“属性页“的”Dock“属性进行设置。
bar.DockSide=eDockSide.Top;
(2)DotNetBarManager控件,通过右键菜单
可以轻松实现如下图所示的布局。
通过拖动也可以轻易的实现如下视图的布局
与上图相应的代码:
//Createnewdocumentandaddittoexistingbar
DevComponents.DotNetBar.DockContainerItemdockItem=newDevComponents.DotNetBar.DockContainerItem();
dockItem.Text="CustomDocument";
//Addcontroltoit
TextBoxt=newTextBox();
t.AutoSize=false;
t.Multiline=true;
t.Text=dockItem.Text;
//PanelDockContainerwillbeusedtohostanycontrols.Itprovidesautomaticfocusmanagementsofocused
//documenttabappearsbold
DevComponents.DotNetBar.PanelDockContainerpanel=newDevComponents.DotNetBar.PanelDockContainer();
t.Dock=DockStyle.Fill;
panel.Controls.Add(t);
dockItem.Control=panel;
bar1.Items.Add(dockItem);
if(!
bar1.Visible)
bar1.Visible=true;
else
bar1.RecalcLayout();
//Optimizedisplaybydisablinglayoutforalldocksites
dotNetBarManager1.SuspendLayout=true;
try
{
foreach(DevComponents.DotNetBar.BarbarindotNetBarManager1.Bars)
{
if(bar.DockSide==DevComponents.DotNetBar.eDockSide.Document)
{
foreach(DevComponents.DotNetBar.DockContainerItemdockinbar.Items)
dock.Visible=true;
}
if(!
bar.Visible)
bar.Visible=true;
}
}
finally
{
dotNetBarManager1.SuspendLayout=false;
}
(2×)下面的代码通过编程的方式实现如下图所示的功能
privatevoidForm1_Load(objectsender,System.EventArgse)
{
dotNetBarManager1.DockTabChange+=newDotNetBarManager.DockTabChangeEventHandler(this.DockTabChanged);
CreateBottomBarAutoHide();
CreateLeftDockedBars();
}
privatevoidDockTabChanged(objectsender,DockTabChangeEventArgse)
{
//Synccaptionofthebarwiththecurrentlyselecteddocktab
Barbar=senderasBar;
if(bar==null||e.NewTab==null)
return;
bar.Text=e.NewTab.Text;
}
privatevoidCreateBottomBarAutoHide()
{
Barbar=newBar("BottomBarinauto-hidestate");
bar.Name="bottomBar";
bar.LayoutType=eLayoutType.DockContainer;//DockContainerLayoutneededfordockablewindows
bar.Stretch=true;//Dockablewindowsstretchtofillcontainer
bar.AutoHideAnimationTime=0;//Somecontrolsdonotsupportanimationsoturnitoff
bar.GrabHandleStyle=eGrabHandleStyle.Caption;//DockableWindowshavecaptions
dotNetBarManager1.Bars.Add(bar);//DotNetBarneedstobeawareofthebarsoitcanmanageit'sdockingetc.
//Createhostedcontrols
DockContainerItemdockItem=newDockContainerItem("bottomDockItem1","Firstdockitem");
bar.Items.Add(dockItem);
//Createcontrolthatwewanttohostondockablewindow
UserControl1dockedControl=newUserControl1();
dockedControl.label1.Text=bar.Name+"-"+dockItem.Text;
dockedControl.BackColor=Color.Azure;
dockItem.Control=dockedControl;//Specifythatcontrolishostedonthedockcontainer
dockItem.Height=128;//Specifytheheightofthedockablecontainerandatthesametimecontrol
//Createseconddockcontainerandaddittothebar
dockItem=newDockContainerItem("bottomDockItem2","Seconddockitem");
bar.Items.Add(dockItem);
dockedControl=newUserControl1();
dockedControl.label1.Text=bar.Name+"-"+dockItem.Text;
dockedControl.BackColor=Color.Aquamarine;
dockItem.Control=dockedControl;//Specifythatcontrolishostedonthedockcontainer
//Dockbartobottomdocksite
dotNetBarManager1.BottomDockSite.GetDocumentUIManager().Dock(bar);
dockItem.Height=128;//Specifytheheightofthedockablecontainerandatthesametimecontrol
bar.RecalcLayout();//Applyallchanges...
bar.AutoHide=true;//Placebarinauto-hidemode.Barneedstobedockedbeforeitcanbeplacesinauto-hidemode
}
privatevoidCreateLeftDockedBars()
{
//Dockfirsttwobarssidebysideanddockthirdbarnexttothem...
Barbar=newBar("Bar1");
bar.Name="leftBar1";
bar.LayoutType=eLayoutType.DockContainer;//DockContainerLayoutneededfordockablewindows
bar.Stretch=true;//Dockablewindowsstretchtofillcontainer
bar.AutoHideAnimationTime=0;//Somecontrolsdonotsupportanimationsoturnitoff
bar.GrabHandleStyle=eGrabHandleStyle.Caption;//DockableWindowshavecaptions
bar.CanHide=true;
//CreateDockContainerItemforthebar.Theitemshouldbeaddedbeforethebarisdocked.
DockContainerItemdockItem=newDockContainerItem("leftDockItem1","TopLeftDockContainer");
bar.Items.Add(dockItem);
//Createcontrolthatishostedondockcontainer
UserControl1dockedControl=newUserControl1();
dockedControl.label1.Text=bar.Name+"-"+dockItem.Text;
dockedControl.BackColor=Color.Khaki;
dockItem.Control=dockedControl;//Specifythatcontrolishostedonthedockcontainer
dotNetBarManager1.Bars.Add(bar);//DotNetBarneedstobeawareofthebarsoitcanmanageit'sdockingetc.
dotNetBarManager1.LeftDockSite.GetDocumentUIManager().Dock(bar);//PerformsactualdockingoftheBartothespecifieddocksite
dockItem.Width=128;//SpecifyWidthofdockcontaineritemafteritisdocked
//Createsecondbaranddockitbelowthefirstbarbutstillonthesameline
Barbar2=newBar("Bar2");
bar2.Name="leftBar2";
bar2.LayoutType=eLayoutType.DockContainer;//DockContainerLayoutneededfordockablewindows
bar2.AutoHideAnimationTime=0;//Somecontrolsdonotsupportanimationsoturnitoff
bar2.Stretch=true;//Dockablewindowsstretchtofillcontainer
bar2.CanHide=true;
bar2.GrabHandleStyle=eGrabHandleStyle.Caption;//DockableWindowshavecaptions
//AddnewDockContainertothebar,shouldbedonebeforeaddingthebarsosizecanbecalculatedproperly
dockItem=newDockContainerItem("leftDockItem2","BottomLeftDockContainer");
bar2.Items.Add(dockItem);
//Createcontrolthatishostedondockcontainer
dockedControl=newUserControl1();
dockedControl.label1.Text=bar.Name+"-"+dockItem.Text;
dockedControl.BackColor=Color.Lavender;
dockItem.Control=dockedControl;//Specifythatcontrolishostedonthedockcontainer
dotNetBarManager1.Bars.Add(bar2);//DotNetBarneedstobeawareofthebarsoitcanmanageit'sdockingetc.
dotNetBarManager1.LeftDockSite.GetDocumentUIManager().Dock(bar,bar2,eDockSide.Bottom);//Docknewbar2belowthebarthatwecreatedpreviously
//Createthirdbarthatisdockednexttothefirstandsecond
//i.e.ontheline1
bar=newBar("Bar3");
bar.Name="leftBar3";
bar.LayoutType=eLayoutType.DockContainer;//DockContainerLayoutneededfordockablewindows
bar.AutoHideAnimationTime=0;//Somecontrolsdonotsupportanimationsoturnitoff
bar.Stretch=true;//Dockablewindowsstretchtofillcontainer
bar.CanHide=true;
bar.GrabHandleStyle=eGrabHandleStyle.Caption;//DockableWindowshavecaptions
dockItem=newDockContainerItem("leftDockItem3","LeftDockContainerline1");
bar.Items.Add(dockItem);
//Createcontrolthatishostedondockcontainer
dockedControl=newUserControl1();
dockedControl.label1.Text=bar.Name+"-"+dockItem.Text;
dockedControl.BackColor=Color.LemonChiffon;
dockItem.Control=dockedControl;//Specifythatcontrolishostedonthedockcontainer
dotNetBarManager1.Bars.Add(bar);//DotNetBarneedstobeawareofthebarsoitcanmanageit'sdockingetc.
dotNetBarManager1.LeftDockSite.GetDocumentUIManager().Dock(bar);
//Settingthewidthofthedocksitewillalsoscalethebarsdockedinside,
//howeverthesizeshouldbelargeenoughtoaccomodateallbarsincludingtheconstraintslikeMinimumSizeetc.
dotNetBarMana
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- DotNet 第三 控件 使用 笔记