DevExpress 控件用法笔记(VB)

1、ChartControl

显示条形图

            ChartControl1.Titles.Clear()
            ChartControl1.Series.Clear()
            Dim db As DataTable
            SqlDataAdapter1.SelectCommand.CommandText =sqlstr
            db = New DataTable
            SqlDataAdapter1.Fill(db)
            Dim series1 As DevExpress.XtraCharts.Series = New DevExpress.XtraCharts.Series("", ViewType.Line)
            series1.DataSource = db‘绑定数据源
            series1.ArgumentDataMember = "TimeStep" 'X轴显示字段
            series1.ValueDataMembers(0) =cbPara.Text ‘Y轴显示字段
            series1.Name = cbPara.Text ’图例名称
            ChartControl1.Series.Add(series1)
            '标题
            Dim chartTitle1 As New ChartTitle()
            chartTitle1.Text = cbPara.SelectedItem & "浓度变化曲线"
            chartTitle1.Antialiasing = True
            chartTitle1.Font = New Font("Tahoma", 14, FontStyle.Regular)
            chartTitle1.TextColor = Color.Black
            chartTitle1.Indent = 10
            ChartControl1.Titles.Add(chartTitle1)
'添加x,y轴标题
Dim diam As DevExpress.XtraCharts.XYDiagram = New DevExpress.XtraCharts.XYDiagram
diam.AxisX.Title.Text = "mg/L"
diam.AxisY.Title.Text = ""
diam.AxisX.Title.Visible = True
diam.AxisY.Title.Visible = True
ChartControl1.Diagram = diam

 

 ’自定义标注 Y轴
xydiagram.AxisY.CustomLabels.AddRange({New CustomAxisLabel("一类", 1), New CustomAxisLabel("二类", 2), New CustomAxisLabel("三类", 3), New CustomAxisLabel("四类", 4), New CustomAxisLabel("五类", 6), New CustomAxisLabel("劣五类", 6)})

 

效果如下:

2、   GridControl

绑定代码如下:

GridControl1.DataSource = db  'db是DataTable对象

自定义字段显示如下图:

 

去掉GroupPanel如下图所示:

3、   WinForm的ComboBox自定义绑定数据

自已定义一个RiverData类的代码:

 

    Public Class RiverData
        Dim m_riverName As String
        Dim m_riverId As String
        Dim m_evtsimId As String

        Public Property RiverName
            Get
                Return m_riverName
            End Get
            Set(ByVal value)
                m_riverName = value
            End Set
        End Property

        Public Property RiverId
            Get
                Return m_riverId
            End Get
            Set(ByVal value)
                m_riverId = value
            End Set
        End Property

        Public Property EvtSimId
            Get
                Return m_evtsimId
            End Get
            Set(ByVal value)
                m_evtsimId = value
            End Set
        End Property


    End Class

 

绑定数据的代码如下:

  Dim m_river As RiverData = New RiverData
        m_river.RiverName = tName
        m_river.RiverId = tRiver
        cbSec.Items.Add(m_river)
        cbSec.DisplayMember = "RiverName"
        cbSec.ValueMember = "RiverId"

 4、LabelControl

设置AutoSizeMode的属性为Vertical,适当的Size,就可以实现文本的换行。

