private void DoFull() { grid1.Redim(20, 4); grid1.FixedRows = 1; grid1[0, 0] = new MyHeader("1"); grid1[0, 0].ColumnSpan = 3; grid1[0, 0].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); grid1[0, 3] = new MyHeader("2"); grid1[0, 3].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); for (int r = 1; r < grid1.RowsCount; r++) { if (r % 2 == 0) { grid1[r, 0] = new SourceGrid.Cells.Cell("nospan" + r.ToString(), typeof(string)); grid1[r, 1] = new SourceGrid.Cells.Cell("span" + r.ToString(), typeof(string)); grid1[r, 1].ColumnSpan = 2; } else { grid1[r, 0] = new SourceGrid.Cells.Cell("span" + r.ToString(), typeof(string)); grid1[r, 0].ColumnSpan = 2; grid1[r, 2] = new SourceGrid.Cells.Cell("nospan" + r.ToString(), typeof(string)); } grid1[r, 3] = new SourceGrid.Cells.CheckBox("CheckBox Column/Row Span" + r.ToString(), false); } grid1.AutoSizeCells(); }
private void frmSample54_Load(object sender, System.EventArgs e) { grid1.BorderStyle = BorderStyle.FixedSingle; grid1.ColumnsCount = 4; grid1.FixedRows = 1; grid1.Rows.Insert(0); grid1.Selection.FocusStyle = FocusStyle.None; cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); cbEditor.StandardValues = new string[] { "Value 1", "Value 2", "Value 3" }; cbEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("String"); grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime"); grid1[0, 2] = new SourceGrid.Cells.ColumnHeader("CheckBox"); grid1[0, 3] = new SourceGrid.Cells.ColumnHeader("ComboBox"); for (int r = 1; r < 10; r++) { grid1.Rows.Insert(r); PopulateRow(r); } grid1.AutoSizeCells(); numericUpDownRowIndex.Value = 0; numericUpDownRowIndex.Minimum = 1; numericUpDownRowIndex.Value = 3; buttonEditCell.Click += delegate { StartEdit(grid1.Selection.ActivePosition); }; }
public Grid CreateGridWithRows(int rowCount) { Grid grid1 = new Grid(); grid1.ColumnsCount = 1; grid1.SelectionMode = GridSelectionMode.Row; for (int r = 0; r < rowCount; r++) { grid1.Rows.Insert(r); grid1[r, 0] = new SourceGrid.Cells.Cell("Hello " + r.ToString(), typeof(string)); } grid1.AutoSizeCells(); grid1.SelectionMode = GridSelectionMode.Row; return grid1; }
public void LoadList() { if (m_ItemType == null) { throw new ApplicationException("ItemType is null"); } if (m_List == null) { m_List = new ArrayList(); } if (m_Properties.Length != m_Editors.Length) { throw new ApplicationException("Properteis.Length != Editors.Length"); } grid.FixedRows = 1; grid.FixedColumns = 0; grid.Redim(m_List.Count + grid.FixedRows, m_Properties.Length + grid.FixedColumns); //HeaderCell //grid[0,0] = new Cells.Header(); for (int i = 0; i < m_Properties.Length; i++) { Cells.ColumnHeader l_Header = new Cells.ColumnHeader(m_Properties[i].Name.Replace("_", " ")); //GetCustomAttributes(typeof(ListEditor), false)); grid[0, i + grid.FixedColumns] = l_Header; l_Header.AutomaticSortEnabled = false; // //If the column type support the IComparable then I can use the value to sort the column, otherwise I use the string representation for sort. // if (typeof(IComparable).IsAssignableFrom(m_Properties[i].PropertyType)) // l_Header.Comparer = new ValueCellComparer(); // else // l_Header.Comparer = new DisplayStringCellComparer(); } for (int r = 0; r < m_List.Count; r++) { PopulateRow(r + grid.FixedRows, m_List[r]); } grid.AutoStretchColumnsToFitWidth = true; grid.AutoSizeCells(); }
private void DoFull() { grid1.Redim(20, 12); grid1.FixedRows = 2; //1 Header Row grid1[0, 0] = new MyHeader("3 Column Header"); grid1[0, 0].ColumnSpan = 3; grid1[0, 3] = new MyHeader("5 Column Header"); grid1[0, 3].ColumnSpan = 5; grid1[0, 8] = new MyHeader("1 Column Header"); grid1[0, 9] = new MyHeader("1 Column Header"); //2 Header Row grid1[1, 0] = new MyHeader("1"); grid1[1, 1] = new MyHeader("2"); grid1[1, 2] = new MyHeader("3"); grid1[1, 3] = new MyHeader("4"); grid1[1, 4] = new MyHeader("5"); grid1[1, 5] = new MyHeader("6"); grid1[1, 6] = new MyHeader("7"); grid1[1, 7] = new MyHeader("8"); grid1[1, 8] = new MyHeader("9"); grid1[1, 9] = new MyHeader("10"); grid1[1, 10] = new MyHeader("11"); grid1[1, 11] = new MyHeader("12"); SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(); SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents(); clickEvent.Click += new EventHandler(clickEvent_Click); for (int r = 2; r < grid1.RowsCount; r = r + 2) { grid1[r, 0] = new SourceGrid.Cells.Cell(r.ToString(), typeof(string)); grid1[r, 0].ColumnSpan = 2; grid1[r + 1, 0] = new SourceGrid.Cells.Cell(); grid1[r + 1, 0].ColumnSpan = 2; grid1[r, 2] = new SourceGrid.Cells.CheckBox("CheckBox Column/Row Span", false); grid1[r, 2].ColumnSpan = 2; grid1[r, 2].RowSpan = 2; grid1[r, 4] = new SourceGrid.Cells.Link("Link Column/Row Span"); grid1[r, 4].ColumnSpan = 2; grid1[r, 4].RowSpan = 2; grid1[r, 4].AddController(clickEvent); grid1[r, 6] = new SourceGrid.Cells.Button("Button Column/Row Span"); grid1[r, 6].ColumnSpan = 2; grid1[r, 6].RowSpan = 2; grid1[r, 6].AddController(clickEvent); grid1[r, 8] = new SourceGrid.Cells.Cell("Image Column/Row Span"); grid1[r, 8].View = viewImage; grid1[r, 8].Image = Properties.Resources.FACE02.ToBitmap(); grid1[r, 8].ColumnSpan = 2; grid1[r, 8].RowSpan = 2; grid1[r, 10] = new SourceGrid.Cells.Cell("Text Span", typeof(string)); grid1[r, 10].ColumnSpan = 2; grid1[r, 10].RowSpan = 2; } grid1.ClipboardMode = SourceGrid.ClipboardMode.All; grid1.AutoSizeCells(); }
private void SetColumnsAndRows(string[] columns, string[] rows, Grid grid) { if (grid.InvokeRequired) { SetNumberOfColumnsAndRows d = SetColumnsAndRows; Invoke(d, columns, rows, grid); } else { grid.Rows.Clear(); grid.Columns.Clear(); grid.Rows.Insert(0); grid.Columns.Insert(0); for (int row = 1; row <= rows.Length; row++) { grid.Rows.Insert(row); grid[row, 0] = new RowHeader(rows[row - 1]); for (int column = 1; column <= columns.Length; column++) { if (row == 1) { grid.Columns.Insert(column); grid[0, column] = new SourceGrid.Cells.ColumnHeader(columns[column - 1]); } grid[row, column] = new Cell(); grid[row, column].View = new SourceGrid.Cells.Views.Cell(); } } grid.AutoSizeCells(); } }
private void UpdateGridFromContractLists(IList<IBSimplefiedContract> contracts, Grid grid) { var i = 1; foreach (var contract in contracts) { SetupMarketDataGridRow(grid, i); grid[i, (int) IBGridColumn.Symbol].Value = contract.Symbol; grid[i, (int) IBGridColumn.SecType].Value = contract.SecurityType; grid[i, (int) IBGridColumn.Expiry].Value = contract.Expiry; grid[i, (int) IBGridColumn.Rollover].Value = contract.Rollover; grid[i, (int) IBGridColumn.Strike].Value = contract.Strike; grid[i, (int) IBGridColumn.PutOrCall].Value = contract.PutOrCall; grid[i, (int) IBGridColumn.Multiplier].Value = contract.Multiplier; grid[i, (int) IBGridColumn.Exchange].Value = contract.Exchange; grid[i, (int) IBGridColumn.Currency].Value = contract.Currency; i++; } SetupMarketDataGridRow(grid, i); grid.AutoSizeCells(); }
private void SetupMarketDataGrid(Grid grid) { grid.Parent.Tag = grid; grid.Controller.AddController(new PopupSelection()); grid.ColumnsCount = (int) IBGridColumn.LAST_COLUMN; grid.Rows.Insert(0); for (var i = 0; i < (int) IBGridColumn.LAST_COLUMN; i++) { grid[0, i] = new SourceGrid.Cells.ColumnHeader(((IBGridColumn) i).ToString()); grid[0, i].View = _columnHeaderView; } grid.Rows[0].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; grid.Rows.Insert(1); var cft = typeof (IBSimplefiedContract); foreach (var p in cft.GetProperties()) { var attrs = from a in p.GetCustomAttributes(false) where a is GridCellInfoAttribute select (a as GridCellInfoAttribute).Column; if (!attrs.Any()) continue; grid[1, (int) attrs.First()] = new SourceGrid.Cells.Cell(null, p.PropertyType) { Tag = p.PropertyType, View = _yellowView }; } grid.Rows[1].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; SetupMarketDataGridRow(grid, 1); grid.AutoSizeCells(); SetupMarketDataGridColumns(grid); }