Imports System.Drawing Imports FlexCell Namespace UTSModule.Project Public Class StationPlanGrid ''' ''' 表格各列名称对应下表 ''' Enum ColNameEnum [Step] [Label] Action Command Description Parameter1 Parameter2 Parameter3 Parameter4 Parameter5 Parameter6 Retry RetryInterval Record RecordName PassGoto FailGoto ErrorCode ErrorMessage Help Max End Enum ''' ''' 测试表格中的列名 ''' Public Shared Name() As String = {"Step", "Label", "Action", "Command", "Description ", "Parameter_1", "Parameter_2", "Parameter_3", "Parameter_4", "Parameter_5", "Parameter_6", "Retry", "RetryInterval", "Record", "RecordName", "Pass Goto", "Fail Goto", "Error Code", "Error Message", "Help"} ''' ''' 测试表每列默认宽度 ''' Public Shared Width() As Integer = {30, 50, 50, 120, 80, 100, 80, 80, 80, 80, 80, 80, 80, 50, 50, 60, 60, 80, 100, 50} ''' ''' 站测试表每列默认类型 ''' Public Shared Type() As CellTypeEnum = {CellTypeEnum.DefaultType, CellTypeEnum.DefaultType, CellTypeEnum.CheckBox, CellTypeEnum.ComboBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.CheckBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox, CellTypeEnum.TextBox } ''' ''' 站测试表每列默认字体名称 ''' Public Shared FontName() As String = {$"Calibri", $"微软雅黑", $"Calibri", $"Consolas", $"微软雅黑", $"微软雅黑", $"微软雅黑", $"微软雅黑", $"微软雅黑", $"微软雅黑", $"微软雅黑", $"Calibri", $"Calibri", $"Consolas", $"Consolas", $"Consolas", $"Consolas", $"Calibri", $"微软雅黑", $"微软雅黑"} ''' ''' 站测试表每列默认字体颜色 ''' Public Shared ForeColor() As Color = {Color.Black, Color.Black, Color.Black, Color.FromArgb(255, 0, 0, 255), Color.FromArgb(255, 0, 128, 0), Color.FromArgb(255, 0, 128, 128), Color.FromArgb(255, 0, 128, 128), Color.FromArgb(255, 0, 128, 128), Color.FromArgb(255, 0, 128, 128), Color.FromArgb(255, 0, 128, 128), Color.FromArgb(255, 0, 128, 128), Color.FromArgb(255, 128, 128, 128), Color.FromArgb(255, 128, 128, 128), Color.FromArgb(255, 0, 0, 128), Color.FromArgb(255, 0, 0, 128), Color.FromArgb(255, 0, 128, 0), Color.FromArgb(255, 255, 0, 0), Color.FromArgb(255, 128, 128, 128), Color.FromArgb(255, 128, 128, 128), Color.FromArgb(255, 128, 128, 0)} ''' ''' 初始化站测试表格 ''' ''' Public Shared Sub InitGrid(grdStationTest As Grid, Optional commands As String() = Nothing) If grdStationTest Is Nothing Then grdStationTest = New Grid() Else grdStationTest.NewFile() '清空表格格式 End If With grdStationTest .Rows = 100 .Cols = ColNameEnum.Max .AutoRedraw = False .BorderStyle = BorderStyleEnum.None .DisplayRowNumber = True '首列显示数字 .ExtendLastCol = True '最后一列自动扩充 '.BackColorFixed = Color.FromArgb(255, 227, 228, 225) '.BackColorFixedSel = Color.FromArgb(255, 201, 226, 244) '.BackColorBkg = Color.FromArgb(255, 248, 232, 226) '.BackColor1 = Color.FromArgb(255, 225, 246, 236) '.BackColor2 = Color.FromArgb(255, 247, 247, 228) '.GridColor = Color.FromArgb(255, 148, 190, 231) .DefaultFont = New Font("微软雅黑", 8) .Range(0, 0, 0, .Cols - 1).Font = New Font($"幼圆", 8) For i As Integer = 0 To Name.Length - 1 .Cell(0, i).Text = Name(i) '设置列名 .Column(i).Width = CShort(Width(i)) '设置列宽 .Column(i).CellType = Type(i) '设置列型 .Range(1, i, .Rows - 1, i).Font = New Font(FontName(i), 8) .Range(1, i, .Rows - 1, i).ForeColor = ForeColor(i) Next .ComboBox(ColNameEnum.Command).Items.Clear() If commands IsNot Nothing Then .ComboBox(ColNameEnum.Command).Items.AddRange(commands) End If .ComboBox(ColNameEnum.Command).Locked = False '只允许选择下拉框内容,不允许修改 .Cell(1, ColNameEnum.Label).Text = "Setup" .Cell(3, ColNameEnum.Label).Text = "End Setup" .Cell(5, ColNameEnum.Label).Text = "Main" .Cell(7, ColNameEnum.Label).Text = "End Main" .Cell(9, ColNameEnum.Label).Text = "Pass" .Cell(11, ColNameEnum.Label).Text = "End Pass" .Cell(13, ColNameEnum.Label).Text = "Fail" .Cell(15, ColNameEnum.Label).Text = "End Fail" .Cell(17, ColNameEnum.Label).Text = "Finally" .Cell(19, ColNameEnum.Label).Text = "End Finally" For i As Integer = 1 To grdStationTest.Rows - 1 If String.IsNullOrEmpty(.Cell(i, ColNameEnum.Label).Text) = False Then .Cell(i, ColNameEnum.Label).FontBold = True End If Next .AutoRedraw = True .Refresh() End With End Sub End Class End Namespace