/// <summary> /// 控件添加方法 /// </summary> public override void OnAdd() { base.OnAdd(); if (m_gridTransaction == null) { m_latestData = new SecurityLatestData(); m_latestDataLV2 = new SecurityLatestDataLV2(); m_gridTransaction = new GridA(); m_gridTransaction.BackColor = COLOR.EMPTY; m_gridTransaction.BorderColor = COLOR.EMPTY; m_gridTransaction.GridLineColor = COLOR.EMPTY; m_gridTransaction.HeaderVisible = false; m_gridTransaction.SelectionMode = GridSelectionMode.SelectNone; AddControl(m_gridTransaction); GridColumn dateColumn = new GridColumn(); dateColumn.Width = 80; m_gridTransaction.AddColumn(dateColumn); GridColumn priceColumn = new GridColumn(); priceColumn.Width = 70; m_gridTransaction.AddColumn(priceColumn); GridColumn volumeColumn = new GridColumn(); volumeColumn.Width = 100; m_gridTransaction.AddColumn(volumeColumn); m_gridTransaction.Update(); } }
/// <summary> /// 添加指标列 /// </summary> private void AddIndicatorColumns() { if (m_task != null) { m_gridFilterResult.BeginUpdate(); CIndicator indicator = m_task.Indicator; foreach (String name in indicator.MainVariables.Keys) { GridColumn column = new GridColumn(name); column.Name = name; column.TextAlign = ContentAlignmentA.MiddleRight; column.Width = 80; m_gridFilterResult.AddColumn(column); if (name == "FILTER") { column.Text = "符合条件"; } } List <GridColumn> columns = m_gridFilterResult.GetColumns(); int columnsSize = columns.Count; for (int i = 0; i < columnsSize; i++) { GridColumn column = columns[i]; column.AllowResize = true; column.BackColor = CDraw.PCOLORS_BACKCOLOR4; column.BorderColor = COLOR.EMPTY; column.Font = new FONT("SimSun", 14, false, false, false); column.ForeColor = CDraw.PCOLORS_FORECOLOR7; } m_gridFilterResult.EndUpdate(); } }
/// <summary> /// 添加控件方法 /// </summary> public override void OnLoad() { base.OnLoad(); if (m_grid == null) { m_grid = new GridA(); m_grid.AutoEllipsis = true; m_grid.GridLineColor = COLOR.EMPTY; m_grid.Size = new SIZE(240, 200); m_grid.RegisterEvent(m_gridCellClickEvent, EVENTID.GRIDCELLCLICK); m_grid.RegisterEvent(m_gridKeyDownEvent, EVENTID.KEYDOWN); AddControl(m_grid); m_grid.BeginUpdate(); //添加列 GridColumn securityCodeColumn = new GridColumn("股票代码"); securityCodeColumn.BackColor = CDraw.PCOLORS_BACKCOLOR; securityCodeColumn.BorderColor = COLOR.EMPTY; securityCodeColumn.Font = new FONT("Simsun", 14, true, false, false); securityCodeColumn.ForeColor = CDraw.PCOLORS_FORECOLOR; securityCodeColumn.TextAlign = ContentAlignmentA.MiddleLeft; securityCodeColumn.Width = 120; m_grid.AddColumn(securityCodeColumn); GridColumn securityNameColumn = new GridColumn("股票名称"); securityNameColumn.BackColor = CDraw.PCOLORS_BACKCOLOR; securityNameColumn.BorderColor = COLOR.EMPTY; securityNameColumn.Font = new FONT("Simsun", 14, true, false, false); securityNameColumn.ForeColor = CDraw.PCOLORS_FORECOLOR; securityNameColumn.TextAlign = ContentAlignmentA.MiddleLeft; securityNameColumn.Width = 110; m_grid.AddColumn(securityNameColumn); m_grid.EndUpdate(); } if (m_searchTextBox == null) { m_searchTextBox = new TextBoxA(); m_searchTextBox.Location = new POINT(0, 200); m_searchTextBox.Size = new SIZE(240, 20); m_searchTextBox.Font = new FONT("SimSun", 16, true, false, false); m_searchTextBox.RegisterEvent(m_textBoxInputChangedEvent, EVENTID.TEXTCHANGED); m_searchTextBox.RegisterEvent(m_textBoxKeyDownEvent, EVENTID.KEYDOWN); AddControl(m_searchTextBox); } }
/// <summary> /// 获取表格 /// </summary> /// <param name="bytes">流</param> /// <param name="native">方法库</param> /// <returns>表格</returns> public GridA GetGrid(byte[] bytes, INativeBase native) { Binary br = new Binary(); br.Write(bytes, bytes.Length); GridA grid = new GridA(); grid.Native = native; grid.Name = br.ReadString(); int columnsSize = br.ReadInt(); for (int i = 0; i < columnsSize; i++) { GridColumn column = new GridColumn(); column.Name = br.ReadString(); column.ColumnType = br.ReadString(); grid.AddColumn(column); } grid.Update(); List <GridColumn> columns = grid.GetColumns(); int rowsCount = br.ReadInt(); for (int i = 0; i < rowsCount; i++) { GridRow row = new GridRow(); grid.AddRow(row); for (int j = 0; j < columnsSize; j++) { GridColumn column = columns[j]; string columnType = column.ColumnType.ToLower(); GridCell cell = null; if (columnType == "bool") { cell = new GridBoolCell(); row.AddCell(j, cell); cell.SetBool(br.ReadBool()); } else if (columnType == "double") { cell = new GridDoubleCell(); row.AddCell(j, cell); cell.SetDouble(br.ReadDouble()); } else if (columnType == "float") { cell = new GridFloatCell(); row.AddCell(j, cell); cell.SetFloat(br.ReadFloat()); } else if (columnType == "int") { cell = new GridIntCell(); row.AddCell(j, cell); cell.SetInt(br.ReadInt()); } else if (columnType == "long") { cell = new GridLongCell(); row.AddCell(j, cell); cell.SetLong((long)br.ReadDouble()); } else if (columnType == "string") { cell = new GridStringCell(); row.AddCell(j, cell); cell.SetString(br.ReadString()); } else { cell = new GridStringCell(); row.AddCell(j, cell); cell.SetString(br.ReadString()); } } } br.Close(); return(grid); }