Namespace BogartMis.Cls
    Public Class gGrid
        '設定表格控的列標題的別名
        '說明:strItem字符串的格式為"01,02,03,04,05" 其中[01]這個字符串中不得包含特定符號
        '特定符號: # / . - * 等
        Public Overloads Sub setGridColCaption(ByVal g As DataTable, ByVal strItem As String)
            Try
                Dim myArray As String() = Split(strItem.Trim, ",")
                Dim i As Integer
                For i = 0 To myArray.GetUpperBound(0)
                    g.Columns(i).ColumnName = myArray(i)
                Next
            Catch ex As Exception
            End Try
        End Sub

        Public Sub setAutoColumnsWidth(ByVal grid As C1.Win.C1TrueDBGrid.C1TrueDBGrid)
            Try
                With grid
                    Dim i As Integer
                    For i = 0 To .Columns.Count - 1
                        If .Splits(0).DisplayColumns(i).Visible = True Then
                            .Splits(0).DisplayColumns(i).AutoSize()
                        End If
                    Next
                End With
            Catch ex As Exception
            End Try
        End Sub

        Public Sub setAutoColumnsWidth(ByVal grid As myDataGrid.myDatagrid)
            Try
                With grid
                    Dim i As Integer
                    For i = 0 To .Columns.Count - 1
                        If .Splits(0).DisplayColumns(i).Visible = True Then
                            .Splits(0).DisplayColumns(i).AutoSize()
                        End If
                    Next
                End With
            Catch ex As Exception
            End Try
        End Sub

        Public Sub setReportStyle(ByVal grid As myDataGrid.myDatagrid)
            Try
                With grid
                    .AllowDelete = False
                    .AllowUpdate = False
                    .Splits(0).ExtendRightColumn = True
                    .MultiSelect = C1.Win.C1TrueDBGrid.MultiSelectEnum.Simple
                    .MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.HighlightRow
                    .BackColor = Color.WhiteSmoke
                    .EvenRowStyle.BackColor = Color.AliceBlue
                    .FilterBarStyle.BackColor = Color.PowderBlue
                    .FilterBar = True
                    .WindowLaguage = g.gLanguage
                    .Font = New System.Drawing.Font("Courier New", 9)
                End With
            Catch ex As Exception
            End Try
        End Sub

        Public Sub setEditStyle5(ByVal grid As myDataGrid.myDatagrid)       ''Add by Bendy on 2011/04/11
            Try
                With grid
                    .AllowDelete = True
                    .AllowSort = True
                    .Splits(0).AlternatingRowStyle = True
                    .EmptyRows = False
                    .BorderStyle = BorderStyle.Fixed3D
                    .HeadingStyle.BackColor = Color.DarkSeaGreen
                    .HeadingStyle.Borders.BorderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Flat
                    .RowDivider.Style = C1.Win.C1TrueDBGrid.LineStyleEnum.Single
                    .EvenRowStyle.BackColor = Color.AliceBlue
                    .BackColor = Color.Linen
                    .RecordSelectorStyle.BackColor = Color.LightGray
                    .RecordSelectorStyle.Borders.BorderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Groove
                    .TabAcrossSplits = True
                    .TabAction = C1.Win.C1TrueDBGrid.TabActionEnum.GridNavigation
                    .AllowAddNew = True
                    .AllowUpdate = True
                    .MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.HighlightRowRaiseCell
                    .FooterStyle = .HeadingStyle
                    .FlatStyle = C1.Win.C1TrueDBGrid.FlatModeEnum.Flat
                    .EmptyRows = False
                    .Splits(0).ExtendRightColumn = True
                    .Splits(0).AlternatingRowStyle = True
                    .WindowLaguage = g.gLanguage
                    .Font = New System.Drawing.Font("Courier New", 9)
                End With
            Catch ex As Exception
            End Try
        End Sub
        Public Sub setQueryStyle5(ByVal grid As myDataGrid.myDatagrid)       ''Add by Bendy on 2011/04/11
            Try
                With grid
                    .AllowDelete = False
                    .AllowSort = True
                    .Splits(0).AlternatingRowStyle = True
                    .EmptyRows = False
                    .BorderStyle = BorderStyle.Fixed3D
                    .HeadingStyle.BackColor = Color.DarkSeaGreen
                    .HeadingStyle.Borders.BorderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Flat
                    .RowDivider.Style = C1.Win.C1TrueDBGrid.LineStyleEnum.Single
                    .EvenRowStyle.BackColor = Color.AliceBlue
                    .BackColor = Color.Linen
                    .RecordSelectorStyle.BackColor = Color.LightGray
                    .RecordSelectorStyle.Borders.BorderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Groove
                    .TabAcrossSplits = True
                    .TabAction = C1.Win.C1TrueDBGrid.TabActionEnum.GridNavigation
                    .AllowAddNew = False
                    .AllowUpdate = False
                    .MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.HighlightRowRaiseCell
                    .FooterStyle = .HeadingStyle
                    .FlatStyle = C1.Win.C1TrueDBGrid.FlatModeEnum.Flat
                    .EmptyRows = False
                    .Splits(0).ExtendRightColumn = True
                    .Splits(0).AlternatingRowStyle = True
                    .WindowLaguage = g.gLanguage
                    .Font = New System.Drawing.Font("Courier New", 9)
                End With
            Catch ex As Exception
            End Try
        End Sub

        Public Function getDataView(ByVal grid As C1.Win.C1TrueDBGrid.C1TrueDBGrid) As DataView
            Try
                Dim DataV As New DataView
                If TypeOf grid.DataSource Is DataView Then
                    DataV = CType(grid.DataSource, DataView)
                ElseIf TypeOf grid.DataSource Is DataSet Then
                    DataV = CType(grid.DataSource, DataSet).Tables(0).DefaultView
                ElseIf TypeOf grid.DataSource Is DataTable Then
                    DataV = CType(grid.DataSource, DataTable).DefaultView
                End If
                Return DataV
            Catch ex As Exception
                System.Console.WriteLine(ex.ToString)
            End Try
        End Function

        Public Function getCurrData(ByVal grid As C1.Win.C1TrueDBGrid.C1TrueDBGrid) As DataTable
            Try
                Dim DataV As New DataView
                If TypeOf grid.DataSource Is DataView Then
                    DataV = CType(grid.DataSource, DataView)
                ElseIf TypeOf grid.DataSource Is DataSet Then
                    DataV = CType(grid.DataSource, DataSet).Tables(0).DefaultView
                ElseIf TypeOf grid.DataSource Is DataTable Then
                    DataV = CType(grid.DataSource, DataTable).DefaultView
                End If
                Dim netRow As DataRowView
                Dim newTable As DataTable = DataV.Table.Clone
                For Each netRow In DataV
                    newTable.Rows.Add(netRow.Row.ItemArray)
                Next
                Return newTable
            Catch ex As Exception
                System.Console.WriteLine(ex.ToString)
            End Try
        End Function

        Public Sub setColumnCombo(ByVal DataColumn As C1.Win.C1TrueDBGrid.C1DataColumn, ByVal SQL As String, ByVal aConn As OleDb.OleDbConnection)
            Try
                With DataColumn.ValueItems
                    Dim netTable As DataTable = gData.GetDataTable(SQL, aConn)
                    Dim netRow As DataRow
                    For Each netRow In netTable.Rows
                        Dim item As New C1.Win.C1TrueDBGrid.ValueItem
                        item.Value = netRow.Item(0)
                        If netTable.Columns.Count > 1 Then
                            item.DisplayValue = netRow.Item(1)
                        Else
                            item.DisplayValue = netRow.Item(0)
                        End If
                        .Values.Add(item)
                    Next
                    .Translate = True
                    .Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.ComboBox
                End With
            Catch ex As Exception
                System.Console.WriteLine(ex.ToString)
            End Try
        End Sub

    End Class

End Namespace

 

posted on 2013-10-14 14:37  vinsonLu  阅读(419)  评论(0编辑  收藏  举报