private void GUI_Check_List_Load(object sender, EventArgs e) { //useless corner tile checksGrid.Columns.Insert(0); checksGrid.Rows.Insert(0); //columns checksGrid.Columns.Insert(0); checksGrid.Columns.Insert(0); checksGrid.Columns.Insert(0); //add rows foreach (Check c in _getChecks()) { checksGrid.Rows.Insert(0); SourceGrid.Cells.Views.Cell rowView = new SourceGrid.Cells.Views.Cell(); SourceGrid.Cells.Views.CheckBox checkView = new SourceGrid.Cells.Views.CheckBox(); System.Drawing.Color cellColour; if (c.IsTriggered()) { cellColour = System.Drawing.Color.Red; } else if (c.HasError()) { cellColour = System.Drawing.Color.Yellow; } else if (c.IsPaused()) { cellColour = System.Drawing.Color.LightBlue; } else { cellColour = System.Drawing.Color.White; } rowView.BackColor = cellColour; checkView.BackColor = cellColour; checksGrid[1, 0] = new SourceGrid.Cells.RowHeader(c.GetIndex()); checksGrid[1, 1] = new SourceGrid.Cells.Cell(c.GetCheckType()); checksGrid[1, 1].View = rowView; checksGrid[1, 2] = new SourceGrid.Cells.Cell(c.GetLocation()); checksGrid[1, 2].View = rowView; SourceGrid.Cells.CheckBox pauseBox = new SourceGrid.Cells.CheckBox(); pauseBox.Checked = c.IsPaused(); checksGrid[1, 3] = pauseBox; checksGrid[1, 3].View = checkView; } //add column headers checksGrid[0, 1] = new SourceGrid.Cells.ColumnHeader("Name"); checksGrid[0, 2] = new SourceGrid.Cells.ColumnHeader("Location"); checksGrid[0, 3] = new SourceGrid.Cells.ColumnHeader("Paused"); checksGrid.AutoSizeCells(); }
public void DoFill(List<FinDetails> list) { FinGrid.Redim(0, 0); FinGrid.EnableSort = true; FinGrid.Redim(list.Count + 2, 6); FinGrid.Rows[0].Height = 25; FinGrid[0, 0] = new MyHeader("序号"); FinGrid[0, 0].Column.Width = 50; FinGrid[0, 0].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); FinGrid[0, 1] = new MyHeader("时间"); FinGrid[0, 1].Column.Width = 80; FinGrid[0, 1].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); FinGrid[0, 2] = new MyHeader("描述"); FinGrid[0, 2].Column.Width = 250; FinGrid[0, 2].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); FinGrid[0, 3] = new MyHeader("金额"); FinGrid[0, 3].Column.Width = 100; FinGrid[0, 3].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); FinGrid[0, 4] = new MyHeader("收支类型"); FinGrid[0, 4].Column.Width = 70; FinGrid[0, 4].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); FinGrid[0, 5] = new MyHeader("备注"); FinGrid[0, 5].Column.Width = 200; SourceGrid.Cells.Views.Cell view; int r = 1; double TotalAmount = 0; foreach (FinDetails detail in list) { TotalAmount = TotalAmount + detail.TotalAmount; FinGrid.Rows[r].Tag = detail.FinId; FinGrid.Rows[r].Height = 22; FinGrid[r, 0] = new SourceGrid.Cells.Cell(r.ToString()); FinGrid[r, 1] = new SourceGrid.Cells.Cell(detail.FinDate); FinGrid[r, 2] = new SourceGrid.Cells.Cell(detail.Description); FinGrid[r, 3] = new SourceGrid.Cells.Cell(detail.TotalAmount.ToString("#,##0.00")); view = new SourceGrid.Cells.Views.Cell(); view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; view.ForeColor = FileUtils.GetColor(detail.TotalAmount); FinGrid[r, 3].View = view; FinGrid[r, 4] = new SourceGrid.Cells.Cell(detail.EventType); FinGrid[r, 5] = new SourceGrid.Cells.Cell(detail.Remark); r++; } for (int i = 0; i < 6; i++) { FinGrid[r, i] = new SourceGrid.Cells.Cell(""); } FinGrid[r, 2] = new SourceGrid.Cells.Cell("合计"); FinGrid[r, 3] = new SourceGrid.Cells.Cell(TotalAmount.ToString("#,##0.00")); view = new SourceGrid.Cells.Views.Cell(); view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; view.ForeColor = FileUtils.GetColor(TotalAmount); FinGrid[r, 3].View = view; FinGrid.ClipboardMode = SourceGrid.ClipboardMode.All; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid1.BorderStyle = BorderStyle.FixedSingle; grid1.ColumnsCount = 3; grid1.FixedRows = 1; grid1.Rows.Insert(0); DevAge.Drawing.RectangleBorder border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.DarkGreen), new DevAge.Drawing.BorderLine(Color.DarkGreen)); DevAge.Drawing.VisualElements.ColumnHeader flatHeader = new DevAge.Drawing.VisualElements.ColumnHeader(); flatHeader.Border = border; flatHeader.BackColor = Color.ForestGreen; flatHeader.BackgroundColorStyle = DevAge.Drawing.BackgroundColorStyle.Solid; SourceGrid.Cells.Views.ColumnHeader headerView = new SourceGrid.Cells.Views.ColumnHeader(); headerView.Font = new Font(grid1.Font, FontStyle.Bold | FontStyle.Underline); headerView.Background = flatHeader; headerView.ForeColor = Color.White; SourceGrid.Cells.Views.Cell cellView = new SourceGrid.Cells.Views.Cell(); cellView.Background = new DevAge.Drawing.VisualElements.BackgroundLinearGradient(Color.ForestGreen, Color.White, 45); cellView.Border = border; SourceGrid.Cells.Views.CheckBox checkView = new SourceGrid.Cells.Views.CheckBox(); checkView.Background = new DevAge.Drawing.VisualElements.BackgroundLinearGradient(Color.ForestGreen, Color.White, 45); checkView.Border = border; grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("String"); grid1[0, 0].View = headerView; grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime"); grid1[0, 1].View = headerView; grid1[0, 2] = new SourceGrid.Cells.ColumnHeader("CheckBox"); grid1[0, 2].View = headerView; for (int r = 1; r < 10; r++) { grid1.Rows.Insert(r); grid1[r, 0] = new SourceGrid.Cells.Cell("Hello " + r.ToString(), typeof(string)); grid1[r, 0].View = cellView; grid1[r, 1] = new SourceGrid.Cells.Cell(DateTime.Today, typeof(DateTime)); grid1[r, 1].View = cellView; grid1[r, 2] = new SourceGrid.Cells.CheckBox(null, true); grid1[r, 2].View = checkView; } grid1.AutoSizeCells(); }
static OneClickTabCell() { view = new SourceGrid.Cells.Views.Cell(); ((TextGDI)view.ElementText).StringFormat.SetTabStops(0.0f, tabPosition); editor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); editor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick; editor.Control.AcceptsReturn = false; editor.Control.AcceptsTab = true; editor.Control.Multiline = true; editor.Control.WordWrap = true; }
void Initialize() { DevAge.Drawing.RectangleBorder b = channelsGrid.Selection.Border; b.SetWidth(0); channelsGrid.Selection.Border = b; channelsGrid.Selection.FocusBackColor = channelsGrid.Selection.BackColor; channelsGrid.ColumnsCount = 6; SourceGrid.Cells.Views.Cell categoryView = GetCategoryCellView(); channelsGrid.RowsCount++; channelsGrid[0, 0] = new SourceGrid.Cells.ColumnHeader("Channel"); channelsGrid[0, 1] = new SourceGrid.Cells.ColumnHeader("Value"); channelsGrid[0, 2] = new SourceGrid.Cells.ColumnHeader("Status"); channelsGrid[0, 3] = new SourceGrid.Cells.ColumnHeader("Time"); channelsGrid[0, 4] = new SourceGrid.Cells.ColumnHeader("Access"); channelsGrid[0, 5] = new SourceGrid.Cells.ColumnHeader("Type"); foreach (string plugId in Env.Current.CommunicationPlugins.PluginIds) { LoadPlugin(categoryView, plugId); } channelsGrid.AutoStretchColumnsToFitWidth = true; channelsGrid.AutoSizeCells(); channelsGrid.Selection.EnableMultiSelection = false; this.FormClosing += new FormClosingEventHandler(VariablesView_FormClosing); this.channelsGrid.Selection.SelectionChanged += new SourceGrid.RangeRegionChangedEventHandler(Selection_SelectionChanged); channelsGrid.MouseDoubleClick += new MouseEventHandler(channelsGrid_MouseDoubleClick); pluginsGrid.Selection.Border = b; pluginsGrid.Selection.FocusBackColor = channelsGrid.Selection.BackColor; pluginsGrid.ColumnsCount = 5; pluginsGrid.RowsCount++; pluginsGrid[0, 0] = new SourceGrid.Cells.ColumnHeader("Plugin Name"); pluginsGrid[0, 1] = new SourceGrid.Cells.ColumnHeader("Variables"); pluginsGrid[0, 2] = new SourceGrid.Cells.ColumnHeader("Start Plugin"); pluginsGrid[0, 3] = new SourceGrid.Cells.ColumnHeader("Stop Plugin"); pluginsGrid[0, 4] = new SourceGrid.Cells.ColumnHeader("Test mode"); foreach (string plugId in Env.Current.CommunicationPlugins.PluginIds) { pluginsGrid.RowsCount++; pluginsGrid[pluginsGrid.RowsCount - 1, 0] = new SourceGrid.Cells.Cell(plugId); pluginsGrid[pluginsGrid.RowsCount - 1, 1] = new SourceGrid.Cells.Cell(Env.Current.CommunicationPlugins[plugId].Channels.Length); //pluginsGrid[pluginsGrid.RowsCount - 1, 2] = new SourceGrid.Cells.Button(new Object()); } updateThread = new Thread(new ParameterizedThreadStart(updateThreadProc)); updateThread.Start(this); }
public CellTotal(object val) : base(new SourceGrid.Grid(), SourceGrid.LinkedControlScrollMode.ScrollVertical, false) { Control.Redim(1, 1); Control.Resize += new EventHandler(Control_Resize); Control.Selection.FocusStyle = SourceGrid.FocusStyle.RemoveFocusCellOnLeave | SourceGrid.FocusStyle.RemoveSelectionOnLeave; SourceGrid.Cells.Views.Cell totalView = new SourceGrid.Cells.Views.Cell(); totalView.Font = new Font(Control.Font, FontStyle.Underline); Control[0, 0] = new SourceGrid.Cells.Cell(val); Control[0, 0].View = totalView; }
private void btLoad_Click(object sender, System.EventArgs e) { grid.Redim(0, 0); //Visual properties shared between all the cells SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); view.BackColor = Color.Snow; //Editor (IDataModel) shared between all the cells SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text)); if (chkAddHeaders.Checked && grid.RowsCount > 0 && grid.ColumnsCount > 0) { grid.FixedRows = 1; grid.FixedColumns = 1; for (int r = grid.FixedRows; r < grid.RowsCount; r++) { grid[r, 0] = new SourceGrid.Cells.RowHeader(r); } for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++) { SourceGrid.Cells.ColumnHeader header = new SourceGrid.Cells.ColumnHeader(c); header.AutomaticSortEnabled = false; grid[0, c] = header; } grid[0, 0] = new SourceGrid.Cells.Header(); } else { grid.FixedRows = 0; grid.FixedColumns = 0; } for (int r = grid.FixedRows; r < grid.RowsCount; r++) { for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++) { grid[r, c] = new SourceGrid.Cells.Cell(r.ToString() + "," + c.ToString()); grid[r, c].Editor = editor; grid[r, c].View = view; } } grid.Selection.Focus(new SourceGrid.Position(0, 0), true); }
private void SetupReplacementsGrid() { SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell { BackColor = Color.SteelBlue, ForeColor = Color.White, TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft }; this.ReplacementsGrid.Columns.Clear(); this.ReplacementsGrid.Rows.Clear(); this.ReplacementsGrid.RowsCount = 1; this.ReplacementsGrid.ColumnsCount = 3; this.ReplacementsGrid.FixedRows = 1; this.ReplacementsGrid.FixedColumns = 0; this.ReplacementsGrid.Selection.EnableMultiSelection = false; this.ReplacementsGrid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.EnableStretch | SourceGrid.AutoSizeMode.EnableAutoSize; this.ReplacementsGrid.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.EnableStretch | SourceGrid.AutoSizeMode.EnableAutoSize; this.ReplacementsGrid.Columns[2].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; this.ReplacementsGrid.Columns[2].Width = 80; this.ReplacementsGrid.AutoStretchColumnsToFitWidth = true; this.ReplacementsGrid.Columns.StretchToFit(); this.ReplacementsGrid.Columns[0].Width = this.ReplacementsGrid.Columns[0].Width - 8; // allow for scrollbar this.ReplacementsGrid.Columns[1].Width = this.ReplacementsGrid.Columns[1].Width - 8; ////////////////////////////////////////////////////////////////////// // header row SourceGrid.Cells.ColumnHeader h; h = new SourceGrid.Cells.ColumnHeader("Search"); h.AutomaticSortEnabled = false; this.ReplacementsGrid[0, 0] = h; this.ReplacementsGrid[0, 0].View = titleModel; h = new SourceGrid.Cells.ColumnHeader("Replace"); h.AutomaticSortEnabled = false; this.ReplacementsGrid[0, 1] = h; this.ReplacementsGrid[0, 1].View = titleModel; h = new SourceGrid.Cells.ColumnHeader("Case Ins."); h.AutomaticSortEnabled = false; this.ReplacementsGrid[0, 2] = h; this.ReplacementsGrid[0, 2].View = titleModel; }
public void AddEmptyRow() { int newRowIndex = grid1.Rows.Count; grid1.Rows.Insert(newRowIndex); var lookupEditor = new LookupEditEditor(typeof(Guid)); LookUpColumnInfo selectedCol = (LookUpColumnInfo)((ComboBoxItem)cmbExerciseViewType.SelectedItem).Tag; lookupEditor.Control.SetDisplayColumn(selectedCol); grid1[newRowIndex, FromExerciseColumn] = new SourceGrid.Cells.Cell(null, lookupEditor); SourceGrid.Cells.Views.Cell readOnlyView = new SourceGrid.Cells.Views.Cell(); grid1[newRowIndex, FromExerciseColumn].View = readOnlyView; grid1[newRowIndex, FromExerciseColumn].View.ForeColor = ApplicationColors.FGNullText; grid1[newRowIndex, FromExerciseColumn].AddController(mapperCtrl); grid1[newRowIndex, FromExerciseColumn].Editor.NullDisplayString = StrengthTrainingEntryStrings.SelectExercise; grid1[newRowIndex, FromExerciseColumn].Column.Width = 250; readOnlyView = new SourceGrid.Cells.Views.Cell(); lookupEditor = new LookupEditEditor(typeof(Guid)); lookupEditor.Control.SetDisplayColumn(selectedCol); grid1[newRowIndex, ToExerciseColumn] = new SourceGrid.Cells.Cell(null, lookupEditor); readOnlyView = new SourceGrid.Cells.Views.Cell(); grid1[newRowIndex, ToExerciseColumn].View = readOnlyView; grid1[newRowIndex, ToExerciseColumn].View.ForeColor = ApplicationColors.FGNullText; grid1[newRowIndex, ToExerciseColumn].AddController(mapperCtrl); grid1[newRowIndex, ToExerciseColumn].Editor.NullDisplayString = StrengthTrainingEntryStrings.SelectExercise; grid1[newRowIndex, ToExerciseColumn].Column.Width = 250; SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(ComboBoxItem)); //cbEditor.StandardValues = Enum.GetValues(typeof(MapperEntryOperation)); foreach (MapperEntryOperation type in Enum.GetValues(typeof(MapperEntryOperation))) { cbEditor.Control.Items.Add(new ComboBoxItem(type, EnumLocalizer.Default.Translate(type))); } cbEditor.Control.DropDownStyle = ComboBoxStyle.DropDownList; cbEditor.Control.SelectedIndex = 0; readOnlyView = new SourceGrid.Cells.Views.Cell(); grid1[newRowIndex, OperationColumn] = new SourceGrid.Cells.Cell(null, cbEditor); grid1[newRowIndex, OperationColumn].View = readOnlyView; grid1[newRowIndex, OperationColumn].Column.Width = 80; UpdateCellsReadOnlyMode(grid1.Rows[newRowIndex]); }
private void AddNewReplacementRow(string from, string to, bool ins) { SourceGrid.Cells.Views.Cell roModel = new SourceGrid.Cells.Views.Cell {ForeColor = Color.Gray}; int r = this.ReplacementsGrid.RowsCount; this.ReplacementsGrid.RowsCount = r + 1; this.ReplacementsGrid[r, 0] = new SourceGrid.Cells.Cell(from, typeof(string)); this.ReplacementsGrid[r, 1] = new SourceGrid.Cells.Cell(to, typeof(string)); this.ReplacementsGrid[r, 2] = new SourceGrid.Cells.CheckBox(null, ins); if (!string.IsNullOrEmpty(from) && (TVSettings.CompulsoryReplacements().IndexOf(from) != -1)) { this.ReplacementsGrid[r, 0].Editor.EnableEdit = false; this.ReplacementsGrid[r, 0].View = roModel; } }
override void OnMouseEnter(SourceGrid.CellContext sender, EventArgs e) { cellView = new SourceGrid.Cells.Views.Cell(); cellView.Background = new DevAge.Drawing.VisualElements.BackgroundSolid(Color.LightGreen); DevAge.Drawing.ContentAlignment ca = new DevAge.Drawing.ContentAlignment(); ca = DevAge.Drawing.ContentAlignment.MiddleCenter; cellView.TextAlignment = ca; for (int c = 0; c < sender.Grid.Columns.Count; c++) { if (Convert.ToString(sender.Grid.GetCell(new Position(sender.Position.Row, c)).GetType()) != "SourceGrid.Cells.Cell") { //sender.Grid.GetCell(new Position(sender.Position.Row, c)).View.TextAlignment = ca; sender.Grid.GetCell(new Position(sender.Position.Row, c)).View = cellView; sender.Grid.InvalidateCell(new Position(sender.Position.Row, c)); } } }
private void InitializeAdvanceCorrectionMap() { AdvanceCorrectionDataGridView.Redim(3, 11); AdvanceCorrectionDataGridView.FixedColumns = 1; AdvanceCorrectionDataGridView.FixedRows = 1; AdvanceCorrectionDataGridView.Rows[0].Height = 28; AdvanceCorrectionDataGridView.Rows[1].Height = 28; AdvanceCorrectionDataGridView.Rows[2].Height = 28; SourceGrid.Cells.Views.Cell binCellView = new SourceGrid.Cells.Views.Cell { Font = new Font(Font, FontStyle.Bold), TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter }; AdvanceCorrectionDataGridView[0, 0] = new SourceGrid.Cells.ColumnHeader(string.Empty) { View = emptyHeaderView }; AdvanceCorrectionDataGridView[0, 0].Column.MinimalWidth = 80; AdvanceCorrectionDataGridView[0, 0].Column.MaximalWidth = 200; AdvanceCorrectionDataGridView[0, 0].Column.Width = 80; AdvanceCorrectionDataGridView[1, 0] = new SourceGrid.Cells.ColumnHeader("Bins") { View = rowHeaderView }; AdvanceCorrectionDataGridView[2, 0] = new SourceGrid.Cells.ColumnHeader("Correction") { View = rowHeaderView }; for (int index = 1; index < AdvanceCorrectionDataGridView.ColumnsCount; index++) { SourceGrid.Cells.ColumnHeader header = new SourceGrid.Cells.ColumnHeader(index); AdvanceCorrectionDataGridView[0, index] = header; header.Column.MinimalWidth = 60; header.Column.Width = 60; header.View = columnHeaderView; AdvanceCorrectionDataGridView[1, index] = new Cell(0, advanceEditor) { View = binCellView }; AdvanceCorrectionDataGridView[2, index] = new AdvanceCell(Font, true, (row, col, value) => Controller.IgnitionMap.AdvanceCorrection.UpdateValue(col, value)); } AdvanceCorrectionDataGridView.Width = 0; //This will force a resize so the columns will stretch to fill the space. The width will not actually be set to 0 because the Dock property is set to Fill. }
private void AddNewReplacementRow(string from, string to, bool ins) { SourceGrid.Cells.Views.Cell roModel = new SourceGrid.Cells.Views.Cell { ForeColor = Color.Gray }; int r = this.ReplacementsGrid.RowsCount; this.ReplacementsGrid.RowsCount = r + 1; this.ReplacementsGrid[r, 0] = new SourceGrid.Cells.Cell(from, typeof(string)); this.ReplacementsGrid[r, 1] = new SourceGrid.Cells.Cell(to, typeof(string)); this.ReplacementsGrid[r, 2] = new SourceGrid.Cells.CheckBox(null, ins); if (!string.IsNullOrEmpty(from) && (TVSettings.CompulsoryReplacements().IndexOf(from) != -1)) { this.ReplacementsGrid[r, 0].Editor.EnableEdit = false; this.ReplacementsGrid[r, 0].View = roModel; } }
private void numericUpDown1_ValueChanged(object sender, EventArgs e) { int angka = int.Parse(label1.Text) - 1; long angka2 = (long)nm_value.Value; a.Position = angka * 4; a.Write(ByteConverter.ToByte(angka2, 4), 0, 4); int r = angka + 1; SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); grid1[r, 1] = new SourceGrid.Cells.Cell(angka2); grid1[r, 1].View = view; grid1.Refresh(); WriteNarcBack(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid1.BorderStyle = BorderStyle.FixedSingle; grid1.ColumnsCount = 3; grid1.FixedRows = 1; grid1.Rows.Insert(0); SourceGrid.Cells.Views.ColumnHeader boldHeader = new SourceGrid.Cells.Views.ColumnHeader(); boldHeader.Font = new Font(grid1.Font, FontStyle.Bold | FontStyle.Underline); SourceGrid.Cells.Views.Cell yellowView = new SourceGrid.Cells.Views.Cell(); yellowView.BackColor = Color.Yellow; SourceGrid.Cells.Views.CheckBox yellowViewCheck = new SourceGrid.Cells.Views.CheckBox(); yellowViewCheck.BackColor = Color.Yellow; grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("String"); grid1[0, 0].View = boldHeader; grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime"); grid1[0, 1].View = boldHeader; grid1[0, 2] = new SourceGrid.Cells.ColumnHeader("CheckBox"); grid1[0, 2].View = boldHeader; for (int r = 1; r < 10; r++) { grid1.Rows.Insert(r); grid1[r, 0] = new SourceGrid.Cells.Cell("Hello " + r.ToString(), typeof(string)); grid1[r, 0].View = yellowView; grid1[r, 1] = new SourceGrid.Cells.Cell(DateTime.Today, typeof(DateTime)); grid1[r, 1].View = yellowView; grid1[r, 2] = new SourceGrid.Cells.CheckBox(null, true); grid1[r, 2].View = yellowViewCheck; } grid1.AutoSizeCells(); }
private void numericUpDown1_ValueChanged(object sender, EventArgs e) { int index = GridActiveRow - 1; if (isGridOrder) { switch (andiImageComboBox3.SelectedIndex) { case 4: case 23: case 24: case 16: WriteRequestment(index, (int)numericUpDown1.Value); break; case 6: case 8: case 17: case 18: case 19: case 20: case 21: case 22: break; default: WriteRequestment(index, 0); break; } try { grid1[index + 1, 3] = new SourceGrid.Cells.Cell(numericUpDown1.Value); SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); grid1.AutoSizeCells(); grid1[index + 1, 3].View = view; grid1.Refresh(); } catch { } WriteNarcBack(); } }
private void ChangeMovesSelected(int position, int level) { try { mvlist[position - 1].level = level; grid1[position, 3] = new SourceGrid.Cells.Cell(level); SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); grid1[position, 3].View = view; grid1.Refresh(); hexBox1.Refresh(); WriteMapData(); WriteNarcBack(); } catch (Exception ex) { Database.InsertReader.InsertLogs("Error", "Yellow", ex); } }
void Initialize() { DevAge.Drawing.RectangleBorder b = channelsGrid.Selection.Border; b.SetWidth(0); channelsGrid.Selection.Border = b; channelsGrid.Selection.FocusBackColor = channelsGrid.Selection.BackColor; channelsGrid.ColumnsCount = 6; SourceGrid.Cells.Views.Cell categoryView = GetCategoryCellView(); channelsGrid.RowsCount++; channelsGrid[0, 0] = new SourceGrid.Cells.ColumnHeader("Channel"); channelsGrid[0, 1] = new SourceGrid.Cells.ColumnHeader("Value"); channelsGrid[0, 2] = new SourceGrid.Cells.ColumnHeader("Status"); channelsGrid[0, 3] = new SourceGrid.Cells.ColumnHeader("Time"); channelsGrid[0, 4] = new SourceGrid.Cells.ColumnHeader("Access"); channelsGrid[0, 5] = new SourceGrid.Cells.ColumnHeader("Type"); foreach (string plugId in Env.Current.CommunicationPlugins.PluginIds) { LoadPlugin(categoryView, plugId); } channelsGrid.AutoStretchColumnsToFitWidth = true; channelsGrid.AutoSizeCells(); channelsGrid.Selection.SelectionChanged += new SourceGrid.RangeRegionChangedEventHandler(OnSelectionChanged); UpdateSelectedChannels(); Connect(connectCheckBox.Checked); selectButton.Visible = selectMode; if (selectMode == true) { closeButton.Text = "Cancel"; } else { closeButton.Text = "Close"; } }
public void SetupGrid() { SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell { BackColor = Color.SteelBlue, ForeColor = Color.White, TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft }; this.Grid1.Columns.Clear(); this.Grid1.Rows.Clear(); this.Grid1.RowsCount = 1; this.Grid1.ColumnsCount = 2; this.Grid1.FixedRows = 1; this.Grid1.FixedColumns = 0; this.Grid1.Selection.EnableMultiSelection = false; this.Grid1.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.None; this.Grid1.Columns[0].Width = 80; this.Grid1.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize | SourceGrid.AutoSizeMode.EnableStretch; this.Grid1.AutoStretchColumnsToFitWidth = true; //Grid1->AutoSizeCells(); this.Grid1.Columns.StretchToFit(); ////////////////////////////////////////////////////////////////////// // header row SourceGrid.Cells.ColumnHeader h; h = new SourceGrid.Cells.ColumnHeader("Name"); h.AutomaticSortEnabled = false; this.Grid1[0, 0] = h; this.Grid1[0, 0].View = titleModel; h = new SourceGrid.Cells.ColumnHeader("URL"); h.AutomaticSortEnabled = false; this.Grid1[0, 1] = h; this.Grid1[0, 1].View = titleModel; }
public void AddEmptyRow(int setNumber) { SerieCellValueChangedController serieCellValueChangedController = new SerieCellValueChangedController(this); int newRowIndex = grid1.Rows.Count; grid1.Rows.Insert(newRowIndex); var lookupEditor = new LookupEditEditor(typeof(Guid)); LookUpColumnInfo selectedCol = (LookUpColumnInfo)cmbExerciseColumns.SelectedItem; lookupEditor.Control.SetDisplayColumn(selectedCol); grid1[newRowIndex, ExerciseColumnIndex] = new SourceGrid.Cells.Cell(null, lookupEditor); SourceGrid.Cells.Views.Cell readOnlyView = new SourceGrid.Cells.Views.Cell(); grid1[newRowIndex, ExerciseColumnIndex].View = readOnlyView; grid1[newRowIndex, ExerciseColumnIndex].View.ForeColor = ApplicationColors.FGNullText; grid1[newRowIndex, ExerciseColumnIndex].AddController(exerciseCellController); grid1[newRowIndex, ExerciseColumnIndex].Editor.NullDisplayString = StrengthTrainingEntryStrings.SelectExercise; grid1[newRowIndex, ExerciseColumnIndex].Column.Width = 250; grid1[newRowIndex, CommentColumnIndex] = new SourceGrid.Cells.Cell(null, new MemoExEditEditor()); readOnlyView = new SourceGrid.Cells.Views.Cell(); //grid1[newRowIndex, 1].AddController(ee); grid1[newRowIndex, CommentColumnIndex].View = readOnlyView; grid1[newRowIndex, CommentColumnIndex].AddController(CommentableCellController); grid1[newRowIndex, CommentColumnIndex].Column.Width = 80; //string SerieRepetitionMask = string.Format(@"[0-9]*x[0-9]*[\{0}]?[0-9]*",System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); for (int i = 0; i < setNumber; i++) { //readOnlyView = new SourceGrid.Cells.Views.Cell(); var maskEditor = new SetEditor(); //maskEditor.MaskRegEx = SerieRepetitionMask; grid1[newRowIndex, StandardColumnNumber + i] = new SourceGrid.Cells.Cell(null, maskEditor); grid1[newRowIndex, StandardColumnNumber + i].AddController(serieCellValueChangedController); grid1[newRowIndex, StandardColumnNumber + i].AddController(popupMenuController); grid1[newRowIndex, StandardColumnNumber + i].View = new SetView(); } UpdateCellsReadOnlyMode(grid1.Rows[newRowIndex]); }
private static void Fill(Grid a, object[,] data, Color warna, bool multiline = true) { SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); view.BackColor = warna; editor.Control.Multiline = multiline; for (int r = a.FixedRows; r < a.RowsCount; r++) { for (int c = a.FixedRows; c < a.ColumnsCount; c++) { a[r, c] = new SourceGrid.Cells.Cell(data[r - 1, c - 1]); a[r, c].Editor = editor; a[r, c].View = view; } } a.Update(); a.Selection.Focus(new SourceGrid.Position(0, 0), true); a.AutoSizeCells(); }
private static void Fill(Grid a, object[] data, Color warna, int kolom) { SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); view.BackColor = Color.Snow; //Editor (IDataModel) shared between all the cells SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); editor.Control.Multiline = true; for (int r = a.FixedRows; r < a.RowsCount; r++) { a[r, kolom] = new SourceGrid.Cells.Cell(data[r]); a[r, kolom].Editor = editor; a[r, kolom].View = view; } a.Update(); a.Selection.Focus(new SourceGrid.Position(0, 0), true); a.AutoSizeCells(); }
public static void FillRandom(Grid a, int rounddigit = 4, int minrnd = -1, int maxrnd = 1) { SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); view.BackColor = Color.Snow; SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); Random rnd = new Random(); for (int r = a.FixedRows; r < a.RowsCount; r++) { for (int c = a.FixedColumns; c < a.ColumnsCount; c++) { a[r, c] = new SourceGrid.Cells.Cell(rnd.NextDouble(minrnd, maxrnd).Rounding(rounddigit)); a[r, c].Editor = editor; a[r, c].View = view; } } a.Update(); a.Selection.Focus(new SourceGrid.Position(0, 0), true); a.AutoSizeCells(); }
private void btLoad_Click(object sender, System.EventArgs e) { //Visual properties shared between all the cells SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); view.BackColor = Color.Snow; //Editor (IDataModel) shared between all the cells SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text)); for (int r = 0; r < grid.RowsCount; r++) { for (int c = 0; c < grid.ColumnsCount; c++) { grid[r, c] = new SourceGrid.Cells.Cell(r.ToString() + "," + c.ToString()); grid[r, c].Editor = editor; grid[r, c].View = view; } } }
private void InitializeGridCaution() { SourceGrid.Cells.Views.IView cTextAlignView = new SourceGrid.Cells.Views.Cell(); cTextAlignView.TextAlignment = DevAge.Drawing.ContentAlignment.TopRight; this.gridCaution.Rows.RowHeight = 21; //處理第一列中文字體會被遮住的問題 this.gridCaution.Columns.Add("Description", "描述", typeof(string)); this.gridCaution.Columns.Add("InitialMoney", "初始保證金", typeof(double)); this.gridCaution.Columns.Add("KeepMoney", "維持保證金", typeof(double)); this.gridCaution.Columns.Add("CloseMoney", "結算保證金", typeof(double)); this.gridCaution.Columns[0].Width = 70; this.gridCaution.Columns[1].Width = 75; this.gridCaution.Columns[1].DataCell.View = cTextAlignView; this.gridCaution.Columns[2].Width = 75; this.gridCaution.Columns[2].DataCell.View = cTextAlignView; this.gridCaution.Columns[3].Width = 75; this.gridCaution.Columns[3].DataCell.View = cTextAlignView; //修改選擇條的框線寬度與顏色 SourceGrid.Selection.SelectionBase cSelectionBase = this.gridCaution.Selection as SourceGrid.Selection.SelectionBase; cSelectionBase.Border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(cSelectionBase.BackColor, 1)); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid1.ColumnsCount = 2; SourceGrid.Cells.Controllers.Button linkEvents = new SourceGrid.Cells.Controllers.Button(); linkEvents.Executed += new EventHandler(linkEvents_Executed); //Category header SourceGrid.Cells.Views.Cell categoryView = new SourceGrid.Cells.Views.Cell(); categoryView.Background = new DevAge.Drawing.VisualElements.BackgroundLinearGradient(Color.RoyalBlue, Color.LightBlue, 0); categoryView.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText); categoryView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; categoryView.Border = DevAge.Drawing.RectangleBorder.NoBorder; categoryView.Font = new Font(Font, FontStyle.Bold); //Title header SourceGrid.Cells.Views.ColumnHeader headerView = new SourceGrid.Cells.Views.ColumnHeader(); //Load the forms System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); Type[] types = assembly.GetTypes(); LoadCategorySample("SourceGrid - Basic concepts", linkEvents, types, categoryView, headerView); LoadCategorySample("SourceGrid - Standard features", linkEvents, types, categoryView, headerView); LoadCategorySample("SourceGrid - Advanced features", linkEvents, types, categoryView, headerView); LoadCategorySample("SourceGrid - Extensions", linkEvents, types, categoryView, headerView); LoadCategorySample("SourceGrid - Generic Samples", linkEvents, types, categoryView, headerView); LoadCategorySample("SourceGrid - Performance", linkEvents, types, categoryView, headerView); LoadCategorySample("SourceGrid - PingGrid", linkEvents, types, categoryView, headerView); //Stretch only the last column grid1.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; grid1.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize | SourceGrid.AutoSizeMode.EnableStretch; grid1.AutoStretchColumnsToFitWidth = true; grid1.AutoSizeCells(); grid1.Columns.StretchToFit(); }
private void andiImageComboBox2_SelectedIndexChanged(object sender, EventArgs e) { int index = GridActiveRow - 1; andiImageBox1.Image = ImageIconHandler.setImagePictureBox(andiImageComboBox2.SelectedIndex); if (isGridOrder) { WritePokemonEv(index, andiImageComboBox2.SelectedIndex); try { grid1[index + 1, 1] = new SourceGrid.Cells.Cell(andiImageComboBox2.Text); SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); grid1.AutoSizeCells(); grid1[index + 1, 1].View = view; grid1.Refresh(); } catch { } WriteNarcBack(); } }
private static void Fill(Grid a, object[,] data, bool multiline = true) { SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); view.BackColor = Color.White; editor.Control.Multiline = multiline; for (int r = a.FixedRows; r < a.RowsCount; r++) { a[r, 1] = new SourceGrid.Cells.Cell(data[r - 1, 0]); a[r, 2] = new SourceGrid.Cells.Cell(data[r - 1, 1]); a[r, 3] = new SourceGrid.Cells.Cell(data[r - 1, 2]); a[r, 4] = new SourceGrid.Cells.Cell(data[r - 1, 3]); a[r, 5] = new SourceGrid.Cells.Cell(data[r - 1, 4]); a[r, 6] = new SourceGrid.Cells.Cell(data[r - 1, 5]); a[r, 7] = new SourceGrid.Cells.Cell(data[r - 1, 6]); a[r, 8] = new SourceGrid.Cells.Cell(data[r - 1, 7]); a[r, 9] = new SourceGrid.Cells.Cell(data[r - 1, 8]); a[r, 1].View = view; a[r, 2].View = view; a[r, 3].View = view; a[r, 4].View = view; a[r, 5].View = view; a[r, 6].View = view; a[r, 7].View = view; a[r, 8].View = view; a[r, 9].View = view; } a.Update(); try { a.Selection.Focus(new SourceGrid.Position(1, 1), true); } catch { } a.AutoSizeCells(); }
private void frmSample19_Load(object sender, System.EventArgs e) { grid1.Redim(20, 20); grid1.BackgroundImage = Properties.Resources.BackGround; grid1.ScrollablePanel.BackColor = Color.Transparent; Random rnd = new Random(); SourceGrid.Cells.Views.Cell transparentView = new SourceGrid.Cells.Views.Cell(); transparentView.BackColor = Color.Transparent; SourceGrid.Cells.Views.Cell semiTransparentView = new SourceGrid.Cells.Views.Cell(); semiTransparentView.BackColor = Color.FromArgb(50, Color.Blue); for (int r = 0; r < grid1.RowsCount; r++) { for (int c = 0; c < grid1.ColumnsCount; c++) { if (rnd.Next(0, 100) < 50) { grid1[r, c] = new SourceGrid.Cells.Cell("Opaque"); } else if (rnd.Next(0, 100) < 75) { SourceGrid.Cells.Cell l_Cell = new SourceGrid.Cells.Cell("Transparent"); l_Cell.View = transparentView; grid1[r, c] = l_Cell; } else { SourceGrid.Cells.Cell l_Cell = new SourceGrid.Cells.Cell("Transparent 50"); l_Cell.View = semiTransparentView; grid1[r, c] = l_Cell; } } } grid1.AutoSizeCells(); }
/// <summary> /// グリッドの壁紙色を設定する /// </summary> /// <param name="bolMode">壁紙色設定モード(Trueなら設定/Falseならクリア)</param> /// <param name="col">Trueの場合に設定するカラー</param> public void WallpaperColorSetting(bool bolMode, Color col) { if (bolMode) { // 壁紙色をセット SourceGrid.Cells.Views.Cell SelectView = new SourceGrid.Cells.Views.Cell(); SelectView.BackColor = col; MainProgram.frmMain.Grid[MainProgram.frmMain.Grid.Selection.ActivePosition.Row, (int)MainProgram.enuGrid.COLOR].View = SelectView; MainProgram.frmMain.Grid[MainProgram.frmMain.Grid.Selection.ActivePosition.Row, (int)MainProgram.enuGrid.COLOR].Value = ""; MainProgram.frmMain.Grid[MainProgram.frmMain.Grid.Selection.ActivePosition.Row, (int)MainProgram.enuGrid.RGBCOLOR].Value = col.R + " " + col.G + " " + col.B; } else { // 壁紙色をクリア SourceGrid.Cells.Views.Cell SelectView = new SourceGrid.Cells.Views.Cell(); MainProgram.frmMain.Grid[MainProgram.frmMain.Grid.Selection.ActivePosition.Row, (int)MainProgram.enuGrid.COLOR].View = SelectView; MainProgram.frmMain.Grid[MainProgram.frmMain.Grid.Selection.ActivePosition.Row, (int)MainProgram.enuGrid.COLOR].Value = "None"; MainProgram.frmMain.Grid[MainProgram.frmMain.Grid.Selection.ActivePosition.Row, (int)MainProgram.enuGrid.RGBCOLOR].Value = ""; } }
protected override void OnLoad(EventArgs e) { base.OnLoad (e); grid1.ColumnsCount = 2; SourceGrid.Cells.Controllers.Button linkEvents = new SourceGrid.Cells.Controllers.Button(); linkEvents.Executed += new EventHandler(linkEvents_Executed); //Category header SourceGrid.Cells.Views.Cell categoryView = new SourceGrid.Cells.Views.Cell(); categoryView.Background = new DevAge.Drawing.VisualElements.BackgroundLinearGradient(Color.RoyalBlue, Color.LightBlue, 0); categoryView.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText); categoryView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; categoryView.Border = DevAge.Drawing.RectangleBorder.NoBorder; categoryView.Font = new Font(Font, FontStyle.Bold); //Title header SourceGrid.Cells.Views.ColumnHeader headerView = new SourceGrid.Cells.Views.ColumnHeader(); //Load the forms System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); Type[] types = assembly.GetTypes(); LoadCategorySample("SourceGrid - Basic concepts", linkEvents, types, categoryView, headerView); LoadCategorySample("SourceGrid - Standard features", linkEvents, types, categoryView, headerView); LoadCategorySample("SourceGrid - Advanced features", linkEvents, types, categoryView, headerView); LoadCategorySample("SourceGrid - Extensions", linkEvents, types, categoryView, headerView); LoadCategorySample("SourceGrid - Generic Samples", linkEvents, types, categoryView, headerView); LoadCategorySample("SourceGrid - Performance", linkEvents, types, categoryView, headerView); LoadCategorySample("SourceGrid - PingGrid", linkEvents, types, categoryView, headerView); //Stretch only the last column grid1.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; grid1.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize|SourceGrid.AutoSizeMode.EnableStretch; grid1.AutoStretchColumnsToFitWidth = true; grid1.AutoSizeCells(); grid1.Columns.StretchToFit(); }
public void ScreenshotsAdd(string file, bool quick) { var screenshotGrid = _mainPanel.screenshotGrid; screenshotGrid.Columns.Insert(0); screenshotGrid[0, 0] = new SourceGrid.Cells.Cell(); Image image = Functions.ScaleImage(Bitmap.FromFile(file), 400, 70); SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(); screenshotGrid[0, 0].View = viewImage; screenshotGrid[0, 0].Image = image; screenshotGrid[0, 0].ToolTipText = file; screenshotGrid[0, 0].AddController(screenshotsClickEvent); if (!quick) { screenshotGrid.AutoSizeCells(); screenshotGrid.RecalcCustomScrollBars(); } }
private void InitializeSourceGrid() { SourceGrid.Cells.Views.IView cTextAlignView = new SourceGrid.Cells.Views.Cell(); cTextAlignView.TextAlignment = DevAge.Drawing.ContentAlignment.TopRight; this.dataGrid.Rows.RowHeight = 21; //處理第一列中文字體會被遮住的問題 this.dataGrid.Columns.Add("Enabled", "啟用", typeof(bool)); this.dataGrid.Columns.Add("Name", "報價元件", typeof(string)); this.dataGrid.Columns.Add("FileVersion", "檔案版本", typeof(string)); this.dataGrid.Columns.Add("ProductVersion", "元件版本", typeof(string)); this.dataGrid.Columns.Add("Company", "開發廠商", typeof(string)); this.dataGrid.Columns.Add("DataSource", "資料來源名稱", typeof(string)); this.dataGrid.Columns.Add("LogonId", "登入帳號", typeof(string)); this.dataGrid.Columns.Add("PacketCountPerSeconds", "傳輸速率", typeof(string)); this.dataGrid.Columns.Add("PacketCount", "封包個數", typeof(string)); this.dataGrid.Columns[0].Width = 40; this.dataGrid.Columns[0].DataCell.Controller.RemoveController(SourceGrid.Cells.Controllers.CheckBox.Default); //因為沒有編輯功能(取消對 Checkbox 的 Click 功能) this.dataGrid.Columns[1].Width = 150; this.dataGrid.Columns[2].Width = 70; this.dataGrid.Columns[3].Width = 70; this.dataGrid.Columns[4].Width = 200; this.dataGrid.Columns[5].Width = 150; this.dataGrid.Columns[6].Width = 100; this.dataGrid.Columns[7].Width = 90; this.dataGrid.Columns[7].DataCell.View = cTextAlignView; this.dataGrid.Columns[8].Width = 90; this.dataGrid.Columns[8].DataCell.View = cTextAlignView; //修改選擇條的框線寬度與顏色 SourceGrid.Selection.SelectionBase cSelectionBase = this.dataGrid.Selection as SourceGrid.Selection.SelectionBase; cSelectionBase.Border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(cSelectionBase.BackColor, 1)); this.dataGrid.Selection.SelectionChanged += dataGrid_onSelectionChanged; source = new Data.SimpleBoundList <Zeghs.Data._QuoteServiceInfo>(64); this.dataGrid.DataSource = source; }
private void InitializeSourceGrid() { SourceGrid.Cells.Views.IView cTextAlignView = new SourceGrid.Cells.Views.Cell(); cTextAlignView.TextAlignment = DevAge.Drawing.ContentAlignment.TopRight; this.dataGrid.Rows.RowHeight = 21; //處理第一列中文字體會被遮住的問題 this.dataGrid.Columns.Add("SymbolName", "名稱", typeof(string)); this.dataGrid.Columns.Add("Time", "時間", typeof(System.TimeSpan)); this.dataGrid.Columns.Add("Price", "成交", typeof(double)); this.dataGrid.Columns.Add("Volume", "總量", typeof(double)); this.dataGrid.Columns[0].Width = 56; this.dataGrid.Columns[1].Width = 55; this.dataGrid.Columns[2].DataCell.View = cTextAlignView; this.dataGrid.Columns[3].DataCell.View = cTextAlignView; //修改選擇條的框線寬度與顏色 SourceGrid.Selection.SelectionBase cSelectionBase = this.dataGrid.Selection as SourceGrid.Selection.SelectionBase; cSelectionBase.Border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(cSelectionBase.BackColor, 1)); source = new Data.PrimaryBoundList<string, Data._QuoteInfo>(256); source.SetFunctionForGetPrimary((quote) => { return quote.SymbolName; }); this.dataGrid.DataSource = source; }
private void btLoad_Click(object sender, System.EventArgs e) { grid.Redim(0, 0); //Visual properties shared between all the cells SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); view.BackColor = Color.Snow; //Editor (IDataModel) shared between all the cells SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text)); if (chkAddHeaders.Checked && grid.RowsCount > 0 && grid.ColumnsCount > 0) { grid.FixedRows = 1; grid.FixedColumns = 1; for (int r = grid.FixedRows; r < grid.RowsCount; r++) grid[r, 0] = new SourceGrid.Cells.RowHeader(r); for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++) { SourceGrid.Cells.ColumnHeader header = new SourceGrid.Cells.ColumnHeader(c); header.AutomaticSortEnabled = false; grid[0, c] = header; } grid[0, 0] = new SourceGrid.Cells.Header(); } else { grid.FixedRows = 0; grid.FixedColumns = 0; } for (int r = grid.FixedRows; r < grid.RowsCount; r++) for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++) { grid[r, c] = new SourceGrid.Cells.Cell(r.ToString() + "," + c.ToString()); grid[r, c].Editor = editor; grid[r, c].View = view; } grid.Selection.Focus(new SourceGrid.Position(0, 0), true); }
private void CreateColumns(SourceGrid.DataGridColumns columns, DevAge.ComponentModel.IBoundList bindList) { SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(decimal)); numericEditor.TypeConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(decimal), "N"); numericEditor.AllowNull = true; //Borders DevAge.Drawing.RectangleBorder border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.ForestGreen), new DevAge.Drawing.BorderLine(Color.ForestGreen)); //Standard Views SourceGrid.Cells.Views.Link viewLink = new SourceGrid.Cells.Views.Link(); viewLink.BackColor = Color.DarkSeaGreen; viewLink.Border = border; viewLink.ImageAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; viewLink.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; SourceGrid.Cells.Views.Cell viewString = new SourceGrid.Cells.Views.Cell(); viewString.BackColor = Color.DarkSeaGreen; viewString.Border = border; viewString.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft; SourceGrid.Cells.Views.Cell viewNumeric = new SourceGrid.Cells.Views.Cell(); viewNumeric.BackColor = Color.DarkSeaGreen; viewNumeric.Border = border; viewNumeric.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(); viewImage.BackColor = Color.DarkSeaGreen; viewImage.Border = border; viewImage.ImageStretch = false; viewImage.ImageAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; //Create columns SourceGrid.DataGridColumn gridColumn; gridColumn = dataGrid.Columns.Add(null, "", new SourceGrid.Cells.Link()); gridColumn.DataCell.AddController(new LinkClickDelete()); gridColumn.DataCell.View = viewLink; ((SourceGrid.Cells.Link)gridColumn.DataCell).Image = Properties.Resources.trash.ToBitmap(); gridColumn = dataGrid.Columns.Add("Flag", "Flag", new SourceGrid.Cells.DataGrid.Image()); gridColumn.DataCell.View = viewImage; gridColumn = dataGrid.Columns.Add("Country", "Country", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("Uniform", "Uniform", new SourceGrid.Cells.DataGrid.Image()); gridColumn.DataCell.View = viewImage; gridColumn = dataGrid.Columns.Add("Capital", "Capital", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("Population", "Population", typeof(decimal)); gridColumn.DataCell.Editor = numericEditor; gridColumn.DataCell.View = viewNumeric; gridColumn = dataGrid.Columns.Add("Surface", "Surface", typeof(decimal)); gridColumn.DataCell.Editor = numericEditor; gridColumn.DataCell.View = viewNumeric; gridColumn = dataGrid.Columns.Add("Languages", "Languages", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("Currency", "Currency", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("Major Cities", "Major Cities", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("National Holiday", "National Holiday", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("Lowest point", "Lowest point", typeof(string)); gridColumn.DataCell.View = viewString; gridColumn = dataGrid.Columns.Add("Highest point", "Highest point", typeof(string)); gridColumn.DataCell.View = viewString; //Create a conditional view foreach (SourceGrid.DataGridColumn col in columns) { SourceGrid.Conditions.ICondition condition = SourceGrid.Conditions.ConditionBuilder.AlternateView(col.DataCell.View, Color.LightGray, Color.Black); col.Conditions.Add(condition); } }
private void frmSample19_Load(object sender, System.EventArgs e) { grid1.Redim(20, 20); grid1.BackgroundImage = Properties.Resources.BackGround; Random rnd = new Random(); SourceGrid.Cells.Views.Cell transparentView = new SourceGrid.Cells.Views.Cell(); transparentView.BackColor = Color.Transparent; SourceGrid.Cells.Views.Cell semiTransparentView = new SourceGrid.Cells.Views.Cell(); semiTransparentView.BackColor = Color.FromArgb(50, Color.Blue); for (int r = 0; r < grid1.RowsCount; r++) for (int c = 0; c < grid1.ColumnsCount; c++) { if (rnd.Next(0,100) < 50) grid1[r,c] = new SourceGrid.Cells.Cell("Opaque"); else if (rnd.Next(0,100) < 75) { SourceGrid.Cells.Cell l_Cell = new SourceGrid.Cells.Cell("Transparent"); l_Cell.View = transparentView; grid1[r,c] = l_Cell; } else { SourceGrid.Cells.Cell l_Cell = new SourceGrid.Cells.Cell("Transparent 50"); l_Cell.View = semiTransparentView; grid1[r,c] = l_Cell; } } grid1.AutoSizeCells(); }
private void SetupExtraGridFunctionality() { DataTable CostCentreListTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.CostCentreList, FLedgerNumber); ACostCentreTable tmpCostCentreTable = new ACostCentreTable(); FMainDS.Tables.Add(tmpCostCentreTable); DataUtilities.ChangeDataTableToTypedDataTable(ref CostCentreListTable, FMainDS.Tables[tmpCostCentreTable.TableName].GetType(), ""); FMainDS.RemoveTable(tmpCostCentreTable.TableName); if ((CostCentreListTable == null) || (CostCentreListTable.Rows.Count == 0)) { FCostCentreList = null; } else { FCostCentreList = (ACostCentreTable)CostCentreListTable; } DataTable AccountListTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, FLedgerNumber); AAccountTable tmpAccountTable = new AAccountTable(); FMainDS.Tables.Add(tmpAccountTable); DataUtilities.ChangeDataTableToTypedDataTable(ref AccountListTable, FMainDS.Tables[tmpAccountTable.TableName].GetType(), ""); FMainDS.RemoveTable(tmpAccountTable.TableName); if ((AccountListTable == null) || (AccountListTable.Rows.Count == 0)) { FAccountList = null; } else { FAccountList = (AAccountTable)AccountListTable; } //Prepare grid to highlight inactive accounts/cost centres // Create a cell view for special conditions SourceGrid.Cells.Views.Cell strikeoutCell = new SourceGrid.Cells.Views.Cell(); strikeoutCell.Font = new System.Drawing.Font(grdDetails.Font, FontStyle.Strikeout); //strikeoutCell.ForeColor = Color.Crimson; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAccountCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionAccountCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string accountCode = row[ATransactionTable.ColumnAccountCodeId].ToString(); return !AccountIsActive(accountCode); }; SourceGrid.Conditions.ConditionView conditionCostCentreCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionCostCentreCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string costCentreCode = row[ATransactionTable.ColumnCostCentreCodeId].ToString(); return !CostCentreIsActive(costCentreCode); }; //Add conditions to columns int indexOfCostCentreCodeDataColumn = 2; int indexOfAccountCodeDataColumn = 3; grdDetails.Columns[indexOfCostCentreCodeDataColumn].Conditions.Add(conditionCostCentreCodeActive); grdDetails.Columns[indexOfAccountCodeDataColumn].Conditions.Add(conditionAccountCodeActive); //Prepare Analysis attributes grid to highlight inactive analysis codes // Create a cell view for special conditions SourceGrid.Cells.Views.Cell strikeoutCell2 = new SourceGrid.Cells.Views.Cell(); strikeoutCell2.Font = new System.Drawing.Font(grdAnalAttributes.Font, FontStyle.Strikeout); //strikeoutCell.ForeColor = Color.Crimson; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAnalysisCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2); conditionAnalysisCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2) { DataRowView row2 = (DataRowView)itemRow2; string analysisCode = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString(); return !FAnalysisAttributesLogic.AnalysisCodeIsActive( cmbDetailAccountCode.GetSelectedString(), FCacheDS.AAnalysisAttribute, analysisCode); }; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAnalysisAttributeValueActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2); conditionAnalysisAttributeValueActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2) { if (itemRow2 != null) { DataRowView row2 = (DataRowView)itemRow2; string analysisCode = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString(); string analysisAttributeValue = row2[ATransAnalAttribTable.ColumnAnalysisAttributeValueId].ToString(); return !TAnalysisAttributes.AnalysisAttributeValueIsActive(ref FcmbAnalAttribValues, FCacheDS.AFreeformAnalysis, analysisCode, analysisAttributeValue); } else { return false; } }; //Add conditions to columns int indexOfAnalysisCodeColumn = 0; int indexOfAnalysisAttributeValueColumn = 1; grdAnalAttributes.Columns[indexOfAnalysisCodeColumn].Conditions.Add(conditionAnalysisCodeActive); grdAnalAttributes.Columns[indexOfAnalysisAttributeValueColumn].Conditions.Add(conditionAnalysisAttributeValueActive); }
public void SetupGrid() { SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell { BackColor = Color.SteelBlue, ForeColor = Color.White, TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft }; SourceGrid.Cells.Views.Cell titleModelC = new SourceGrid.Cells.Views.Cell { BackColor = Color.SteelBlue, ForeColor = Color.White, TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter }; this.Grid1.Columns.Clear(); this.Grid1.Rows.Clear(); this.Grid1.RowsCount = 1; this.Grid1.ColumnsCount = 4; this.Grid1.FixedRows = 1; this.Grid1.FixedColumns = 0; this.Grid1.Selection.EnableMultiSelection = false; this.Grid1.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.None; this.Grid1.Columns[0].Width = 60; this.Grid1.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize | SourceGrid.AutoSizeMode.EnableStretch; this.Grid1.Columns[2].AutoSizeMode = SourceGrid.AutoSizeMode.None; this.Grid1.Columns[2].Width = 60; this.Grid1.Columns[3].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize | SourceGrid.AutoSizeMode.EnableStretch; this.Grid1.AutoStretchColumnsToFitWidth = true; this.Grid1.Columns.StretchToFit(); ////////////////////////////////////////////////////////////////////// // header row SourceGrid.Cells.ColumnHeader h; h = new SourceGrid.Cells.ColumnHeader("Enabled"); h.AutomaticSortEnabled = false; this.Grid1[0, 0] = h; this.Grid1[0, 0].View = titleModelC; h = new SourceGrid.Cells.ColumnHeader("Regex"); h.AutomaticSortEnabled = false; this.Grid1[0, 1] = h; this.Grid1[0, 1].View = titleModel; h = new SourceGrid.Cells.ColumnHeader("Full Path"); h.AutomaticSortEnabled = false; this.Grid1[0, 2] = h; this.Grid1[0, 2].View = titleModelC; h = new SourceGrid.Cells.ColumnHeader("Notes"); h.AutomaticSortEnabled = false; this.Grid1[0, 3] = h; this.Grid1[0, 3].View = titleModel; this.Grid1.Selection.SelectionChanged += this.SelectionChanged; }
private void SetupExtraGridFunctionality() { //Prepare grid to highlight inactive accounts/cost centres // Create a cell view for special conditions SourceGrid.Cells.Views.Cell strikeoutCell = new SourceGrid.Cells.Views.Cell(); strikeoutCell.Font = new System.Drawing.Font(grdDetails.Font, FontStyle.Strikeout); //strikeoutCell.ForeColor = Color.Crimson; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAccountCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionAccountCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string accountCode = row[AGiftBatchTable.ColumnBankAccountCodeId].ToString(); return !FAccountAndCostCentreLogicObject.AccountIsActive(accountCode); }; SourceGrid.Conditions.ConditionView conditionCostCentreCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionCostCentreCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string costCentreCode = row[AGiftBatchTable.ColumnBankCostCentreId].ToString(); return !FAccountAndCostCentreLogicObject.CostCentreIsActive(costCentreCode); }; //Add conditions to columns int indexOfCostCentreCodeDataColumn = 7; int indexOfAccountCodeDataColumn = 8; grdDetails.Columns[indexOfCostCentreCodeDataColumn].Conditions.Add(conditionCostCentreCodeActive); grdDetails.Columns[indexOfAccountCodeDataColumn].Conditions.Add(conditionAccountCodeActive); }
private void SetupRSSGrid() { SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell { BackColor = Color.SteelBlue, ForeColor = Color.White, TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft }; this.RSSGrid.Columns.Clear(); this.RSSGrid.Rows.Clear(); this.RSSGrid.RowsCount = 1; this.RSSGrid.ColumnsCount = 1; this.RSSGrid.FixedRows = 1; this.RSSGrid.FixedColumns = 0; this.RSSGrid.Selection.EnableMultiSelection = false; this.RSSGrid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize | SourceGrid.AutoSizeMode.EnableStretch; this.RSSGrid.AutoStretchColumnsToFitWidth = true; this.RSSGrid.Columns.StretchToFit(); ////////////////////////////////////////////////////////////////////// // header row ColumnHeader h = new SourceGrid.Cells.ColumnHeader("URL"); h.AutomaticSortEnabled = false; this.RSSGrid[0, 0] = h; this.RSSGrid[0, 0].View = titleModel; }
private void addRowToDownloadGrid(Download download) { PopupMenu menuController = new PopupMenu(this); int insertRowCount = downloadGrid.Rows.Count; download.RowIndex = insertRowCount; downloadGrid.Rows.Insert(insertRowCount); downloadGrid[insertRowCount, 0] = new SourceGrid.Cells.CheckBox(null, download.DownloadEnable); downloadGrid[insertRowCount, 0].View = viewCheckBox; downloadGrid[insertRowCount, 0].AddController(menuController); downloadGrid[insertRowCount, 0].Controller.RemoveController(downloadGrid[insertRowCount, 0].FindController<SourceGrid.Cells.Controllers.CheckBox>()); downloadGrid[insertRowCount, 0].Controller.AddController(new SourceGrid.Cells.Controllers.CheckBox(false)); downloadGrid[insertRowCount, 0].FindController<SourceGrid.Cells.Controllers.CheckBox>().CheckedChanged += ChangeActivateCheckBox(insertRowCount); downloadGrid[insertRowCount, 1] = new SourceGrid.Cells.Cell(download.No); downloadGrid[insertRowCount, 1].View = viewNormal; downloadGrid[insertRowCount, 1].AddController(menuController); downloadGrid[insertRowCount, 2] = new SourceGrid.Cells.Cell(download.Ip); downloadGrid[insertRowCount, 2].View = viewNormal; downloadGrid[insertRowCount, 2].AddController(menuController); downloadGrid[insertRowCount, 3] = new SourceGrid.Cells.Cell(Path.GetFileName(download.DownloadFileName)); downloadGrid[insertRowCount, 3].View = viewNormal; downloadGrid[insertRowCount, 3].AddController(menuController); ProgressBar progressBar = new ProgressBar(); progressBar.BackColor = Color.Gray; progressBar.ForeColor = Color.DarkSlateGray; progressBar.Value = 0; SourceGrid.Cells.Cell cell = new SourceGrid.Cells.Cell(download.Progress); downloadGrid[insertRowCount, 4] = cell; downloadGrid[insertRowCount, 4].View = viewNormal; downloadGrid[insertRowCount, 4].AddController(menuController); SourceGrid.LinkedControlValue linkedControlValue = new SourceGrid.LinkedControlValue(progressBar, new SourceGrid.Position(insertRowCount, 4)); downloadGrid.LinkedControls.Add(linkedControlValue); SourceGrid.Cells.Views.Cell statusCell = new SourceGrid.Cells.Views.Cell(); statusCell.Border = cellBorder; statusCell.Font = new Font("돋음", 8, FontStyle.Regular); statusCell.BackColor = download.Status.ColorParse(); SourceGrid.Cells.Cell cell5 = new SourceGrid.Cells.Cell(download.Status.Parse()); downloadGrid[insertRowCount, 5] = cell5; downloadGrid[insertRowCount, 5].View = statusCell; downloadGrid[insertRowCount, 5].AddController(menuController); DownLoadBinding binding = new DownLoadBinding(); binding.ProgressBar = progressBar; binding.Cell = cell5; binding.StatusCell = statusCell; downloadGrid.Rows[insertRowCount].Tag = binding; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid.Redim(62, 3); SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell(); titleModel.BackColor = Color.SteelBlue; titleModel.ForeColor = Color.White; titleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; SourceGrid.Cells.Views.Cell captionModel = new SourceGrid.Cells.Views.Cell(); captionModel.BackColor = grid.BackColor; int currentRow = 0; #region Base Types grid[currentRow, 0] = new SourceGrid.Cells.Cell("Base Types"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //string grid[currentRow, 0] = new SourceGrid.Cells.Cell("String"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("String Value", typeof(string)); currentRow++; //double grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(1.5, typeof(double)); currentRow++; //int grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(5, typeof(int)); currentRow++; //DateTime grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTime"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime)); currentRow++; //Boolean grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(true, typeof(Boolean)); currentRow++; #endregion #region Complex Types grid[currentRow, 0] = new SourceGrid.Cells.Cell("Complex Types"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Font grid[currentRow, 0] = new SourceGrid.Cells.Cell("Font"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(this.Font, typeof(Font)); currentRow++; //Cursor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cursor"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(Cursors.Arrow, typeof(Cursor)); currentRow++; //Point grid[currentRow, 0] = new SourceGrid.Cells.Cell("Point"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Point(2, 3), typeof(Point)); currentRow++; //Rectangle grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rectangle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Rectangle(100, 100, 200, 200), typeof(Rectangle)); currentRow++; //Image grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Image(Properties.Resources.CalcioSmall); currentRow++; //Enum AnchorStyle grid[currentRow, 0] = new SourceGrid.Cells.Cell("AnchorStyle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(AnchorStyles.Bottom, typeof(AnchorStyles)); currentRow++; //Enum grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(System.Windows.Forms.BorderStyle.Fixed3D, typeof(System.Windows.Forms.BorderStyle)); currentRow++; //String[] grid[currentRow, 0] = new SourceGrid.Cells.Cell("String Array"); grid[currentRow, 0].View = captionModel; string[] strArray = new string[] { "Value 1", "Value 2" }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(strArray, typeof(string[])); currentRow++; //Double[] grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Array"); grid[currentRow, 0].View = captionModel; double[] dblArray = new double[] { 1, 0.5, 0.1 }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(dblArray, typeof(double[])); currentRow++; #endregion #region Special Editors grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Editors"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Time grid[currentRow, 0] = new SourceGrid.Cells.Cell("Time"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now); grid[currentRow, 1].Editor = new SourceGrid.Cells.Editors.TimePicker(); currentRow++; //Double Chars Validation grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Chars Validation"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double)); numericEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs) { bool isValid = char.IsNumber(keyArgs.KeyChar) || keyArgs.KeyChar == System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]; keyArgs.Handled = !isValid; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.5); grid[currentRow, 1].Editor = numericEditor; currentRow++; //String Chars (ABC) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Chars Validation(only ABC)"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox stringEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); stringEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs) { keyArgs.KeyChar = char.ToUpper(keyArgs.KeyChar); bool isValid = keyArgs.KeyChar == 'A' || keyArgs.KeyChar == 'B' || keyArgs.KeyChar == 'C'; keyArgs.Handled = !isValid; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell("AABB"); grid[currentRow, 1].Editor = stringEditor; currentRow++; //String Validating grid[currentRow, 0] = new SourceGrid.Cells.Cell("String validating(min 6 chars)"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox stringEditorValidating = new SourceGrid.Cells.Editors.TextBox(typeof(string)); stringEditorValidating.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { string val = ((TextBox)sender).Text; if (val == null || val.Length < 6) cancelEvent.Cancel = true; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell("test string"); grid[currentRow, 1].Editor = stringEditorValidating; currentRow++; //Int 0-100 or null grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int 0-100 or null"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBoxNumeric numericEditor0_100 = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(int)); numericEditor0_100.MinimumValue = 0; numericEditor0_100.MaximumValue = 100; numericEditor0_100.AllowNull = true; grid[currentRow, 1] = new SourceGrid.Cells.Cell(7); grid[currentRow, 1].Editor = numericEditor0_100; currentRow++; //Double Custom Conversion grid[currentRow, 0] = new SourceGrid.Cells.Cell("Dbl custom conversion"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox dblCustomConversion = new SourceGrid.Cells.Editors.TextBox(typeof(double)); dblCustomConversion.ConvertingObjectToValue += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs conv) { if (conv.Value is string) { //Here you can add any custom code double val; if (double.TryParse((string)conv.Value, out val)) { conv.Value = val; conv.ConvertingStatus = DevAge.ComponentModel.ConvertingStatus.Completed; } } }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(73.839); grid[currentRow, 1].Editor = dblCustomConversion; currentRow++; //Enum Custom Display grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum Custom Display"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox keysCombo = new SourceGrid.Cells.Editors.ComboBox(typeof(Keys)); keysCombo.Control.FormattingEnabled = true; keysCombo.ConvertingValueToDisplayString += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs convArgs) { if (convArgs.Value is Keys) convArgs.Value = (int)((Keys)convArgs.Value) + " - " + convArgs.Value.ToString(); }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(Keys.Enter); grid[currentRow, 1].Editor = keysCombo; currentRow++; string[] arraySample = new string[] { "Value 1", "Value 2", "Value 3" }; //ComboBox 1 grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboStandard = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false); comboStandard.Control.MaxLength = 10; grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboStandard); currentRow++; //ComboBox exclusive grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String Exclusive"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboExclusive = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboExclusive); currentRow++; //ComboBox AutoComplete grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox AutoComplete"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboAutoComplete = new SourceGrid.Cells.Editors.ComboBox(typeof(string), new string[] { "AAA", "ABC", "AZA", "BAA", "ZAA" }, true); comboAutoComplete.Control.AutoCompleteSource = AutoCompleteSource.ListItems; comboAutoComplete.Control.AutoCompleteMode = AutoCompleteMode.Append; grid[currentRow, 1] = new SourceGrid.Cells.Cell("AAA", comboAutoComplete); currentRow++; //ComboBox DropDownList grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DropDownList"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboNoText = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0]); grid[currentRow, 1].Editor = comboNoText; comboNoText.Control.DropDownStyle = ComboBoxStyle.DropDownList; currentRow++; //ComboBox DateTime Editable grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DateTime"); grid[currentRow, 0].View = captionModel; DateTime[] arrayDt = new DateTime[] { new DateTime(1981, 10, 6), new DateTime(1991, 10, 6), new DateTime(2001, 10, 6) }; SourceGrid.Cells.Editors.ComboBox comboDateTime = new SourceGrid.Cells.Editors.ComboBox(typeof(DateTime), arrayDt, false); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arrayDt[0], comboDateTime); currentRow++; //ComboBox Custom Display (create a datamodel that has a custom display string) grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Custom Display"); grid[currentRow, 0].View = captionModel; int[] arrInt = new int[] { 0, 1, 2, 3, 4 }; string[] arrStr = new string[] { "0 - Zero", "1 - One", "2 - Two", "3 - Three", "4- Four" }; SourceGrid.Cells.Editors.ComboBox editorComboCustomDisplay = new SourceGrid.Cells.Editors.ComboBox(typeof(int), arrInt, true); editorComboCustomDisplay.Control.FormattingEnabled = true; DevAge.ComponentModel.Validator.ValueMapping comboMapping = new DevAge.ComponentModel.Validator.ValueMapping(); comboMapping.DisplayStringList = arrStr; comboMapping.ValueList = arrInt; comboMapping.SpecialList = arrStr; comboMapping.SpecialType = typeof(string); comboMapping.BindValidator(editorComboCustomDisplay); grid[currentRow, 1] = new SourceGrid.Cells.Cell(0); grid[currentRow, 1].Editor = editorComboCustomDisplay; SourceGrid.Cells.Cell l_CellComboRealValue = new SourceGrid.Cells.Cell(grid[currentRow, 1].Value); l_CellComboRealValue.View = captionModel; SourceGrid.Cells.Controllers.BindProperty l_ComboBindProperty = new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Cell).GetProperty("Value"), l_CellComboRealValue); grid[currentRow, 1].AddController(l_ComboBindProperty); grid[currentRow, 2] = l_CellComboRealValue; currentRow++; //ComboBox with inline View grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Inline View"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox cbInline = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false); cbInline.EditableMode = SourceGrid.EditableMode.Default | SourceGrid.EditableMode.Focus; grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], cbInline); grid[currentRow, 1].View = SourceGrid.Cells.Views.ComboBox.Default; currentRow++; //Numeric Up Down Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("NumericUpDown"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0); SourceGrid.Cells.Editors.NumericUpDown l_NumericUpDownEditor = new SourceGrid.Cells.Editors.NumericUpDown(typeof(int), 50, -50, 1); grid[currentRow, 1].Editor = l_NumericUpDownEditor; currentRow++; //Multiline Textbox grid[currentRow, 0] = new SourceGrid.Cells.Cell("Multiline Textbox"); grid[currentRow, 0].View = captionModel; grid[currentRow, 0].ColumnSpan = 1; grid[currentRow, 0].RowSpan = 2; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello\r\nWorld"); SourceGrid.Cells.Editors.TextBox l_MultilineEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); l_MultilineEditor.Control.Multiline = true; grid[currentRow, 1].Editor = l_MultilineEditor; grid[currentRow, 1].RowSpan = 2; currentRow++; currentRow++; //Boolean (CheckBox) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean (CheckBox)"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.CheckBox(null, true); grid[currentRow, 1].FindController<SourceGrid.Cells.Controllers.CheckBox>().CheckedChanged += InvertDisabledCheckBox(currentRow); SourceGrid.Cells.CheckBox l_DisabledCheckBox = new SourceGrid.Cells.CheckBox("Disabled Checkbox", true); l_DisabledCheckBox.Editor.EnableEdit = false; grid[currentRow, 2] = l_DisabledCheckBox; currentRow++; //DateTime with DateTimePicker Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.DateTimePicker editorDtPicker = new SourceGrid.Cells.Editors.DateTimePicker(); grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today); grid[currentRow, 1].Editor = editorDtPicker; currentRow++; //DateTime with DateTimePicker nullable Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker nullable"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.DateTimePicker editorDtPickerNull = new SourceGrid.Cells.Editors.DateTimePicker(); editorDtPickerNull.AllowNull = true; grid[currentRow, 1] = new SourceGrid.Cells.Cell(null); grid[currentRow, 1].Editor = editorDtPickerNull; currentRow++; //File editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("File editor"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("c:\\windows\\System32\\user32.dll", new EditorFileDialog()); currentRow++; // Richtext box grid[currentRow, 0] = new SourceGrid.Cells.Cell("RichTextBox editor"); grid[currentRow, 0].View = captionModel; string rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0" + "Microsoft Sans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17 Only a \\b " + "Test\\b0.\\par\r\n}\r\n"; var richTextBox = new SourceGrid.Cells.RichTextBox(new RichText(rtf)); grid[currentRow, 1] = richTextBox; currentRow++; #endregion #region Special Cells grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Cells"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Cell Button grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Button"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Button("CellButton"); grid[currentRow, 1].Image = Properties.Resources.FACE02.ToBitmap(); SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button(); buttonClickEvent.Executed += new EventHandler(CellButton_Click); grid[currentRow, 1].Controller.AddController(buttonClickEvent); currentRow++; //Cell Link grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Link"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Link("CellLink"); SourceGrid.Cells.Controllers.Button linkClickEvent = new SourceGrid.Cells.Controllers.Button(); linkClickEvent.Executed += new EventHandler(CellLink_Click); grid[currentRow, 1].Controller.AddController(linkClickEvent); currentRow++; //Custom draw cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom draw cell"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("CustomView"); grid[currentRow, 1].View = new RoundView(); currentRow++; //Control Cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Control Cell"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("control cell"); ProgressBar progressBar = new ProgressBar(); progressBar.Value = 50; grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(progressBar, new SourceGrid.Position(currentRow, 1))); currentRow++; //Custom Border Cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Border"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Views.Cell viewCustomBorder = new SourceGrid.Cells.Views.Cell(); viewCustomBorder.Border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.Red, 1), new DevAge.Drawing.BorderLine(Color.Blue, 1), new DevAge.Drawing.BorderLine(Color.Violet, 1), new DevAge.Drawing.BorderLine(Color.Green, 1)); grid[currentRow, 1] = new SourceGrid.Cells.Cell("Custom Border"); grid[currentRow, 1].View = viewCustomBorder; currentRow++; #endregion #region Custom Formatting grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Formatting"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Format grid[currentRow, 0] = new SourceGrid.Cells.Cell("Default Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); SourceGrid.Cells.Editors.TextBox editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); editorCustom.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(double)); DevAge.ComponentModel.Converter.NumberTypeConverter numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Percent Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Percent Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); SourceGrid.Cells.Editors.TextBox l_PercentEditor = new SourceGrid.Cells.Editors.TextBox(typeof(double)); l_PercentEditor.TypeConverter = new DevAge.ComponentModel.Converter.PercentTypeConverter(typeof(double)); grid[currentRow, 1].Editor = l_PercentEditor; currentRow++; //Currency Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Currency Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246M); SourceGrid.Cells.Editors.TextBox l_CurrencyEditor = new SourceGrid.Cells.Editors.TextBox(typeof(decimal)); l_CurrencyEditor.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(decimal)); grid[currentRow, 1].Editor = l_CurrencyEditor; currentRow++; //Format (#.00) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format #.00"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); numberFormatCustom.Format = "#.00"; editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Format ("0000.0000") grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format 0000.0000"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); numberFormatCustom.Format = "0000.0000"; editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Format ("Scientific (exponential)") grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format Scientific"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.0006); SourceGrid.Cells.Editors.TextBoxNumeric editorExponential = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double)); DevAge.ComponentModel.Converter.NumberTypeConverter exponentialConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double), "e"); exponentialConverter.NumberStyles = System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowExponent; editorExponential.TypeConverter = exponentialConverter; grid[currentRow, 1].Editor = editorExponential; currentRow++; //DateTime 2 (using custom formatting) string dtFormat2 = "yyyy MM dd"; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Date(" + dtFormat2 + ")"); grid[currentRow, 0].View = captionModel; string[] dtParseFormats = new string[] { dtFormat2 }; System.Globalization.DateTimeStyles dtStyles = System.Globalization.DateTimeStyles.AllowInnerWhite | System.Globalization.DateTimeStyles.AllowLeadingWhite | System.Globalization.DateTimeStyles.AllowTrailingWhite | System.Globalization.DateTimeStyles.AllowWhiteSpaces; TypeConverter dtConverter = new DevAge.ComponentModel.Converter.DateTimeTypeConverter(dtFormat2, dtParseFormats, dtStyles); SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDt2 = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime)); editorDt2.TypeConverter = dtConverter; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today); grid[currentRow, 1].Editor = editorDt2; currentRow++; //Text Ellipses grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Ellipses"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("This text is very very long and shows how to trim and add ellipses", typeof(string)); SourceGrid.Cells.Views.Cell ellipsesView = new SourceGrid.Cells.Views.Cell(); ellipsesView.TrimmingMode = SourceGrid.TrimmingMode.Word; grid[currentRow, 1].View = ellipsesView; currentRow++; #endregion #region Image And Text Properties grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image And Text Properties"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Cell Image SourceGrid.Cells.Cell cellImage1 = new SourceGrid.Cells.Cell("Single Image"); SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(captionModel); cellImage1.View = viewImage; grid[currentRow, 2] = cellImage1; cellImage1.RowSpan = 4; cellImage1.Image = Properties.Resources.FACE02.ToBitmap(); grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image Alignment"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageAlignment, typeof(DevAge.Drawing.ContentAlignment)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageAlignment"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Stretch Image"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageStretch, typeof(bool)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageStretch"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Alignment"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.TextAlignment, typeof(DevAge.Drawing.ContentAlignment)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("TextAlignment"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("DrawMode"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ElementsDrawMode, typeof(DevAge.Drawing.ElementsDrawMode)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ElementsDrawMode"), viewImage)); currentRow++; // Cell VisualModelMultiImages grid[currentRow, 1] = new SourceGrid.Cells.Cell("Multi Images"); SourceGrid.Cells.Views.MultiImages modelMultiImages = new SourceGrid.Cells.Views.MultiImages(); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE00.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE01.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE02.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE04.ToBitmap())); modelMultiImages.SubImages[0].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopLeft, false); modelMultiImages.SubImages[1].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopRight, false); modelMultiImages.SubImages[2].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomLeft, false); modelMultiImages.SubImages[3].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomRight, false); modelMultiImages.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; grid[currentRow, 1].View = modelMultiImages; grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid.Rows[currentRow].Height = 50; currentRow++; // Cell Rotated Text grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rotated by angle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Rotated Text", typeof(string)); SourceGrid.Cells.Views.Cell rotateView = new SourceGrid.Cells.Views.Cell(); rotateView.ElementText = new RotatedText(45); grid[currentRow, 1].View = rotateView; grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid.Rows[currentRow].Height = 50; currentRow++; // GDI+ Text grid[currentRow, 0] = new SourceGrid.Cells.Cell("GDI+ Text"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello from GDI+", typeof(string)); GDITextView gdiTextView = new GDITextView(); gdiTextView.FormatFlags = StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap; grid[currentRow, 1].View = gdiTextView; currentRow++; #endregion grid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.Columns[2].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.MinimumWidth = 50; grid.AutoSizeCells(); grid.AutoStretchColumnsToFitWidth = true; grid.Columns.StretchToFit(); }
private void frmSampleGrid1_Load(object sender, System.EventArgs e) { string[] l_CountryList = new string[]{"Italy","France","Spain","UK","Argentina","Mexico", "Switzerland", "Brazil", "Germany","Portugal","Sweden","Austria"}; grid1.RowsCount = 1; grid1.ColumnsCount = 10; grid1.FixedRows = 1; grid1.FixedColumns = 1; grid1.SelectionMode = SourceGrid.GridSelectionMode.Row; grid1.AutoStretchColumnsToFitWidth = true; grid1.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.None; grid1.Columns[0].Width = 25; grid1.Controller.AddController(new KeyDeleteController()); //TODO ////Enable Drag and Drop //grid1.GridController.AddController(SourceGrid.Controllers.SelectionDrag.Cut); //grid1.GridController.AddController(SourceGrid.Controllers.SelectionDrop.Default); #region Create Grid Style, Views and Controllers //Views mView_Price = new SourceGrid.Cells.Views.Cell(); mView_Price.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; mController_Link = new SourceGrid.Cells.Controllers.Button(); mController_Link.Executed += new EventHandler(mController_Link_Click); #endregion #region Create Header Row and Editor SourceGrid.Cells.Header l_00Header = new SourceGrid.Cells.Header(null); grid1[0,0] = l_00Header; mEditor_Id = SourceGrid.Cells.Editors.Factory.Create(typeof(int)); mEditor_Id.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,1] = new SourceGrid.Cells.ColumnHeader("ID (int)"); mEditor_Name = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); mEditor_Name.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,2] = new SourceGrid.Cells.ColumnHeader("NAME (string)"); mEditor_Address = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); mEditor_Address.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,3] = new SourceGrid.Cells.ColumnHeader("ADDRESS (string)"); mEditor_City = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); mEditor_City.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,4] = new SourceGrid.Cells.ColumnHeader("CITY (string)"); mEditor_BirthDay = SourceGrid.Cells.Editors.Factory.Create(typeof(DateTime)); mEditor_BirthDay.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,5] = new SourceGrid.Cells.ColumnHeader("BIRTHDATE (DateTime)"); mEditor_Country = new SourceGrid.Cells.Editors.ComboBox(typeof(string),l_CountryList,false); mEditor_Country.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,6] = new SourceGrid.Cells.ColumnHeader("COUNTRY (string + combobox)"); mEditor_Price = new SourceGrid.Cells.Editors.TextBoxCurrency(typeof(double)); mEditor_Price.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,7] = new SourceGrid.Cells.ColumnHeader("$ PRICE (double)"); grid1[0,8] = new SourceGrid.Cells.ColumnHeader("Selected"); grid1[0,9] = new SourceGrid.Cells.ColumnHeader("WebSite"); #endregion //Read Data From xml System.IO.StreamReader reader = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsSample.GridSamples.SampleData.xml")); System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(reader.ReadToEnd()); reader.Close(); System.Xml.XmlNodeList rows = xmlDoc.SelectNodes("//row"); grid1.RowsCount = rows.Count+1; int rowsCount = 1; foreach(System.Xml.XmlNode l_Node in rows) { #region Pupulate RowsCount grid1[rowsCount,0] = new SourceGrid.Cells.RowHeader(null); grid1[rowsCount,1] = new SourceGrid.Cells.Cell(rowsCount, mEditor_Id); grid1[rowsCount,2] = new SourceGrid.Cells.Cell(l_Node.Attributes["ContactName"].InnerText, mEditor_Name); grid1[rowsCount,3] = new SourceGrid.Cells.Cell(l_Node.Attributes["Address"].InnerText, mEditor_Address); grid1[rowsCount,4] = new SourceGrid.Cells.Cell(l_Node.Attributes["City"].InnerText, mEditor_City); grid1[rowsCount,5] = new SourceGrid.Cells.Cell(DateTime.Today, mEditor_BirthDay); grid1[rowsCount,6] = new SourceGrid.Cells.Cell(l_Node.Attributes["Country"].InnerText, mEditor_Country); grid1[rowsCount,7] = new SourceGrid.Cells.Cell(25.0, mEditor_Price); grid1[rowsCount, 7].View = mView_Price; grid1[rowsCount,8] = new SourceGrid.Cells.CheckBox(null, false); grid1[rowsCount,9] = new SourceGrid.Cells.Link(l_Node.Attributes["website"].InnerText); grid1[rowsCount,9].AddController(mController_Link); #endregion rowsCount++; } grid1.AutoSizeCells(); }
private void frmSample14_Load(object sender, System.EventArgs e) { grid1.Redim(20, 10); 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"); 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(DateTime.Today.AddDays(r), typeof(DateTime)); 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.AutoSizeCells(); }
private void btLoad_Click(object sender, System.EventArgs e) { using (var counter = new PerformanceCounter()) { grid.Redim(0, 0); //Visual properties shared between all the cells SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); view.BackColor = Color.Snow; //Editor (IDataModel) shared between all the cells SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text)); if (chkAddHeaders.Checked && grid.RowsCount > 0 && grid.ColumnsCount > 0) { grid.FixedRows = 1; grid.FixedColumns = 1; for (int r = grid.FixedRows; r < grid.RowsCount; r++) grid[r, 0] = new SourceGrid.Cells.RowHeader(r); for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++) { SourceGrid.Cells.ColumnHeader header = new SourceGrid.Cells.ColumnHeader(c); header.AutomaticSortEnabled = false; grid[0, c] = header; } grid[0, 0] = new SourceGrid.Cells.Header(); } else { grid.FixedRows = 0; grid.FixedColumns = 0; } for (int r = grid.FixedRows; r < grid.RowsCount; r++) for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++) { grid[r, c] = new SourceGrid.Cells.Cell(r.ToString() + "," + c.ToString()); grid[r, c].Editor = editor; grid[r, c].View = view; var span = 3; if (chkAddColspan.Checked && (c + span < grid.ColumnsCount)) { if (r % 2 == 0) { grid[r, c].ColumnSpan = span; c += span; } } } grid.Selection.Focus(new SourceGrid.Position(0, 0), true); this.toolStripStatusLabelBuildTime.Text = string.Format( "Rows added in {0} ms", counter.GetMilisec()); } }
private void SetupExtraGridFunctionality() { //Populate CostCentreList variable DataTable costCentreList = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.CostCentreList, FLedgerNumber); ACostCentreTable tmpCostCentreTable = new ACostCentreTable(); FMainDS.Tables.Add(tmpCostCentreTable); DataUtilities.ChangeDataTableToTypedDataTable(ref costCentreList, FMainDS.Tables[tmpCostCentreTable.TableName].GetType(), ""); FMainDS.RemoveTable(tmpCostCentreTable.TableName); FCostCentreTable = (ACostCentreTable)costCentreList; //Populate AccountList variable DataTable accountList = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, FLedgerNumber); AAccountTable tmpAccountTable = new AAccountTable(); FMainDS.Tables.Add(tmpAccountTable); DataUtilities.ChangeDataTableToTypedDataTable(ref accountList, FMainDS.Tables[tmpAccountTable.TableName].GetType(), ""); FMainDS.RemoveTable(tmpAccountTable.TableName); FAccountTable = (AAccountTable)accountList; //Prepare grid to highlight inactive accounts/cost centres // Create a cell view for special conditions SourceGrid.Cells.Views.Cell strikeoutCell = new SourceGrid.Cells.Views.Cell(); strikeoutCell.Font = new System.Drawing.Font(grdDetails.Font, FontStyle.Strikeout); //strikeoutCell.ForeColor = Color.Crimson; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAccountCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionAccountCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string accountCode = row[ABudgetTable.ColumnAccountCodeId].ToString(); return !AccountIsActive(accountCode); }; SourceGrid.Conditions.ConditionView conditionCostCentreCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionCostCentreCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string costCentreCode = row[ABudgetTable.ColumnCostCentreCodeId].ToString(); return !CostCentreIsActive(costCentreCode); }; //Add conditions to columns int indexOfCostCentreCodeDataColumn = 0; int indexOfAccountCodeDataColumn = 1; grdDetails.Columns[indexOfCostCentreCodeDataColumn].Conditions.Add(conditionCostCentreCodeActive); grdDetails.Columns[indexOfAccountCodeDataColumn].Conditions.Add(conditionAccountCodeActive); }
private void FillGrid() { SourceGrid.Cells.Views.Cell colTitleModel = new SourceGrid.Cells.Views.Cell { ElementText = new RotatedText(-90.0f), BackColor = Color.SteelBlue, ForeColor = Color.White, TextAlignment = DevAge.Drawing.ContentAlignment.BottomCenter }; SourceGrid.Cells.Views.Cell topleftTitleModel = new SourceGrid.Cells.Views.Cell { BackColor = Color.SteelBlue, ForeColor = Color.White, TextAlignment = DevAge.Drawing.ContentAlignment.BottomLeft }; SourceGrid.Cells.Views.Cell isActorModel = new SourceGrid.Cells.Views.Cell { BackColor = Color.Green, ForeColor = Color.Green, TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft }; SourceGrid.Cells.Views.Cell isGuestModel = new SourceGrid.Cells.Views.Cell { BackColor = Color.LightGreen, ForeColor = Color.LightGreen, TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft }; this.grid1.Columns.Clear(); this.grid1.Rows.Clear(); int rows = this.TheData.DataR + 2; // title and total int cols = this.TheData.DataC + 2; this.grid1.ColumnsCount = cols; this.grid1.RowsCount = rows; this.grid1.FixedColumns = 1; this.grid1.FixedRows = 1; this.grid1.Selection.EnableMultiSelection = false; for (int i = 0; i < cols; i++) { this.grid1.Columns[i].AutoSizeMode = i == 0 ? SourceGrid.AutoSizeMode.Default : SourceGrid.AutoSizeMode.MinimumSize; if (i > 0) this.grid1.Columns[i].Width = 24; } this.grid1.Rows[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; this.grid1.Rows[0].Height = 100; ColumnHeader h = new SourceGrid.Cells.ColumnHeader("Show") { AutomaticSortEnabled = false, ResizeEnabled = false }; this.grid1[0, 0] = h; this.grid1[0, 0].View = topleftTitleModel; this.grid1[0, 0].AddController(new SideClickEvent(this, null)); // default sort for (int c = 0; c < this.TheData.DataC; c++) { h = new SourceGrid.Cells.ColumnHeader(this.TheData.Cols[c]) { AutomaticSortEnabled = false, ResizeEnabled = false }; // "<A HREF=\"http://www.imdb.com/find?s=nm&q="+kvp->Key+"\">"+kvp->Key+"</a>"); // h->AddController(sortableController); // h->SortComparer = gcnew SourceGrid::MultiColumnsComparer(c, 0); // TODO: remove? this.grid1[0, c + 1] = h; this.grid1[0, c + 1].View = colTitleModel; this.grid1[0, c + 1].AddController(new TopClickEvent(this, this.TheData.Cols[c])); } int totalCol = this.grid1.ColumnsCount - 1; h = new SourceGrid.Cells.ColumnHeader("Totals") { AutomaticSortEnabled = false, ResizeEnabled = false }; //h->AddController(sortableController); // h->SortComparer = gcnew SourceGrid::MultiColumnsComparer(c, 0); this.grid1.Columns[totalCol].Width = 48; this.grid1[0, totalCol] = h; this.grid1[0, totalCol].View = colTitleModel; this.grid1[0, totalCol].AddController(new SortRowsByCountEvent(this)); for (int r = 0; r < this.TheData.DataR; r++) { this.grid1[r + 1, 0] = new SourceGrid.Cells.RowHeader(this.TheData.Rows[r]) { ResizeEnabled = false }; this.grid1[r + 1, 0].AddController(new SideClickEvent(this, this.TheData.Rows[r])); } this.grid1[this.TheData.DataR + 1, 0] = new SourceGrid.Cells.RowHeader("Totals") { ResizeEnabled = false }; this.grid1[this.TheData.DataR + 1, 0].AddController(new SortColsByCountEvent(this)); for (int c = 0; c < this.TheData.DataC; c++) { for (int r = 0; r < this.TheData.DataR; r++) { if (this.TheData.Data[r][c].HasValue) { this.grid1[r + 1, c + 1] = new SourceGrid.Cells.Cell("Y") { View = this.TheData.Data[r][c].Value ? isActorModel : isGuestModel }; this.grid1[r + 1, c + 1].AddController(new CellClickEvent(this.TheData.Cols[c], this.TheData.Rows[r])); } else this.grid1[r + 1, c + 1] = new SourceGrid.Cells.Cell(""); } } for (int c = 0; c < this.TheData.DataC; c++) this.grid1[rows - 1, c + 1] = new SourceGrid.Cells.Cell(this.TheData.ColScore(c)); for (int r = 0; r < this.TheData.DataR; r++) this.grid1[r + 1, cols - 1] = new SourceGrid.Cells.Cell(this.TheData.RowScore(r, null)); this.grid1[this.TheData.DataR + 1, this.TheData.DataC + 1] = new SourceGrid.Cells.Cell(""); this.grid1.AutoSizeCells(); }
private void CreateColumns(DevAge.ComponentModel.IBoundList boundList) { //Create the editors SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(decimal)); numericEditor.TypeConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(decimal), "N"); numericEditor.AllowNull = true; //the database value can be null (System.DbNull) SourceGrid.Cells.Editors.ComboBox externalIdEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(int)); externalIdEditor.StandardValues = new int[]{1, 2, 3, 4}; externalIdEditor.StandardValuesExclusive = true; externalIdEditor.Control.FormattingEnabled = true; DevAge.ComponentModel.Validator.ValueMapping mapping = new DevAge.ComponentModel.Validator.ValueMapping(); mapping.ValueList = new int[]{1, 2, 3, 4}; mapping.DisplayStringList = new string[] { "Reference 1", "Reference 2", "Reference 3", "Reference 4" }; mapping.BindValidator(externalIdEditor); //Create the views SourceGrid.Cells.Views.Cell viewSelected = new SourceGrid.Cells.Views.Cell(); viewSelected.Font = new Font(dataGrid.Font, FontStyle.Bold); viewSelected.ForeColor = Color.DarkGreen; //Create selected conditions SourceGrid.Conditions.ConditionView selectedConditionBold = new SourceGrid.Conditions.ConditionView(viewSelected); selectedConditionBold.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; return row["Selected"] is bool && (bool)row["Selected"] == true; }; SourceGrid.Conditions.ConditionCell selectedConditionStar = new SourceGrid.Conditions.ConditionCell(new SourceGrid.Cells.Virtual.CellVirtual()); selectedConditionStar.Cell.Model.AddModel(new SourceGrid.Cells.Models.Image(Properties.Resources.Star.ToBitmap())); selectedConditionStar.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; return row["Selected"] is bool && (bool)row["Selected"] == true; }; //Create columns SourceGrid.DataGridColumn gridColumn; gridColumn = dataGrid.Columns.Add("Selected", "Selected", typeof(bool)); gridColumn = dataGrid.Columns.Add("Country", "Country", typeof(string)); gridColumn.DataCell.Model.AddModel(new BoundImage("Uniform")); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("Uniform", "Uniform", new SourceGrid.Cells.DataGrid.Image()); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("Population", "Population", numericEditor); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("Surface", "Surface", numericEditor); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("ExternalID", "ExternalID", externalIdEditor); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("Star", "Star", new SourceGrid.Cells.Virtual.CellVirtual()); gridColumn.DataCell.Model.AddModel(new SourceGrid.Cells.Models.Image(Properties.Resources.StarOff)); gridColumn.Conditions.Add(selectedConditionStar); foreach (SourceGrid.DataGridColumn col in dataGrid.Columns) { col.DataCell.AddController(SourceGrid.Cells.Controllers.ToolTipText.Default); col.DataCell.Model.AddModel(MyToolTipModel.Default); } }
private void SetupGrid() { // manually add a forth column which displays the fields partner short name DataColumn FieldName = new DataColumn("FieldName", Type.GetType("System.String")); FMainDS.PPartnerGiftDestination.Columns.Add(FieldName); grdDetails.Columns.Clear(); grdDetails.AddDateColumn("Date Effective From", FMainDS.PPartnerGiftDestination.ColumnDateEffective); grdDetails.AddDateColumn("Date of Expiry", FMainDS.PPartnerGiftDestination.ColumnDateExpires); grdDetails.AddPartnerKeyColumn("Field Key", FMainDS.PPartnerGiftDestination.ColumnFieldKey); grdDetails.AddPartnerKeyColumn("Field Name", FieldName); foreach (DataRow Row in FMainDS.PPartnerGiftDestination.Rows) { string PartnerShortName; TPartnerClass PartnerClass; TRemote.MPartner.Partner.ServerLookups.WebConnectors.GetPartnerShortName( Convert.ToInt64(Row[PPartnerGiftDestinationTable.ColumnFieldKeyId]), out PartnerShortName, out PartnerClass); Row["FieldName"] = PartnerShortName; } // create a new column so we can to sort the table with null DateExpires values at the top DataColumn NewColumn = new DataColumn("Order", Type.GetType("System.DateTime")); FMainDS.PPartnerGiftDestination.Columns.Add(NewColumn); foreach (DataRow Row in FMainDS.PPartnerGiftDestination.Rows) { if (Row["p_date_expires_d"] == DBNull.Value) { Row["Order"] = DateTime.MaxValue; } else { Row["Order"] = Row["p_date_expires_d"]; } } DataView myDataView = FMainDS.PPartnerGiftDestination.DefaultView; myDataView.Sort = "Order DESC, p_date_effective_d DESC"; myDataView.AllowNew = false; grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(myDataView); grdDetails.Columns.AutoSize(false); //Prepare grid to highlight inactive Gift Destinations SourceGrid.Cells.Views.Cell strikeoutCell = new SourceGrid.Cells.Views.Cell(); strikeoutCell.Font = new System.Drawing.Font(grdDetails.Font, FontStyle.Strikeout); // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView condition = new SourceGrid.Conditions.ConditionView(strikeoutCell); condition.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; if (row[PPartnerGiftDestinationTable.ColumnDateEffectiveId].ToString() == row[PPartnerGiftDestinationTable.ColumnDateExpiresId].ToString()) { return true; } return false; }; // add condtion to grid columns grdDetails.Columns[0].Conditions.Add(condition); grdDetails.Columns[1].Conditions.Add(condition); grdDetails.Columns[2].Conditions.Add(condition); grdDetails.Columns[3].Conditions.Add(condition); }
private void SetupAnalysisAttributeGrid(TSgrdDataGridPaged AGrid, ref SourceGrid.Cells.Editors.ComboBox AGridCombo) { AGrid.DataSource = null; GLBatchTDS DS = null; SourceGrid.Cells.Editors.ComboBox ATempCombo = null; if (AGrid.Name == grdFromAnalAttributes.Name) { FTempFromDS = (GLBatchTDS)FMainDS.Clone(); DS = FTempFromDS; } else { DS = FMainDS; } if (AGrid.Columns.Count == 0) { ATempCombo = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); ATempCombo.EnableEdit = true; ATempCombo.EditableMode = EditableMode.Focus; AGrid.Columns.Clear(); AGrid.AddTextColumn(Catalog.GetString("Type"), FMainDS.ATransAnalAttrib.ColumnAnalysisTypeCode, 99); AGrid.AddTextColumn(Catalog.GetString("Value"), DS.ATransAnalAttrib.Columns[ATransAnalAttribTable.GetAnalysisAttributeValueDBName()], 150, ATempCombo); } FAnalysisAttributesLogic.SetTransAnalAttributeDefaultView(DS, true); DS.ATransAnalAttrib.DefaultView.AllowNew = false; AGrid.DataSource = new DevAge.ComponentModel.BoundDataView(DS.ATransAnalAttrib.DefaultView); AGrid.SetHeaderTooltip(0, Catalog.GetString("Type")); AGrid.SetHeaderTooltip(1, Catalog.GetString("Value")); AGrid.Selection.SelectionChanged += AnalysisAttributesGrid_RowSelected; //Prepare Analysis attributes grid to highlight inactive analysis codes // Create a cell view for special conditions SourceGrid.Cells.Views.Cell strikeoutCell2 = new SourceGrid.Cells.Views.Cell(); strikeoutCell2.Font = new System.Drawing.Font(AGrid.Font, FontStyle.Strikeout); // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAnalysisCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2); conditionAnalysisCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2) { DataRowView row2 = (DataRowView)itemRow2; string analysisCode = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString(); if (AGrid.Name == grdFromAnalAttributes.Name) { return !FAnalysisAttributesLogic.AnalysisCodeIsActive( FPreviouslySelectedAccountsRow[AGeneralLedgerMasterTable.GetAccountCodeDBName()].ToString(), FCacheDS.AAnalysisAttribute, analysisCode); } return !FAnalysisAttributesLogic.AnalysisCodeIsActive( cmbDetailAccountCode.GetSelectedString(), FCacheDS.AAnalysisAttribute, analysisCode); }; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAnalysisAttributeValueActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2); conditionAnalysisAttributeValueActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2) { if (itemRow2 != null) { DataRowView row2 = (DataRowView)itemRow2; string analysisCode = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString(); string analysisAttributeValue = row2[ATransAnalAttribTable.ColumnAnalysisAttributeValueId].ToString(); return !TAnalysisAttributes.AnalysisAttributeValueIsActive(ref ATempCombo, FCacheDS.AFreeformAnalysis, analysisCode, analysisAttributeValue); } else { return false; } }; //Add conditions to columns int indexOfAnalysisCodeColumn = 0; int indexOfAnalysisAttributeValueColumn = 1; AGrid.Columns[indexOfAnalysisCodeColumn].Conditions.Add(conditionAnalysisCodeActive); AGrid.Columns[indexOfAnalysisAttributeValueColumn].Conditions.Add(conditionAnalysisAttributeValueActive); AGridCombo = ATempCombo; }
/// <summary> /// Chargement de la Liste des Photographes /// </summary> private void loadLstView() { int numLigne = 0; for (int i = 0; i < p_applClass.Param.ListPhotographe.Count; i++) { numLigne++; gridPhoto.Rows.Insert(numLigne); gridPhoto[numLigne, 0] = new SourceGrid.Cells.Cell(p_applClass.Param.ListPhotographe[i].Nom); gridPhoto[numLigne, 1] = new SourceGrid.Cells.Cell(p_applClass.Param.ListPhotographe[i].EMailPhotograph); SourceGrid.Cells.Cell l_Cell = new SourceGrid.Cells.Cell(); SourceGrid.Cells.Cell colorCell = new SourceGrid.Cells.Cell(); SourceGrid.Cells.Views.Cell viewColor = new SourceGrid.Cells.Views.Cell(); viewColor.BackColor = Color.FromArgb(p_applClass.Param.ListPhotographe[i].GetColor()); colorCell.View = viewColor; gridPhoto[numLigne, 2] = colorCell; } numLigne++; gridPhoto.Rows.Insert(numLigne); gridPhoto[numLigne, 0] = new SourceGrid.Cells.Cell("Cliquer pour créer un nouveau"); gridPhoto[numLigne, 0].ColumnSpan = 3; }
private void SetupGrid() { Grid1.Columns.Clear(); Grid1.Rows.Clear(); Grid1.RowsCount = 1; Grid1.ColumnsCount = 4; Grid1.FixedRows = 1; Grid1.FixedColumns = 0; Grid1.Selection.EnableMultiSelection = false; Grid1.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.None; Grid1.Columns[0].Width = 60; Grid1.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize | SourceGrid.AutoSizeMode.EnableStretch; Grid1.Columns[2].AutoSizeMode = SourceGrid.AutoSizeMode.None; Grid1.Columns[2].Width = 60; Grid1.Columns[3].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize | SourceGrid.AutoSizeMode.EnableStretch; Grid1.AutoStretchColumnsToFitWidth = true; Grid1.Columns.StretchToFit(); ////////////////////////////////////////////////////////////////////// // header row SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell { BackColor = Color.SteelBlue, ForeColor = Color.White, TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft }; SourceGrid.Cells.Views.Cell titleModelC = new SourceGrid.Cells.Views.Cell { BackColor = Color.SteelBlue, ForeColor = Color.White, TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter }; Grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("Enabled") { AutomaticSortEnabled = false, View = titleModelC }; Grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("Regex") { AutomaticSortEnabled = false, View = titleModel }; Grid1[0, 2] = new SourceGrid.Cells.ColumnHeader("Full Path") { AutomaticSortEnabled = false, View = titleModelC }; Grid1[0, 3] = new SourceGrid.Cells.ColumnHeader("Notes") { AutomaticSortEnabled = false, View = titleModel }; Grid1.Selection.SelectionChanged += SelectionChanged; }
public void DoFill(List<Order> list) { OrderGrid.Redim(0, 0); OrderGrid.FixedRows = 1; OrderGrid.EnableSort = true; int RowNum = IsFinOrderView ? list.Count + 2 : list.Count + 1; OrderGrid.Redim(RowNum, 7); OrderGrid.Rows[0].Height = 25; OrderGrid[0, 0] = new MyHeader("开始日期"); OrderGrid[0, 0].Column.Width = 100; OrderGrid[0, 0].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); OrderGrid[0, 1] = new MyHeader("结束日期"); OrderGrid[0, 1].Column.Width = 100; OrderGrid[0, 1].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); OrderGrid[0, 2] = new MyHeader("订单编号"); OrderGrid[0, 2].Column.Width = 100; OrderGrid[0, 2].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); OrderGrid[0, 3] = new MyHeader("订单描述"); OrderGrid[0, 3].Column.Width = 300; OrderGrid[0, 3].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); OrderGrid[0, 4] = new MyHeader("业务员"); OrderGrid[0, 4].Column.Width = 100; OrderGrid[0, 4].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); OrderGrid[0, 5] = new MyHeader("订单状态"); OrderGrid[0, 5].Column.Width = 150; OrderGrid[0, 5].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); if (!IsFinOrderView) { OrderGrid[0, 6] = new MyHeader("备注"); OrderGrid[0, 6].Column.Width = 200; } else { OrderGrid[0, 6] = new MyHeader("业务总金额"); OrderGrid[0, 6].Column.Width = 150; OrderGrid[0, 6].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); } SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents(); clickEvent.DoubleClick += new EventHandler(clickEvent_Click); int r = 1; double TotalAmount = 0; foreach (Order order in list) { OrderGrid.Rows[r].Tag = order.Id; OrderGrid.Rows[r].Height = 25; OrderGrid[r, 0] = new SourceGrid.Cells.Cell(order.BeginDate); OrderGrid[r, 0].AddController(clickEvent); OrderGrid[r, 1] = new SourceGrid.Cells.Cell(order.EndDate); OrderGrid[r, 1].AddController(clickEvent); OrderGrid[r, 2] = new SourceGrid.Cells.Cell(order.OrderNo); OrderGrid[r, 2].AddController(clickEvent); OrderGrid[r, 3] = new SourceGrid.Cells.Cell(order.Description); OrderGrid[r, 3].AddController(clickEvent); OrderGrid[r, 4] = new SourceGrid.Cells.Cell(order.SalesMan); OrderGrid[r, 5] = new SourceGrid.Cells.Cell(order.Status); if (!IsFinOrderView) { OrderGrid[r, 6] = new SourceGrid.Cells.Cell(order.Remark); } else { TotalAmount = TotalAmount + order.TotalAmount; string totalAmount = "¥" + order.TotalAmount.ToString("#,##0.00"); OrderGrid[r, 6] = new SourceGrid.Cells.Cell(totalAmount); SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; view.ForeColor = FileUtils.GetColor(order.TotalAmount); OrderGrid[r, 6].View = view; } r++; } if (IsFinOrderView) { for (int i = 0; i < 6; i++) { OrderGrid[r, i] = new SourceGrid.Cells.Cell(""); } OrderGrid[r, 3] = new SourceGrid.Cells.Cell("合计"); OrderGrid[r, 6] = new SourceGrid.Cells.Cell("¥" + TotalAmount.ToString("#,##0.00")); SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; view.ForeColor = FileUtils.GetColor(TotalAmount); OrderGrid[r, 6].View = view; } OrderGrid.ClipboardMode = SourceGrid.ClipboardMode.All; }
/// <summary> /// Occurs when loading this control. /// </summary> /// <param name="eventArgs"> /// The <see cref="EventArgs"/>. /// </param> protected override void OnLoad(EventArgs eventArgs) { const int numberOfRows = 6; const int numberOfCols = 4; grid.Redim(numberOfRows, numberOfCols); grid.FixedRows = 1; grid.FixedColumns = 1; grid.SelectionMode = SourceGrid.GridSelectionMode.Row; grid.ToolTipText = "Linked Controls"; grid[0, 0] = new SourceGrid.Cells.Header(null); // Create column header for (int i = 0; i < numberOfCols; i++) { string label; switch (i) { case 1: label = "Description"; break; case 2: label = "Value"; break; case 3: label = "Unit"; break; default: label = null; break; } var header = new SourceGrid.Cells.ColumnHeader(label) { AutomaticSortEnabled = false }; grid[0, i] = header; } // Create some entries SourceGrid.Cells.Views.Cell visualAspect = new SourceGrid.Cells.Views.Cell(); for (int i = 1; i < numberOfRows; i++) { string label; string unit; Control usedControl; SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText(); toolTipController.IsBalloon = true; switch (i) { case 1: label = "Numeric Up Down [3...15]"; unit = "µs"; usedControl = new NumericUpDown(); (usedControl as NumericUpDown).Minimum = 3; (usedControl as NumericUpDown).Maximum = 15; (usedControl as NumericUpDown).Increment = 2; (usedControl as NumericUpDown).Value = 7; break; case 2: label = "Text box with max. length of 15 chars."; unit = ":o)"; usedControl = new TextBox(); (usedControl as TextBox).MaxLength = 15; (usedControl as TextBox).Text = "Some Text"; break; case 3: label = "Disabled text box"; unit = "^_^"; usedControl = new TextBox(); (usedControl as TextBox).Enabled = false; (usedControl as TextBox).Text = "Some disabled Text"; break; case 4: label = "Combo box with auto complete"; unit = "Prio."; usedControl = new ComboBox(); (usedControl as ComboBox).Items.AddRange( new object[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }); (usedControl as ComboBox).AutoCompleteMode = AutoCompleteMode.SuggestAppend; (usedControl as ComboBox).AutoCompleteSource = AutoCompleteSource.ListItems; break; default: label = "Progress bar"; unit = ""; Random randNmbr = new Random(); usedControl = new ProgressBar(); (usedControl as ProgressBar).Value = randNmbr.Next(0, 100); break; } grid[i, 1] = new SourceGrid.Cells.Cell { View = visualAspect, Value = label, ToolTipText = label + "..." + unit }; grid[i, 1].AddController(toolTipController); grid[i, 2] = new SourceGrid.Cells.Cell(); usedControl.Enter += delegate(object sender, EventArgs e) { IsRechangingSelection = true; foreach (RowInfo rowInfo in grid.Rows) { grid.Selection.SelectRow(rowInfo.Index, false); } foreach (LinkedControlValue lcv in grid.LinkedControls) { if (lcv.Control == usedControl) { grid.Selection.SelectRow(lcv.Position.Row, true); break; } } IsRechangingSelection = false; }; grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(usedControl, new SourceGrid.Position(i, 2))); grid[i, 3] = new SourceGrid.Cells.Cell { View = visualAspect, Value = unit }; } if (grid.Columns[2].MinimalWidth < 127) { grid.Columns[2].MinimalWidth = 127; } grid.VScrollBar.ValueChanged += delegate(object sender, EventArgs valueChangedEventArgs) { // Hide all linked controls above 'new value' // Show all linked controls beyond 'new value' foreach (LinkedControlValue lcv in grid.LinkedControls) { lcv.Control.Visible = lcv.Position.Row > grid.VScrollBar.Value; } // Reselecting works more or less when scrolling down. But what when scrolling up? if (grid.Selection.ActivePosition.Row <= grid.VScrollBar.Value) { IsRechangingSelection = false; foreach (LinkedControlValue lcv in grid.LinkedControls) { grid.Selection.SelectRow(lcv.Position.Row, false); } IsRechangingSelection = true; grid.Selection.SelectRow(grid.VScrollBar.Value + 1, true); } }; // Focus the custom control when changing selection grid.Selection.SelectionChanged += delegate(object sender, RangeRegionChangedEventArgs e) { if (!IsRechangingSelection && e.AddedRange != null && e.RemovedRange == null) { bool isFound = false; int selectedRow = -1; int selectedCol = -1; int[] selectedRows = e.AddedRange.GetRowsIndex(); if (sender is SourceGrid.Selection.SelectionBase) { selectedRow = (sender as SourceGrid.Selection.SelectionBase).ActivePosition.Row; selectedCol = (sender as SourceGrid.Selection.SelectionBase).ActivePosition.Column; } if (selectedRows[0] != -1) { selectedRow = selectedRows[0]; } foreach (LinkedControlValue lcv in grid.LinkedControls) { if (lcv.Position.Row == selectedRow) { // Remove focus from control isFound = true; lcv.Control.Focus(); break; } } if (!isFound) { IsRechangingSelection = true; grid.Selection.Focus(new Position(selectedRow, selectedCol), true); IsRechangingSelection = false; } } }; }
public void DoFill(List<Finance> list) { int rowCount = 3; foreach (Finance finance in list) { rowCount = rowCount + finance.Details.Count; } FinGrid.Redim(0, 0); FinGrid.FixedRows = 2; FinGrid.FixedColumns = 3; FinGrid.EnableSort = true; FinGrid.Redim(rowCount, 15); FinGrid[0, 0] = new MyHeader("日期"); FinGrid[0, 0].RowSpan = 2; FinGrid[0, 0].Column.Width = 100; FinGrid[0, 1] = new MyHeader("收支类型"); FinGrid[0, 1].RowSpan = 2; FinGrid[0, 1].Column.Width = 70; FinGrid[0, 2] = new MyHeader("款项描述"); FinGrid[0, 2].RowSpan = 2; FinGrid[0, 2].Column.Width = 250; FinGrid[0, 3] = new MyHeader("金额"); FinGrid[0, 3].RowSpan = 2; FinGrid[0, 3].Column.Width = 100; FinGrid[0, 4] = new MyHeader("汇率"); FinGrid[0, 4].RowSpan = 2; FinGrid[0, 4].Column.Width = 100; FinGrid[0, 5] = new MyHeader("总金额"); FinGrid[0, 5].RowSpan = 2; FinGrid[0, 5].Column.Width = 150; FinGrid[0, 6] = new MyHeader("流水号"); FinGrid[0, 6].RowSpan = 2; FinGrid[0, 6].Column.Width = 100; FinGrid[0, 7] = new MyHeader("收付款单位"); FinGrid[0, 7].RowSpan = 2; FinGrid[0, 7].Column.Width = 100; FinGrid[0, 8] = new MyHeader("经手人/相关人"); FinGrid[0, 8].RowSpan = 2; FinGrid[0, 8].Column.Width = 100; FinGrid[0, 9] = new MyHeader("备注"); FinGrid[0, 9].RowSpan = 2; FinGrid[0, 9].Column.Width = 150; FinGrid[0, 10] = new MyHeader("明细"); FinGrid[0, 10].ColumnSpan = 5; FinGrid[1, 10] = new MyHeader("描述"); FinGrid[1, 10].Column.Width = 200; FinGrid[1, 11] = new MyHeader("所属业务"); FinGrid[1, 11].Column.Width = 100; FinGrid[1, 12] = new MyHeader("金额"); FinGrid[1, 12].Column.Width = 150; FinGrid[1, 13] = new MyHeader("总金额"); FinGrid[1, 13].Column.Width = 150; FinGrid[1, 14] = new MyHeader("备注"); FinGrid[1, 14].Column.Width = 300; SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents(); clickEvent.DoubleClick += new EventHandler(clickEvent_Click); SourceGrid.Cells.Views.Cell view; int r = 2; double SumTotalAmount = 0.0; double DetailSumTotalAmount = 0.0; foreach (Finance finance in list) { int detailCount = finance.Details.Count(); FinGrid.Rows[r].Height = 22; FinGrid[r, 0] = new SourceGrid.Cells.Cell(finance.FinDate); FinGrid[r, 0].AddController(clickEvent); FinGrid[r, 1] = new SourceGrid.Cells.Cell(finance.EventType); FinGrid[r, 1].AddController(clickEvent); FinGrid[r, 2] = new SourceGrid.Cells.Cell(finance.Description); FinGrid[r, 2].AddController(clickEvent); string amount = "(" + finance.Currency + ")" + finance.Amount.ToString("#,##0.00"); FinGrid[r, 3] = new SourceGrid.Cells.Cell(amount); FinGrid[r, 3].AddController(clickEvent); view = new SourceGrid.Cells.Views.Cell(); view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; view.ForeColor = FileUtils.GetColor(finance.TotalAmount); FinGrid[r, 3].View = view; string rate = finance.Rate.ToString("#,##0.0000"); FinGrid[r, 4] = new SourceGrid.Cells.Cell(rate); view = new SourceGrid.Cells.Views.Cell(); view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; FinGrid[r, 4].View = view; string totalAmount= "¥" + finance.TotalAmount.ToString("#,##0.00"); SumTotalAmount = SumTotalAmount + finance.TotalAmount; FinGrid[r, 5] = new SourceGrid.Cells.Cell(totalAmount); view = new SourceGrid.Cells.Views.Cell(); view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; view.ForeColor = FileUtils.GetColor(finance.TotalAmount); FinGrid[r, 5].View = view; FinGrid[r, 6] = new SourceGrid.Cells.Cell(finance.ReferenceNo); FinGrid[r, 7] = new SourceGrid.Cells.Cell(finance.ReceivePaymentor); FinGrid[r, 8] = new SourceGrid.Cells.Cell(finance.Association); FinGrid[r, 9] = new SourceGrid.Cells.Cell(finance.Remark); FinGrid[r, 0].RowSpan = detailCount; FinGrid[r, 1].RowSpan = detailCount; FinGrid[r, 2].RowSpan = detailCount; FinGrid[r, 3].RowSpan = detailCount; FinGrid[r, 4].RowSpan = detailCount; FinGrid[r, 5].RowSpan = detailCount; FinGrid[r, 6].RowSpan = detailCount; FinGrid[r, 7].RowSpan = detailCount; FinGrid[r, 8].RowSpan = detailCount; FinGrid[r, 9].RowSpan = detailCount; foreach (FinDetails detail in finance.Details) { FinGrid.Rows[r].Tag = finance.FinId; FinGrid.Rows[r].Height = 22; FinGrid[r, 10] = new SourceGrid.Cells.Cell(detail.Description); FinGrid[r, 11] = new SourceGrid.Cells.Cell(detail.OrderNo); string detailAmount = "(" + finance.Currency + ")" + detail.Amount.ToString("#,##0.00"); FinGrid[r, 12] = new SourceGrid.Cells.Cell(detailAmount); view = new SourceGrid.Cells.Views.Cell(); view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; view.ForeColor = FileUtils.GetColor(finance.TotalAmount); FinGrid[r, 12].View = view; string detailTotalAmount = "¥" + detail.TotalAmount.ToString("#,##0.00"); DetailSumTotalAmount = DetailSumTotalAmount + detail.TotalAmount; FinGrid[r, 13] = new SourceGrid.Cells.Cell(detailTotalAmount); view = new SourceGrid.Cells.Views.Cell(); view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; view.ForeColor = FileUtils.GetColor(finance.TotalAmount); FinGrid[r, 13].View = view; FinGrid[r, 14] = new SourceGrid.Cells.Cell(detail.Remark); r++; } } for (int i = 0; i < 15; i++) { FinGrid[r, i] = new SourceGrid.Cells.Cell(""); } FinGrid.Rows[r].Height = 22; FinGrid[r, 2] = new SourceGrid.Cells.Cell("合计"); FinGrid[r, 5] = new SourceGrid.Cells.Cell("¥" + SumTotalAmount.ToString("#,##0.00")); FinGrid[r, 13] = new SourceGrid.Cells.Cell("¥" + DetailSumTotalAmount.ToString("#,##0.00")); view = new SourceGrid.Cells.Views.Cell(); view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; view.ForeColor = FileUtils.GetColor(SumTotalAmount); FinGrid[r, 5].View = FinGrid[r, 13].View = view; FinGrid.ClipboardMode = SourceGrid.ClipboardMode.All; }