5、NavBarControl

 

        For i As Integer = 0 To dt.Rows.Count - 1 Step 1
            Dim NavBarGroup1 As DevExpress.XtraNavBar.NavBarGroup = New DevExpress.XtraNavBar.NavBarGroup '创建分组栏
            NavBarGroup1.Caption = dt.Rows(i)(0).ToString()
            NavBarGroup1.Name = "NavBarGroup" + i.ToString()
            '站点信息
            Dim navBarGroupControlContainer1 As NavBarGroupControlContainer = New NavBarGroupControlContainer '创建容器面板
            For j As Integer = 1 To 9 Step 1
                Dim lable1 As DevExpress.XtraEditors.LabelControl = New DevExpress.XtraEditors.LabelControl
                lable1.Location = New System.Drawing.Point(13, 24 * j - 8)
                Select Case j
                    Case 1
                        lable1.Text = "XX: "
                        lable1.Location = New System.Drawing.Point(13, 10)
                    Case 2
                        lable1.Text = "XX:   "
                    Case 3
                        lable1.Text = "XX:     "
                    Case 4
                        lable1.Text = "XX: "
                    Case 5
                        lable1.Text = "XX: "
                    Case 6
                        lable1.Text = "XX:   "
                    Case 7
                        lable1.Text = "XX:    "
                    Case 8
                        lable1.Text = "XX:   "
                    Case 9
                        lable1.Text = "XX:   "
                End Select
                lable1.Text += dt.Rows(i)(j).ToString()
                lable1.Name = "Lb_Title" + j.ToString
                lable1.Size = New System.Drawing.Size(37, 13)
                navBarGroupControlContainer1.Controls.Add(lable1) '容器面板添加Lable
            Next
            '创建内容面板
            navBarGroupControlContainer1.Size = New System.Drawing.Size(235, 200)
            navBarGroupControlContainer1.ResumeLayout(False)
            navBarGroupControlContainer1.PerformLayout()
            NavBarGroup1.ControlContainer = navBarGroupControlContainer1
            NavBarControl1.Controls.Add(navBarGroupControlContainer1)
            NavBarControl1.Groups.Add(NavBarGroup1)
        Next

效果图如下:

6、ImageComboBoxEdit 用法

 

 ImageComboBoxItem icbi = new ImageComboBoxItem();
 icbi.Description ="aa";
 icbi.Value =0;
 ImgComBox_Layers.Properties.Items.Add(icbi);
 ImgComBox_Layers.EditValue = 0;

 7、AllowFormGlass属性设置窗体的时候,使用的是RibbonForm窗体,但是标题栏没有DEV的样式效果,如下图:

但是demo上有dev效果,如下图:

后来对比发现是主窗体设计代码少了一行代码所致:

  Me.AllowFormGlass = DevExpress.Utils.DefaultBoolean.[False]

dev帮助文档解释如下:

获取或设置窗体的标题和边框是否根据本地的Windows主题。

注意:如果加上上面代码,添加ArcEngine控件的时候,调试程序会报错->“未将对象引用到对象的实例”,具体问题原因还没有找到,应该是个Bug,解决办法:将ArcEngine控件放在Panel控件上就可以了。

 8、For循环

 

 For i As Integer = 0 To m_ZoomPopupMenu.ItemLinks.Count - 1
                     If TypeOf pItem Is DevExpress.XtraBars.BarButtonItem Then
                          End If
        Next

 9、动态生成DockPanel

执行代码前:

执行代码后:

生成DockPanel的代码:

      Dim QuikeSearchDock As DockPanel = MainFrom.MainDockManager.AddPanel(DockingStyle.Bottom)
      QuikeSearchDock.Show()
      If QuikeSearchDock.RootPanel IsNot QuikeSearchDock Then
        QuikeSearchDock.DockAsTab(QuikeSearchDock.RootPanel)
      Else
        Dim container As DockPanel = Nothing
        For Each container In MainFrom.MainDockManager.RootPanels
          If container.Dock = DockingStyle.Bottom Then
            container.Index = 0 '显示新添加的tap
            Exit For
          End If
        Next
        If container IsNot Nothing Then
          QuikeSearchDock.DockAsTab(container)
        End If
        QuikeSearchDock.Dock = DevExpress.XtraBars.Docking.DockingStyle.Fill
        QuikeSearchDock.Text = title

 10、TreeList

TreeList的节点也可以分列显示,所以在使用的时候先要添加列,如下图所示,右键控件,点击Run Designer

然后就可以编写代码了

 

 Public Function LoadControl(ByVal ErrFacs As List(Of ErrorFactor))
    For i As Integer = 0 To ErrFacs.Count - 1
      Dim errfac As ErrorFactor = ErrFacs(i)
      Dim errnode As TreeListNode = TreeList1.Nodes.Add(errfac.ErrName, Nothing)
      TreeList1.AppendNode(New Object() {errfac.ErrFieldName}, errnode)
      TreeList1.AppendNode(New Object() {errfac.ErrDescription}, errnode)
    Next
  End Function

 ShowIndicator属性,是否显示指示器

设置前:

设置前效果:

设置后:

设置后效果:

 11、XtraForm

继承XtraForm 需要添加如下引用:

 

posted on 2016-02-15 18:40  Geography爱好者  阅读(3458)  评论(0编辑  收藏  举报

导航