WinForm DotNetBar 动态添加DataGridView

时间:2022-05-14 07:37:50

DataGridView dgv = new DataGridView();
dgv.Dock = DockStyle.Fill;
dgv.Location = new System.Drawing.Point(0, 0);
dgv.Size = new System.Drawing.Size(794, 69);
dgv.BackgroundColor = Color.White;
//DataSet ds = new DataSet();
//ds.Tables.Add(dt);
dgv.DataSource = dt.DefaultView;

PanelDockContainer panelDockContainerResult = new PanelDockContainer();
panelDockContainerResult.Size = new System.Drawing.Size(794, 69);
panelDockContainerResult.Name = "panelDockContainerResult";
panelDockContainerResult.Controls.Add(dgv);

DockContainerItem dockContainerItemResult = new DockContainerItem();
dockContainerItemResult.Name = "Result";
dockContainerItemResult.Text = "分析结果:" + text;
dockContainerItemResult.Control = panelDockContainerResult;

Bar barResult = new Bar();
barResult.AccessibleDescription = "DotNetBar Bar (barResult)";
barResult.AccessibleName = "DotNetBar Bar";
barResult.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
barResult.AutoSyncBarCaption = true;
barResult.CloseSingleTab = true;
barResult.Controls.Add(panelDockContainerResult);
barResult.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
barResult.GrabHandleStyle = DevComponents.DotNetBar.eGrabHandleStyle.Caption;
barResult.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {
dockContainerItemResult});
barResult.LayoutType = eLayoutType.DockContainer;
barResult.Location = new System.Drawing.Point(0, 3);
barResult.Name = "barResult";
barResult.Size = new System.Drawing.Size(800, 105);
barResult.Stretch = true;
barResult.Style = eDotNetBarStyle.Metro;
barResult.TabIndex = 0;
barResult.TabStop = false;
barResult.Text = "分析结果";

barResult.Style = eDotNetBarStyle.Metro;
//barResult.CanHide = true;
//barResult.CanDockBottom = true;

DockSite dockSiteResult = new DockSite();
dockSiteResult.Dock = DockStyle.Fill;
dockSiteResult.Controls.Add(barResult);
dockSiteResult.AccessibleRole = System.Windows.Forms.AccessibleRole.Window;
dockSiteResult.DocumentDockContainer = new DevComponents.DotNetBar.DocumentDockContainer(new DevComponents.DotNetBar.DocumentBaseContainer[] {
((DevComponents.DotNetBar.DocumentBaseContainer)(new DevComponents.DotNetBar.DocumentBarContainer(barResult, 800, 95)))}, DevComponents.DotNetBar.eOrientation.Vertical);
dockSiteResult.Location = new System.Drawing.Point(0, 289);
dockSiteResult.Name = "dockSiteResult";
dockSiteResult.Size = new System.Drawing.Size(800, 108);
dockSiteResult.TabIndex = 10;
dockSiteResult.TabStop = false;
//
this.dotNetBarManager1.BottomDockSite = dockSiteResult;
this.Controls.Add(dockSiteResult);

WinForm DotNetBar 动态添加DataGridView