private void DoFiltering() { Table table = this.table; // The Table control on a form - already initialised table.Clear(); table.BeginUpdate(); table.EnableWordWrap = true; // If false, then Cell.WordWrap is ignored table.EnableFilters = true; table.HeaderFilterClick += Table_HeaderFilterClick; NumberColumn col0 = new NumberColumn("#", 20); NumberColumn col1 = new NumberColumn("Height", 50); TextColumn col2 = new TextColumn("Name", 80); _filter = col2.Filter as TextColumnFilter; col2.Filterable = true; TextColumn col3 = new TextColumn("Surname", 80); col3.Filterable = true; DateTimeColumn col4 = new DateTimeColumn("Birthday", 120); TextColumn col5 = new TextColumn("Comments", 100); table.ColumnModel = new ColumnModel(new Column[] { col0, col1, col2, col3, col4, col5 }); TableModel model = new TableModel(); AddRow(model, 1, 1.52, "Mark", "Hobbs", "23/1/1978", "likes apples"); AddRow(model, 2, 1.76, "Dave", "Duke", "2/5/1977", "keeps fish"); AddRow(model, 3, 1.64, "Holly", "Prench", "14/8/1979", "singer"); AddRow(model, 4, 1.53, "Mark", "Hobbs", "23/1/1984", "plays football"); AddRow(model, 4, 1.53, "Mark", "Prench", "23/1/1984", "shoots arrows"); AddRow(model, 5, 1.64, "Dave", "Hobbs", "19/1/1980", "vegetarian"); this.table.TableModel = model; this.table.EndUpdate(); }
/// <summary> /// Returns the type of column that is appropriate for the given property of the data source. /// Numbers, DateTime, Color and Boolean columns are mapped to NumberColumn, DateTimeColumn, ColorColumn and CheckBoxColumn respectively. The default /// is just a TextColumn. /// </summary> /// <param name="prop"></param> /// <param name="index"></param> /// <returns></returns> public virtual Column GetColumn(PropertyDescriptor prop, int index) { Column column; var propertyType = prop.PropertyType; switch (propertyType.Name) { case nameof(Int32): case nameof(Double): case nameof(Single): case nameof(Int16): case nameof(Int64): case nameof(Decimal): var fieldMin = propertyType.GetField("MinValue"); var fieldMax = propertyType.GetField("MaxValue"); column = new DoubleColumn(prop.Name) { Minimum = (double)fieldMin.GetValue(propertyType), Maximum = (double)fieldMax.GetValue(propertyType), }; break; case "DateTime": column = new DateTimeColumn(prop.Name); break; case "Color": column = new ColorColumn(prop.Name); break; case "Boolean": column = new CheckBoxColumn(prop.Name); break; default: column = new TextColumn(prop.Name); break; } return(column); }
public ColumnModel getColumnModel() { //1. oszlop ImageColumn imageColumn = new ImageColumn("", 30); imageColumn.Editable = false; TextColumn textColumn = new TextColumn("név", 110); textColumn.Editable = false; NumberColumn ertekColumn = new NumberColumn("érték", 50); ertekColumn.Editable = false; DateTimeColumn datetimeColumn = new DateTimeColumn("idő", 70); datetimeColumn.DateTimeFormat = DateTimePickerFormat.Time; datetimeColumn.Editable = false; datetimeColumn.ShowDropDownButton = false; return(new ColumnModel(new Column[] {imageColumn, datetimeColumn, textColumn, ertekColumn })); }
private static DateTimeColumn CreateDateTimeColumn(string header, int width) { var col = new DateTimeColumn(header, width) { CustomDateTimeFormat = "d-MM H:mm", DateTimeFormat = System.Windows.Forms.DateTimePickerFormat.Custom, Editable = false, ShowDropDownButton = false }; return col; }
private void setColumnModelSum() { //1. oszlop ImageColumn imageColumn = new ImageColumn("", 30); imageColumn.Editable = false; NumberColumn numberColumn = new NumberColumn("db", 28); numberColumn.Editable = false; TextColumn textColumn = new TextColumn("név", 110); textColumn.Editable = false; NumberColumn ertekColumn = new NumberColumn("érték", 50); ertekColumn.Editable = false; DateTimeColumn datetimeColumn = new DateTimeColumn("idő", 70); datetimeColumn.DateTimeFormat = DateTimePickerFormat.Time; datetimeColumn.Editable = false; datetimeColumn.ShowDropDownButton = false; _ColumnModelSum = new ColumnModel(new Column[] { numberColumn, textColumn, ertekColumn }); }
private void DoSorting(bool withMulti) { Table table = this.table; // The Table control on a form - already initialised table.Clear(); table.BeginUpdate(); table.EnableWordWrap = true; // If false, then Cell.WordWrap is ignored NumberColumn col0 = new NumberColumn("#", 20); NumberColumn col1 = new NumberColumn("Height", 50); TextColumn col2 = new TextColumn("Name", 80); TextColumn col3 = new TextColumn("Surname", 80); DateTimeColumn col4 = new DateTimeColumn("Birthday", 120); TextColumn col5 = new TextColumn("Comments", 100); table.ColumnModel = new ColumnModel(new Column[] { col0, col1, col2, col3, col4, col5 }); if (withMulti) { // Surname, Name, Height (descending) SortColumnCollection sort = new SortColumnCollection(); sort.Add(new SortColumn(3, SortOrder.Ascending)); // Surname sort.Add(new SortColumn(2, SortOrder.Ascending)); // Name sort.Add(new SortColumn(1, SortOrder.Descending)); // Height table.ColumnModel.SecondarySortOrders = sort; } TableModel model = new TableModel(); AddSortingRow(model, 1, 1.52, "Mark", "Hobbs", "23/1/1978", "likes apples"); AddSortingRow(model, 2, 1.76, "Dave", "Duke", "2/5/1977", "keeps fish"); AddSortingRow(model, 3, 1.64, "Holly", "Prench", "14/8/1979", "singer"); AddSortingRow(model, 4, 1.53, "Mark", "Hobbs", "23/1/1984", "plays football"); AddSortingRow(model, 5, 1.64, "Dave", "Hobbs", "19/1/1980", "vegetarian"); this.table.TableModel = model; this.table.EndUpdate(); }
/// <summary> /// Returns the type of column that is appropriate for the given property of the data source. /// Numbers, DateTime, Color and Boolean columns are mapped to NumberColumn, DateTimeColumn, ColorColumn and CheckBoxColumn respectively. The default /// is just a TextColumn. /// </summary> /// <param name="prop"></param> /// <param name="index"></param> /// <returns></returns> public virtual Column GetColumn(PropertyDescriptor prop, int index) { NumberColumn numCol = null; Column column = null; switch (prop.PropertyType.Name) { case "Int32": numCol = new NumberColumn(prop.Name); numCol.Maximum = Int32.MaxValue; numCol.Minimum = Int32.MinValue; column = numCol; break; case "Double": numCol = new NumberColumn(prop.Name); numCol.Maximum = Decimal.MaxValue; numCol.Minimum = Decimal.MinValue; column = numCol; break; case "Float": numCol = new NumberColumn(prop.Name); numCol.Maximum = Convert.ToDecimal(float.MaxValue); numCol.Minimum = Convert.ToDecimal(float.MinValue); column = numCol; break; case "Int16": numCol = new NumberColumn(prop.Name); numCol.Maximum = Int16.MaxValue; numCol.Minimum = Int16.MinValue; column = numCol; break; case "Int64": numCol = new NumberColumn(prop.Name); numCol.Maximum = Int64.MaxValue; numCol.Minimum = Int64.MinValue; column = numCol; break; case "Decimal": numCol = new NumberColumn(prop.Name); numCol.Maximum = Decimal.MaxValue; numCol.Minimum = Decimal.MinValue; column = numCol; break; case "DateTime": column = new DateTimeColumn(prop.Name); break; case "Color": column = new ColorColumn(prop.Name); break; case "Boolean": column = new CheckBoxColumn(prop.Name); break; default: column = new TextColumn(prop.Name); break; } return(column); }
private void DoGroup() { Table table = this.table; // The Table control on a form - already initialised //table.Font = new Font(table.Font.FontFamily, 12f); table.SelectionStyle = SelectionStyle.Grid; table.BeginUpdate(); table.EnableWordWrap = true; // If false, then Cell.WordWrap is ignored table.FamilyRowSelect = true; table.FullRowSelect = true; table.ShowSelectionRectangle = false; table.MultiSelect = true; table.GridLines = GridLines.Both; GroupColumn col0 = new GroupColumn("", 20); // this is the NEW +/- column col0.Editable = false; // Double clicking on this is to toggle the collapsed state col0.Selectable = false; col0.ToggleOnSingleClick = true; ImageColumn col1 = new ImageColumn("", 20); TextColumn col2 = new TextColumn("From", 200); DateTimeColumn col3 = new DateTimeColumn("Sent", 180); /// 493 col3.ShowDropDownButton = false; col3.DateTimeFormat = DateTimePickerFormat.Custom; col3.CustomDateTimeFormat = "d/M/yyyy hh:mm"; col3.Alignment = ColumnAlignment.Right; col3.AutoResizeMode = ColumnAutoResizeMode.Any; //NumberColumn col4 = new NumberColumn("num", 60); //col4.ShowUpDownButtons = true; ButtonColumn col4 = new ButtonColumn("butt"); col4.FlatStyle = true; table.ColumnModel = new ColumnModel(new Column[] { col0, col1, col2, col3, col4 }); TableModel model = new TableModel(); //model.RowHeight = 24; AddEmailRows(model, true, "Dave ", "4/9/2007 12:34", "Here is the email subject", "Here is a preview of the text that is in the email. It wraps over too so you can see more of it"); AddEmailRows(model, false, "Richard Richard Richard Richard Richard Richard Richard Richard Richard Richard Richard Richard Richard Richard", "5/4/2007 9:13", "An email abut something", "Another preview of another ficticious email. Not much to say really"); AddEmailRows(model, true, "Andy", "13/2/2007 9:45", "Work stuff", "Can you get this finished by this afternoon please? Thanks"); // Make and add the context menu: ContextMenu menu = new ContextMenu(); MenuItem delete = new MenuItem("Delete"); delete.Click += new EventHandler(delete_Click); menu.MenuItems.Add(delete); table.ContextMenu = menu; // Add an event handler for the key event table.CellKeyUp += new CellKeyEventHandler(table_CellKeyUp); table.CellButtonClicked += new CellButtonEventHandler(table_CellButtonClicked); table.CellMouseDown += new CellMouseEventHandler(table_CellMouseDown); table.CellMouseUp += new CellMouseEventHandler(table_CellMouseUp); this.table.TableModel = model; this.table.EndUpdate(); return; #region Tracer stuff //_tracer = new Tracer(table, OnEventTrace); //_tracer.HookEvent("BeginEditing"); //_tracer.HookEvent("CellClick"); //_tracer.HookEvent("CellDoubleClick"); //_tracer.HookEvent("CellMouseDown"); //_tracer.HookEvent("CellMouseEnter"); //_tracer.HookEvent("CellMouseHover"); //_tracer.HookEvent("CellMouseLeave"); //_tracer.HookEvent("CellMouseMove"); //_tracer.HookEvent("CellMouseUp"); //_tracer.HookEvent("CellPropertyChanged"); //_tracer.HookEvent("Click"); //_tracer.HookEvent("DoubleClick"); //_tracer.HookEvent("EditingStopped"); //_tracer.HookEvent("Enter"); //_tracer.HookEvent("GotFocus"); //_tracer.HookEvent("LostFocus"); //_tracer.HookEvent("MouseCaptureChanged"); //_tracer.HookEvent("MouseClick"); //_tracer.HookEvent("MouseDoubleClick"); //_tracer.HookEvent("MouseDown"); //_tracer.HookEvent("MouseEnter"); //_tracer.HookEvent("MouseHover"); //_tracer.HookEvent("MouseLeave"); //_tracer.HookEvent("MouseUp"); // _tracer.HookAllEvents(); #endregion }
/// <summary> /// Returns the type of column that is appropriate for the given property of the data source. /// Numbers, DateTime, Color and Boolean columns are mapped to NumberColumn, DateTimeColumn, ColorColumn and CheckBoxColumn respectively. The default /// is just a TextColumn. /// </summary> /// <param name="prop"></param> /// <param name="index"></param> /// <returns></returns> public virtual Column GetColumn(PropertyDescriptor prop, int index) { NumberColumn numCol = null; Column column = null; switch (prop.PropertyType.Name) { case "Int32": numCol = new NumberColumn(prop.Name); numCol.Maximum = Int32.MaxValue; numCol.Minimum = Int32.MinValue; column = numCol; break; case "Double": numCol = new NumberColumn(prop.Name); numCol.Maximum = Decimal.MaxValue; numCol.Minimum = Decimal.MinValue; column = numCol; break; case "Float": numCol = new NumberColumn(prop.Name); numCol.Maximum = Convert.ToDecimal(float.MaxValue); numCol.Minimum = Convert.ToDecimal(float.MinValue); column = numCol; break; case "Int16": numCol = new NumberColumn(prop.Name); numCol.Maximum = Int16.MaxValue; numCol.Minimum = Int16.MinValue; column = numCol; break; case "Int64": numCol = new NumberColumn(prop.Name); numCol.Maximum = Int64.MaxValue; numCol.Minimum = Int64.MinValue; column = numCol; break; case "Decimal": numCol = new NumberColumn(prop.Name); numCol.Maximum = Decimal.MaxValue; numCol.Minimum = Decimal.MinValue; column = numCol; break; case "DateTime": column = new DateTimeColumn(prop.Name); break; case "Color": column = new ColorColumn(prop.Name); break; case "Boolean": column = new CheckBoxColumn(prop.Name); break; default: column = new TextColumn(prop.Name); break; } return column; }
private void DoGroup() { Table table = this.table; // The Table control on a form - already initialised table.SelectionStyle = SelectionStyle.Grid; table.BeginUpdate(); table.EnableWordWrap = true; // If false, then Cell.WordWrap is ignored table.GridLines = GridLines.None; GroupColumn col0 = new GroupColumn("", 20); // this is the NEW +/- column col0.Editable = false; // Double clicking on this is to toggle the collapsed state col0.Selectable = false; col0.ToggleOnSingleClick = true; ImageColumn col1 = new ImageColumn("", 20); TextColumn col2 = new TextColumn("From", 200); DateTimeColumn col3 = new DateTimeColumn("Sent", 120); col3.ShowDropDownButton = false; col3.DateTimeFormat = DateTimePickerFormat.Custom; col3.CustomDateTimeFormat = "d/m/yyyy hh:mm"; ButtonColumn col4 = new ButtonColumn("butt"); table.ColumnModel = new ColumnModel(new Column[] { col0, col1, col2, col3, col4 }); TableModel model = new TableModel(); AddEmailRows(model, true, "Dave", "4/9/2007 12:34", "Here is the email subject", "Here is a preview of the text that is in the email. It wraps over too so you can see more of it"); AddEmailRows(model, false, "Richard", "5/4/2007 9:13", "An email abut something", "Another preview of another ficticious email. Not much to say really"); AddEmailRows(model, true, "Andy", "13/2/2007 9:45", "Work stuff", "Can you get this finished by this afternoon please? Thanks"); // Make and add the context menu: ContextMenu menu = new ContextMenu(); MenuItem delete = new MenuItem("Delete"); delete.Click += new EventHandler(delete_Click); menu.MenuItems.Add(delete); table.ContextMenu = menu; // Add an event handler for the key event table.CellKeyUp += new CellKeyEventHandler(table_CellKeyUp); table.CellButtonClicked += new CellButtonEventHandler(table_CellButtonClicked); this.table.TableModel = model; this.table.EndUpdate(); }