/// <summary> /// Gets the corresponding property type for the specified row data and column. /// </summary> /// <param name="column"> /// The corresponding column to get property type. /// </param> /// <param name="rowData"> /// The corresponding row data to get property type. /// </param> /// <returns> /// Returns the corresponding property type. /// </returns> protected virtual Type GetPropertyType(object rowData, TreeGridColumn column) { if (this.TreeGrid.View == null) { return(null); } //Get the Type of particular column var provider = TreeGrid.View.GetPropertyAccessProvider(); #if UWP PropertyInfoCollection typeInfos = null; if (TreeGrid.View is TreeGridUnboundView) { typeInfos = new PropertyInfoCollection(rowData.GetType()); } else { typeInfos = TreeGrid.View.GetItemProperties(); } #else PropertyDescriptorCollection typeInfos = null; if (TreeGrid.View is TreeGridUnboundView) { typeInfos = TypeDescriptor.GetProperties(rowData); } else { typeInfos = TreeGrid.View.GetItemProperties(); } #endif var typeInfo = typeInfos.GetPropertyDescriptor(column.MappingName); if (typeInfo != null) { return(typeInfo.PropertyType); } var cellvalue = provider.GetValue(rowData, column.MappingName); return(cellvalue != null?cellvalue.GetType() : null); }
/// <summary> /// Initialize the binding for display element of corresponding column. /// </summary> /// <param name="dataColumn">Specifies the dataColumn which contain TreeGridColumn, RowColumnIndex</param> /// <param name="uiElement">Specifies the display control to initialize binding</param> /// <param name="dataContext">Specifies the data context of the particular row</param> public override void OnInitializeDisplayElement(TreeDataColumnBase dataColumn, D uiElement, object dataContext) { TreeGridColumn column = dataColumn.TreeGridColumn; uiElement.SetBinding(TextBlock.TextProperty, column.DisplayBinding); uiElement.SetValue(TextBlock.TextAlignmentProperty, column.textAlignment); uiElement.SetValue(Control.VerticalAlignmentProperty, column.verticalAlignment); var textColumnBase = column as TreeGridTextColumnBase; if (textColumnBase == null) { return; } uiElement.SetValue(TextBlock.TextTrimmingProperty, textColumnBase.textTrimming); uiElement.SetValue(TextBlock.TextWrappingProperty, textColumnBase.textWrapping); #if WPF uiElement.SetValue(TextBlock.TextDecorationsProperty, textColumnBase.textDecoration); #endif }
/// <summary> /// To commits the value for the specified row data, column and corresponding changed value. /// </summary> protected virtual void CommitValue(object rowData, TreeGridColumn column, object changedValue) { Type type = null; var provider = this.TreeGrid.View.GetPropertyAccessProvider(); type = GetPropertyType(rowData, column); ////While giving dummy mappingname, its type becomes null. so we should check the type as null or not. if (type == null) { return; } var canconvert = CanConvertToType(changedValue, ref type); if (!canconvert && string.IsNullOrEmpty(changedValue.ToString())) { return; } if (!(canconvert || type == typeof(string) || type == typeof(object))) { return; } if (column.IsDropDown) { CommitValueDropDownColumn(column, ref changedValue, type); } else if (type == typeof(DateTimeOffset)) { DateTimeOffset value; DateTimeOffset.TryParse(changedValue.ToString(), out value); provider.SetValue(rowData, column.MappingName, value); return; } var pasteValue = ValueConvert.ChangeType(changedValue, type, null); provider.SetValue(rowData, column.MappingName, pasteValue); }
private void InitializeEditBinding(ComboBox uiElement, TreeGridColumn column) { var comboBoxColumn = (TreeGridComboBoxColumn)column; var bind = column.ValueBinding.CreateEditBinding(comboBoxColumn.GridValidationMode != GridValidationMode.None, column); uiElement.SetBinding(ComboBox.SelectedValueProperty, bind); var itemsSourceBinding = new Binding { Path = new PropertyPath("ItemsSource"), Mode = BindingMode.TwoWay, Source = comboBoxColumn }; uiElement.SetBinding(ComboBox.ItemsSourceProperty, itemsSourceBinding); var displayMemberBinding = new Binding { Path = new PropertyPath("DisplayMemberPath"), Mode = BindingMode.TwoWay, Source = comboBoxColumn }; uiElement.SetBinding(ComboBox.DisplayMemberPathProperty, displayMemberBinding); var selectedValuePathBinding = new Binding { Path = new PropertyPath("SelectedValuePath"), Mode = BindingMode.TwoWay, Source = comboBoxColumn }; uiElement.SetBinding(ComboBox.SelectedValuePathProperty, selectedValuePathBinding); #if WPF var staysOpenOnEditBinding = new Binding { Path = new PropertyPath("StaysOpenOnEdit"), Mode = BindingMode.TwoWay, Source = comboBoxColumn }; uiElement.SetBinding(ComboBox.StaysOpenOnEditProperty, staysOpenOnEditBinding); var isEditableBinding = new Binding { Path = new PropertyPath("IsEditable"), Mode = BindingMode.TwoWay, Source = comboBoxColumn }; uiElement.SetBinding(ComboBox.IsEditableProperty, isEditableBinding); #endif var itemTemplateBinding = new Binding { Path = new PropertyPath("ItemTemplate"), Mode = BindingMode.TwoWay, Source = comboBoxColumn }; uiElement.SetBinding(ComboBox.ItemTemplateProperty, itemTemplateBinding); }
private void ConstructieColoaneTGV() { this.tgvListaCategorii.IncepeConstructieColoane(); TreeGridColumn colExpand = new TreeGridColumn(); colExpand.Name = EnumColTGV.colExpand.ToString(); colExpand.HeaderText = string.Empty; colExpand.MinimumWidth = 20; colExpand.Width = 20; colExpand.Frozen = true; colExpand.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; this.tgvListaCategorii.Columns.Add(colExpand); this.tgvListaCategorii.AdaugaColoana(DataGridViewPersonalizat.EnumTipColoana.Editare); this.tgvListaCategorii.AdaugaColoanaText(EnumColTGV.colDenumire.ToString(), BMultiLingv.getElementById(BMultiLingv.EnumDictionar.Denumire), 100, true, DataGridViewColumnSortMode.Automatic); this.tgvListaCategorii.AdaugaColoanaText(EnumColTGV.colCuloare.ToString(), BMultiLingv.getElementById(BMultiLingv.EnumDictionar.Culoare), 50, false, DataGridViewColumnSortMode.Automatic); this.tgvListaCategorii.AdaugaColoana(DataGridViewPersonalizat.EnumTipColoana.Stergere); this.tgvListaCategorii.FinalizeazaConstructieColoane(); }
/// <summary> /// Starts an edit operation on a current cell. /// </summary> /// <param name="cellRowColumnIndex"> /// Specifies the row and column index of the cell to start an edit operation. /// </param> /// <param name="cellElement"> /// Specifies the UIElement of the cell to start an edit operation. /// </param> /// <param name="column"> /// The corresponding column to edit the cell. /// </param> /// <param name="record"> /// The corresponding record to edit the cell. /// </param> /// <returns> /// Returns <b>true</b> if the current cell starts an editing; otherwise, <b>false</b>. /// </returns> public override bool BeginEdit(RowColumnIndex cellRowColumnIndex, FrameworkElement cellElement, TreeGridColumn column, object record) { if (!this.HasCurrentCellState) { return(false); } if (this.SupportsRenderOptimization) { E cellcontent = null; if (!UseOnlyRendererElement && cellElement == null) { throw new Exception("Cell Element will not be get null for any case"); } var dataColumn = (cellElement as TreeGridCell).ColumnBase; OnUnloadUIElements(dataColumn); // Cell content will be null for templated case always. cellcontent = (column.IsTemplate && ((column as TreeGridTemplateColumn).hasEditTemplate || (column as TreeGridTemplateColumn).hasEditTemplateSelector)) ? null : CreateOrEditRecycleUIElement(); if (dataColumn.TreeGridColumn != null) { dataColumn.TreeGridColumn.IsInSuspend = true; } InitializeEditElement(dataColumn, (E)(cellcontent ?? cellElement), record); if (dataColumn.TreeGridColumn != null) { dataColumn.TreeGridColumn.IsInSuspend = false; } WireEditUIElement((E)(cellcontent ?? cellElement)); if (cellcontent != null) { (cellElement as TreeGridCell).Content = cellcontent; } OnEnteredEditMode(dataColumn, cellcontent ?? cellElement); } else { OnEnteredEditMode(null, this.CurrentCellRendererElement); } return(this.IsInEditing); }
/// <summary> /// Processes the edit binding. /// </summary> /// <param name="uiElement">The UI element.</param> /// <param name="column">TreeGridColumn of the Editing Column</param> private void InitializeEditUIElement(DoubleTextBox uiElement, TreeGridColumn column) { var numericColumn = ((TreeGridNumericColumn)column); var bind = numericColumn.ValueBinding.CreateEditBinding(column.GridValidationMode != GridValidationMode.None, column); uiElement.SetBinding(DoubleTextBox.ValueProperty, bind); #if UWP bind = new Binding { Path = new PropertyPath("AllowNull"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(DoubleTextBox.AllowNullProperty, bind); bind = new Binding { Path = new PropertyPath("BlockCharactersOnTextInput"), Source = numericColumn }; uiElement.SetBinding(DoubleTextBox.BlockCharactersOnTextInputProperty, bind); bind = new Binding { Path = new PropertyPath("FormatString"), Source = numericColumn }; uiElement.SetBinding(DoubleTextBox.FormatStringProperty, bind); #else bind = new Binding { Path = new PropertyPath("AllowScrollingOnCircle"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(EditorBase.IsScrollingOnCircleProperty, bind); bind = new Binding { Path = new PropertyPath("MinValue"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(DoubleTextBox.MinValueProperty, bind); bind = new Binding { Path = new PropertyPath("MaxValue"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(DoubleTextBox.MaxValueProperty, bind); bind = new Binding { Path = new PropertyPath("NumberDecimalDigits"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(DoubleTextBox.NumberDecimalDigitsProperty, bind); bind = new Binding { Path = new PropertyPath("NumberDecimalSeparator"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(DoubleTextBox.NumberDecimalSeparatorProperty, bind); bind = new Binding { Path = new PropertyPath("NumberGroupSeparator"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(DoubleTextBox.NumberGroupSeparatorProperty, bind); bind = new Binding { Path = new PropertyPath("NumberGroupSizes"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(DoubleTextBox.NumberGroupSizesProperty, bind); bind = new Binding { Path = new PropertyPath("AllowNullValue"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(EditorBase.UseNullOptionProperty, bind); bind = new Binding { Path = new PropertyPath("MaxValidation"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(EditorBase.MaxValidationProperty, bind); bind = new Binding { Path = new PropertyPath("MinValidation"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(EditorBase.MinValidationProperty, bind); bind = new Binding { Path = new PropertyPath("NullValue"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(DoubleTextBox.NullValueProperty, bind); uiElement.WatermarkTextIsVisible = true; bind = new Binding { Path = new PropertyPath("NullText"), Mode = BindingMode.TwoWay, Source = numericColumn }; uiElement.SetBinding(DoubleTextBox.WatermarkTextProperty, bind); #endif }
protected override void OnColumnAdded(DataGridViewColumnEventArgs e) { if (typeof(TreeGridColumn).IsAssignableFrom(e.Column.GetType())) { if (_expandableColumn == null) { // identify the expanding column. _expandableColumn = (TreeGridColumn)e.Column; } } // Expandable Grid doesn't support sorting. This is just a limitation of the sample. e.Column.SortMode = DataGridViewColumnSortMode.NotSortable; base.OnColumnAdded(e); }
private void UpdateListView() { //try //{ lock (_cache) { lock (statsTGV) { DataView infoDV = new DataView(_cache.Tables["StatisticInfo"]); if (!_columnsConfigured) { while (statsToolStripMenuItem.DropDownItems.Count > 2) { statsToolStripMenuItem.DropDownItems.RemoveAt(0); } statsTGV.Columns.Clear(); foreach (DataColumn dc in _cache.Tables["Statistics"].Columns) { if (dc.ColumnName == "boat_id") { TreeGridColumn tgc = new TreeGridColumn(); tgc.HeaderText = "Name"; tgc.Name = "Name"; tgc.Frozen = true; tgc.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; statsTGV.Columns.Add(tgc); DataGridViewTextBoxColumn color = new DataGridViewTextBoxColumn(); color.HeaderText = "Color"; color.Name = "Color"; color.Frozen = true; statsTGV.Columns.Add(color); } else if (dc.ColumnName == "leg_index" || dc.ColumnName=="tack_index") { } else { bool selectedByDefault = _replay.Boats[0].TotalStatistics.IsStatisticSelectedByDefault(dc.ColumnName); if (selectedByDefault) { DataGridViewTextBoxColumn dgvtbc = new DataGridViewTextBoxColumn(); dgvtbc.Name = dc.ColumnName; infoDV.RowFilter = "name='" + dc.ColumnName + "'"; string type = (string)infoDV[0]["type"]; string unit = (string)infoDV[0]["unit"]; string description = (string)infoDV[0]["description"]; if (unit != "other") { dgvtbc.HeaderText = dc.ColumnName + " (" + unit + ")"; dgvtbc.ToolTipText = "(" + unit + ") " + description; } statsTGV.Columns.Add(dgvtbc); } ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = dc.ColumnName; item.Checked = selectedByDefault; item.CheckOnClick = true; item.CheckedChanged += new EventHandler(selectStatisticToolStripMenuItem_Click); statsToolStripMenuItem.DropDownItems.Insert(statsToolStripMenuItem.DropDownItems.Count - 2, item); } } statsTGV.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.ColumnHeader); _columnsConfigured = true; } else { for (int i = 0; i < statsToolStripMenuItem.DropDownItems.Count; i++) { if (((ToolStripMenuItem)statsToolStripMenuItem.DropDownItems[i]).Checked) { if (statsToolStripMenuItem.DropDownItems[i].Text != "boat_id" && statsToolStripMenuItem.DropDownItems[i].Text != "leg_index" && !statsTGV.Columns.Contains(statsToolStripMenuItem.DropDownItems[i].Text)) { DataGridViewTextBoxColumn dgvtbc = new DataGridViewTextBoxColumn(); dgvtbc.Name = statsToolStripMenuItem.DropDownItems[i].Text; infoDV.RowFilter = "name='" + statsToolStripMenuItem.DropDownItems[i].Text + "'"; string type = (string)infoDV[0]["type"]; string unit = (string)infoDV[0]["unit"]; string description = (string)infoDV[0]["description"]; if (unit != "other") { dgvtbc.HeaderText = statsToolStripMenuItem.DropDownItems[i].Text + " (" + unit + ")"; dgvtbc.ToolTipText = "(" + unit + ") " + description; } statsTGV.Columns.Add(dgvtbc); } } else { if (statsTGV.Columns.Contains(statsToolStripMenuItem.DropDownItems[i].Text)) { statsTGV.Columns.Remove(statsTGV.Columns[statsToolStripMenuItem.DropDownItems[i].Text]); } } } } //statsTGV.Nodes.Clear(); int boatIndex = 0; TreeGridNode boat=null; int legIndex = 0; TreeGridNode leg=null; int tackIndex = 0; TreeGridNode tack=null; foreach (DataRow dr in _cache.Tables["Boats"].Rows) { string boatName = dr["name"].ToString() + " " + dr["number"].ToString(); Color boatColor = (Color)dr["color"]; Color boatColorLight = ColorHelper.Darken(boatColor);//Color.FromArgb(boatColor.R / 2, boatColor.G / 2, boatColor.B / 2); DataRow stats = _cache.Tables["Statistics"].Select("boat_id=" + dr["id"] + " and leg_index is null and tack_index is null")[0]; if (boatIndex < statsTGV.Nodes.Count) { for (int i = 0; i < statsTGV.Columns.Count; i++) { if (statsTGV.Columns[i].Name == "Name") { statsTGV.Nodes[boatIndex].Cells[i].Value = boatName; } else if (statsTGV.Columns[i].Name == "Color") { statsTGV.Nodes[boatIndex].Cells[i].Style.BackColor = boatColor; statsTGV.Nodes[boatIndex].Cells[i].Style.SelectionBackColor = boatColorLight; } else { //we might need to add cells if (i < statsTGV.Nodes[boatIndex].Cells.Count) { statsTGV.Nodes[boatIndex].Cells[statsTGV.Columns[i].Name].Value = FormatValue(stats[statsTGV.Columns[i].Name]); } else { //TreeGridCell c = new TreeGridCell(); DataGridViewTextBoxCell c = new DataGridViewTextBoxCell(); c.Value = FormatValue(stats[statsTGV.Columns[i].Name]); statsTGV.Nodes[boatIndex].Cells.Add(c); } } } //remove any excess nodes while (boatIndex >= statsTGV.Nodes.Count) { statsTGV.Nodes.RemoveAt(statsTGV.Nodes.Count - 1); } //remove any excess cells while (statsTGV.Nodes[boatIndex].Cells.Count > statsTGV.Columns.Count) { statsTGV.Nodes[boatIndex].Cells.RemoveAt(statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells.Count - 1); } boat = statsTGV.Nodes[boatIndex]; } else { List<object> values = new List<object>(); for (int i = 0; i < statsTGV.Columns.Count; i++) { if (statsTGV.Columns[i].Name == "Name") { values.Add(boatName); } else if (statsTGV.Columns[i].Name == "Color") { values.Add(""); } else { values.Add(FormatValue(stats[statsTGV.Columns[i].Name])); } } boat = statsTGV.Nodes.Add(values.ToArray()); } legIndex = 0; foreach (DataRow ldr in _cache.Tables["Legs"].Rows) { string legName = ldr["description"].ToString(); if (ldr["index"].ToString() != "") { DataRow[] drc = _cache.Tables["Statistics"].Select("boat_id=" + dr["id"] + " and leg_index=" + ldr["index"]+" and tack_index is null"); if (drc.Length > 0) { DataRow legstats = drc[0]; if (legIndex < boat.Nodes.Count) { for (int i = 0; i < statsTGV.Columns.Count; i++) { if (statsTGV.Columns[i].Name == "Name") { statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells[i].Value = legName; } else if (statsTGV.Columns[i].Name == "Color") { statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells[i].Style.BackColor = boatColor; statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells[i].Style.SelectionBackColor = boatColorLight; } else { //we might need to add cells if (i<statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells.Count) { statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells[i].Value = FormatValue(legstats[statsTGV.Columns[i].Name]); } else { //TreeGridCell c=new TreeGridCell(); DataGridViewTextBoxCell c = new DataGridViewTextBoxCell(); c.Value = FormatValue(legstats[statsTGV.Columns[i].Name]); statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells.Add(c); } } } //remove any excess nodes while (legIndex >= boat.Nodes.Count) { boat.Nodes.RemoveAt(boat.Nodes.Count - 1); } //remove any excess cells while (statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells.Count > statsTGV.Columns.Count) { statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells.RemoveAt(statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells.Count - 1); } leg = statsTGV.Nodes[boatIndex].Nodes[legIndex]; } else { List<object> legvalues = new List<object>(); for (int i = 0; i < statsTGV.Columns.Count; i++) { if (statsTGV.Columns[i].Name == "Name") { legvalues.Add(legName); } else if (statsTGV.Columns[i].Name == "Color") { legvalues.Add(""); } else { legvalues.Add(FormatValue(legstats[statsTGV.Columns[i].Name])); } } leg = boat.Nodes.Add(legvalues.ToArray()); } } try { DataRow[] tackRows = _cache.Tables["Tacks"].Select(string.Format("boat_id={0} and leg_index={1}", dr["id"], ldr["index"]), "tack_index asc"); tackIndex = 0; foreach (DataRow tdr in tackRows) { string tackName = tdr["Name"].ToString(); DataRow[] trc = _cache.Tables["Statistics"].Select("boat_id=" + dr["id"] + " and leg_index=" + ldr["index"] + " and tack_index=" + tdr["tack_index"]); if (trc.Length > 0) { DataRow tackstats = trc[0]; if (tackIndex < leg.Nodes.Count) { for (int i = 0; i < statsTGV.Columns.Count; i++) { if (statsTGV.Columns[i].Name == "Name") { statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells[i].Value = tackName; } else if (statsTGV.Columns[i].Name == "Color") { statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells[i].Style.BackColor = boatColor; statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells[i].Style.SelectionBackColor = boatColorLight; } else { //we might need to add cells if (i < statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells.Count) { statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells[i].Value = FormatValue(tackstats[statsTGV.Columns[i].Name]); } else { //TreeGridCell c=new TreeGridCell(); DataGridViewTextBoxCell c = new DataGridViewTextBoxCell(); c.Value = FormatValue(tackstats[statsTGV.Columns[i].Name]); statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells.Add(c); } } } //remove any excess nodes while (tackIndex >= leg.Nodes.Count) { leg.Nodes.RemoveAt(leg.Nodes.Count - 1); } //remove any excess cells while (statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells.Count > statsTGV.Columns.Count) { statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells.RemoveAt(statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells.Count - 1); } tack = statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex]; } else { List<object> tackvalues = new List<object>(); for (int i = 0; i < statsTGV.Columns.Count; i++) { if (statsTGV.Columns[i].Name == "Name") { tackvalues.Add(tackName); } else if (statsTGV.Columns[i].Name == "Color") { tackvalues.Add(""); } else { tackvalues.Add(FormatValue(tackstats[statsTGV.Columns[i].Name])); } } tack = leg.Nodes.Add(tackvalues.ToArray()); } } tackIndex++; } } catch (Exception) { #warning catch with no implementation.... why the f**k did i do this? it must be for a reason } legIndex++; } } boatIndex++; } } } //} //catch (Exception e) //{ // #warning remove this try catch block for production // //this is just here for a breakpoint, delete it later // throw e; //} //statsTGV.SelectionMode = DataGridViewSelectionMode.CellSelect; }
internal void MakeSort(TreeGridColumn column) { if (this.View == null) { return; } if (column.MappingName == null) { throw new InvalidOperationException("Mapping Name is necessary for Sorting"); } if (!this.treeGrid.CheckColumnNameinItemProperties(column)) { return; } CommitCurrentRow(); var sortColumName = column.MappingName; var cancelScroll = false; var allowMultiSort = SelectionHelper.CheckControlKeyPressed(); IsInSort = true; if (treeGrid.SortColumnDescriptions.Any() && allowMultiSort) { var sortedColumn = this.treeGrid.SortColumnDescriptions.FirstOrDefault(s => s.ColumnName == sortColumName); if (sortedColumn == default(SortColumnDescription)) { var newSortColumn = new SortColumnDescription { ColumnName = sortColumName, SortDirection = ListSortDirection.Ascending }; if (this.treeGrid.RaiseSortColumnsChanging(new List <SortColumnDescription>() { newSortColumn }, new List <SortColumnDescription>(), NotifyCollectionChangedAction.Add, out cancelScroll)) { this.treeGrid.SortColumnDescriptions.Add(newSortColumn); this.treeGrid.RaiseSortColumnsChanged(new List <SortColumnDescription>() { newSortColumn }, new List <SortColumnDescription>(), NotifyCollectionChangedAction.Add); } } else { if (sortedColumn.SortDirection == ListSortDirection.Descending && this.treeGrid.AllowTriStateSorting) { var removedSortColumn = this.treeGrid.SortColumnDescriptions.FirstOrDefault(s => s.ColumnName == sortColumName); if (removedSortColumn != null) { if (this.treeGrid.RaiseSortColumnsChanging(new List <SortColumnDescription>(), new List <SortColumnDescription>() { removedSortColumn }, NotifyCollectionChangedAction.Remove, out cancelScroll)) { this.treeGrid.SortColumnDescriptions.Remove(removedSortColumn); this.treeGrid.RaiseSortColumnsChanged(new List <SortColumnDescription>(), new List <SortColumnDescription>() { removedSortColumn }, NotifyCollectionChangedAction.Remove); } } } else { sortedColumn.SortDirection = sortedColumn.SortDirection == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending; var removedSortColumn = this.treeGrid.SortColumnDescriptions.FirstOrDefault(s => s.ColumnName == sortedColumn.ColumnName); if (this.treeGrid.RaiseSortColumnsChanging(new List <SortColumnDescription> { sortedColumn }, new List <SortColumnDescription>() { removedSortColumn }, NotifyCollectionChangedAction.Replace, out cancelScroll)) { this.treeGrid.SortColumnDescriptions.Remove(removedSortColumn); this.treeGrid.SortColumnDescriptions.Add(sortedColumn); this.treeGrid.RaiseSortColumnsChanged(new List <SortColumnDescription> { sortedColumn }, new List <SortColumnDescription>() { removedSortColumn }, NotifyCollectionChangedAction.Replace); } } } } else { var currentSortColumn = this.treeGrid.SortColumnDescriptions.FirstOrDefault(s => s.ColumnName == sortColumName); if (currentSortColumn != default(SortColumnDescription)) { if (currentSortColumn.SortDirection == ListSortDirection.Descending && this.treeGrid.AllowTriStateSorting) { var sortColumnsClone = this.treeGrid.SortColumnDescriptions.ToList(); if (this.treeGrid.RaiseSortColumnsChanging(new List <SortColumnDescription>(), sortColumnsClone, NotifyCollectionChangedAction.Remove, out cancelScroll)) { this.treeGrid.SortColumnDescriptions.Clear(); this.treeGrid.RaiseSortColumnsChanged(new List <SortColumnDescription>(), sortColumnsClone, NotifyCollectionChangedAction.Remove); } } else { currentSortColumn.SortDirection = currentSortColumn.SortDirection == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending; if (this.treeGrid.RaiseSortColumnsChanging(new List <SortColumnDescription>() { currentSortColumn }, new List <SortColumnDescription>(), NotifyCollectionChangedAction.Replace, out cancelScroll)) { this.treeGrid.SortColumnDescriptions.Clear(); this.treeGrid.SortColumnDescriptions.Add(currentSortColumn); this.treeGrid.RaiseSortColumnsChanged(new List <SortColumnDescription>() { currentSortColumn }, new List <SortColumnDescription>(), NotifyCollectionChangedAction.Replace); } } } else { var sortColumn = new SortColumnDescription() { ColumnName = sortColumName, SortDirection = ListSortDirection.Ascending }; if (this.treeGrid.SortColumnDescriptions.Any()) { var sortColumnsClone = this.treeGrid.SortColumnDescriptions.ToList(); if (this.treeGrid.RaiseSortColumnsChanging(new List <SortColumnDescription>() { sortColumn }, sortColumnsClone, NotifyCollectionChangedAction.Add, out cancelScroll)) { this.treeGrid.SortColumnDescriptions.Clear(); this.treeGrid.SortColumnDescriptions.Add(sortColumn); this.treeGrid.RaiseSortColumnsChanged(new List <SortColumnDescription>() { sortColumn }, sortColumnsClone, NotifyCollectionChangedAction.Add); } } else { if (this.treeGrid.RaiseSortColumnsChanging(new List <SortColumnDescription>() { sortColumn }, new List <SortColumnDescription>(), NotifyCollectionChangedAction.Add, out cancelScroll)) { this.treeGrid.SortColumnDescriptions.Add(sortColumn); this.treeGrid.RaiseSortColumnsChanged(new List <SortColumnDescription>() { sortColumn }, new List <SortColumnDescription>(), NotifyCollectionChangedAction.Add); } } } } RefreshAfterSorting(cancelScroll); IsInSort = false; }
/// <summary> /// Initializes a new instance of <see cref="Syncfusion.UI.Xaml.TreeGrid.TreeGridAutoGeneratingColumnEventArgs"/> class. /// </summary> /// <param name="column"> /// The generated column. /// </param> /// <param name="originalSource"> /// The source of the event. /// </param> public TreeGridAutoGeneratingColumnEventArgs(TreeGridColumn column, object originalSource) : base(originalSource) { Column = column; }
/// <summary> /// Processes the edit binding. /// </summary> /// <param name="uiElement">The UI element.</param> /// <param name="column"></param> private void InitializeEditUIElement(DateTimeEdit uiElement, TreeGridColumn column) { var dateTimeColumn = (TreeGridDateTimeColumn)column; var bind = dateTimeColumn.ValueBinding.CreateEditBinding(dateTimeColumn.GridValidationMode != GridValidationMode.None, column); #if UWP //WRT-4266 Need to create the binding by using CreateEditBinding method available in BindingUtility helper //for Setting the Mode as Two Way for AddNewRowColumn if AllowEditing is False uiElement.SetBinding(DateTimeEdit.ValueProperty, bind); bind = new Binding { Path = new PropertyPath("FormatString"), Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.FormatStringProperty, bind); bind = new Binding { Path = new PropertyPath("AllowInlineEditing"), Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.AllowInlineEditingProperty, bind); bind = new Binding { Path = new PropertyPath("ShowDropDownButton"), Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.ShowDropDownButtonProperty, bind); bind = new Binding { Path = new PropertyPath("AllowNullValue"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.AllowNullProperty, bind); bind = new Binding { Path = new PropertyPath("MinDate"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.MinDateProperty, bind); bind = new Binding { Path = new PropertyPath("MaxDate"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.MaxDateProperty, bind); bind = new Binding { Path = new PropertyPath("WaterMark"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.WatermarkProperty, bind); bind = new Binding { Path = new PropertyPath("AccentBrush"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.AccentBrushProperty, bind); bind = new Binding { Path = new PropertyPath("DropDownHeight"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.DropDownHeightProperty, bind); bind = new Binding { Path = new PropertyPath("InputScope"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.InputScopeProperty, bind); bind = new Binding { Path = new PropertyPath("SelectorItemCount"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.SelectorItemCountProperty, bind); bind = new Binding { Path = new PropertyPath("SelectorItemHeight"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.SelectorItemHeightProperty, bind); bind = new Binding { Path = new PropertyPath("SelectorItemSpacing"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.SelectorItemSpacingProperty, bind); bind = new Binding { Path = new PropertyPath("SelectorItemWidth"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.SelectorItemWidthProperty, bind); bind = new Binding { Path = new PropertyPath("SelectorFormatString"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.SelectorFormatStringProperty, bind); uiElement.IsDropDownOpen = dateTimeColumn.IsDropDownOpen; #else uiElement.SetBinding(DateTimeEdit.DateTimeProperty, bind); bind = new Binding { Path = new PropertyPath("MinDateTime"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.MinDateTimeProperty, bind); bind = new Binding { Path = new PropertyPath("MaxDateTime"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.MaxDateTimeProperty, bind); bind = new Binding { Path = new PropertyPath("CustomPattern"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeBase.CustomPatternProperty, bind); bind = new Binding { Path = new PropertyPath("CanEdit"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeBase.CanEditProperty, bind); bind = new Binding { Path = new PropertyPath("EnableBackspaceKey"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.EnableBackspaceKeyProperty, bind); bind = new Binding { Path = new PropertyPath("EnableDeleteKey"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.EnableDeleteKeyProperty, bind); bind = new Binding { Path = new PropertyPath("AllowScrollingOnCircle"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeBase.EnableMouseWheelEditProperty, bind); bind = new Binding { Path = new PropertyPath("DateTimeFormat"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeBase.DateTimeFormatProperty, bind); bind = new Binding { Path = new PropertyPath("Pattern"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeBase.PatternProperty, bind); bind = new Binding { Path = new PropertyPath("EnableClassicStyle"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.EnableClassicStyleProperty, bind); bind = new Binding { Path = new PropertyPath("AllowNullValue"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.IsEmptyDateEnabledProperty, bind); bind = new Binding { Path = new PropertyPath("ShowRepeatButton"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeBase.IsVisibleRepeatButtonProperty, bind); bind = new Binding { Path = new PropertyPath("NullValue"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.NullValueProperty, bind); bind = new Binding { Path = new PropertyPath("NullText"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.NoneDateTextProperty, bind); bind = new Binding { Path = new PropertyPath("DisableDateSelection"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.DisableDateSelectionProperty, bind); bind = new Binding { Path = new PropertyPath("TextDecorations"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(TimeSpanEdit.TextDecorationsProperty, bind); if ((column as TreeGridDateTimeColumn).MaxDateTime != System.DateTime.MaxValue) { bind = new Binding { Path = new PropertyPath("MaxDateTime"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.MaxDateTimeProperty, bind); } else { bind = new Binding { Path = new PropertyPath("NullValue"), Mode = BindingMode.TwoWay, Source = dateTimeColumn }; uiElement.SetBinding(DateTimeEdit.NullValueProperty, bind); } #endif }
protected override void OnHolding(GestureEventArgs e) { if (!this.TreeGrid.ValidationHelper.CheckForValidation(true)) { return; } if (e.HoldingState == HoldingState.Started && e.PointerDeviceType != PointerDeviceType.Mouse && pointer != null) { if (Column.AllowResizing) { TreeGridColumn treeColumn = this.Column; Point mouseDown = e.GetPosition(this); int colIndex = this.TreeGrid.Columns.IndexOf(treeColumn); int columnindex = this.TreeGrid.ResolveToScrollColumnIndex(colIndex); var line = this.TreeGrid.TreeGridPanel.ScrollColumns.GetVisibleLineAtLineIndex(columnindex); var point = this.GetControlRect(this.TreeGrid); //UWP-4063 Resizing popup size is varied when column width exceeds the total width of the grid. if (line != null && line.IsClipped) { this.TreeGrid.TreeGridPanel.ScrollColumns.ScrollInView(columnindex); var distance = treeColumn.ActualWidth - line.ClippedSize; if (line.IsClippedOrigin) { point.X = point.X + distance; } else { point.X = point.X - distance; } } Rect rect = Rect.Empty; if ((mouseDown.X < 20 || mouseDown.X > this.ActualWidth - 20) && this.TreeGrid.AllowResizingHiddenColumns && colIndex > 0 && colIndex < this.TreeGrid.Columns.Count - 1) { int index = mouseDown.X < 20 ? colIndex - 1 : colIndex + 1; TreeGridColumn hiddenColumn = this.TreeGrid.Columns[index]; if (hiddenColumn.IsHidden) { treeColumn = mouseDown.X < 20 ? hiddenColumn : this.TreeGrid.Columns[index]; if (mouseDown.X > this.ActualWidth - 20) { index = this.TreeGrid.Columns.IndexOf(treeColumn); treeColumn = treeColumn.IsHidden ? this.TreeGrid.Columns[index] : this.TreeGrid.Columns[index - 1]; rect = new Rect(point.X + this.ActualWidth, point.Y, this.ActualWidth, this.ActualHeight); } this.TreeGrid.ColumnResizingController.HiddenLineIndex = this.TreeGrid.ResolveToScrollColumnIndex(this.TreeGrid.Columns.IndexOf(treeColumn)); } } if (rect.IsEmpty) { rect = new Rect(point.X, point.Y, this.ActualWidth, this.ActualHeight); } this.TreeGrid.ColumnDragDropController.ShowPopup(treeColumn, rect, mouseDown, true, pointer); e.Handled = true; } } // When long press SfTreeGrid Cell, Context menu appears for the selected cell. We are using this event for context menu support in Header Cell. if (e.HoldingState == HoldingState.Completed && e.PointerDeviceType != PointerDeviceType.Mouse) { var position = e.GetPosition(this); if (ShowContextMenu(position)) { e.Handled = true; } } base.OnHolding(e); }
/// <summary> /// To raise the <see cref="Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.GridPasteOption"/> event in SfTreeGrid. /// </summary> /// <param name="column"> /// The corresponding column of the cell content. /// </param> /// <param name="rowData"> /// The corresponding row data of the cell content. /// </param> /// <param name="clipboardValue"> /// The corresponding clipboard value that is going to be pasted. /// </param> /// Returns the <see cref="Syncfusion.UI.Xaml.TreeGrid.TreeGridCopyPasteCellEventArgs"/>. /// </returns> protected virtual TreeGridCopyPasteCellEventArgs RaisePasteGridCellContentEvent(TreeGridColumn column, object rowData, object clipboardValue) { return(TreeGrid.RaisePasteTreeGridCellContentEvent(new TreeGridCopyPasteCellEventArgs(false, column, this.TreeGrid, rowData, clipboardValue))); }
/// <summary> /// This method is called when the cut operation performed for the particular row data and column. /// </summary> /// <param name="rowData"> /// Contains the row data of the selected record to perform cut operation. /// </param> /// <param name="column"> /// The corresponding column of the selected record to perform cut operation. /// </param> protected virtual void ClearCell(object rowData, TreeGridColumn column) { if (this.TreeGrid.View == null) { return; } var provider = this.TreeGrid.View.GetPropertyAccessProvider(); #if UWP PropertyInfoCollection properyCollection = null; if (TreeGrid.View is TreeGridUnboundView) { properyCollection = new PropertyInfoCollection(rowData.GetType()); } else { properyCollection = TreeGrid.View.GetItemProperties(); } #else PropertyDescriptorCollection properyCollection = null; if (TreeGrid.View is TreeGridUnboundView) { properyCollection = TypeDescriptor.GetProperties(rowData); } else { properyCollection = TreeGrid.View.GetItemProperties(); } #endif if (column.IsHidden || properyCollection == null) { return; } Type type = null; var cellvalue = provider.GetValue(rowData, column.MappingName); #if WPF if (cellvalue == null || cellvalue == DBNull.Value) #else if (cellvalue == null) #endif { return; } //Getting type of the column using GetPropertyType(). type = GetPropertyType(rowData, column); if (type == null) { return; } #if UWP if (properyCollection.Find(column.MappingName, false) != null && !properyCollection.Find(column.MappingName, false).CanWrite) #else if (properyCollection.Find(column.MappingName, false) != null && properyCollection.Find(column.MappingName, false).IsReadOnly) #endif { return; } if (type.IsValueType()) { provider.SetValue(rowData, column.MappingName, Activator.CreateInstance(type)); } else if (type == typeof(string)) { provider.SetValue(rowData, column.MappingName, string.Empty); } }
/// <summary> /// Processes the edit binding. /// </summary> /// <param name="uiElement">The UI element.</param> /// <param name="column">Grid Column</param> private void InitializeEditUIElement(MaskedTextBox uiElement, TreeGridColumn column) { var maskedColumn = ((TreeGridMaskColumn)column); var bind = maskedColumn.ValueBinding.CreateEditBinding(maskedColumn.GridValidationMode != GridValidationMode.None, column); uiElement.SetBinding(MaskedTextBox.ValueProperty, bind); #if UWP bind = new Binding { Path = new PropertyPath("Mask"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(SfMaskedEdit.MaskProperty, bind); bind = new Binding { Path = new PropertyPath("MaskType"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(SfMaskedEdit.MaskTypeProperty, bind); bind = new Binding { Path = new PropertyPath("PromptChar"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(SfMaskedEdit.PromptCharProperty, bind); bind = new Binding { Path = new PropertyPath("MaskFormat"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(SfMaskedEdit.ValueMaskFormatProperty, bind); bind = new Binding { Path = new PropertyPath("ValidationMode"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(SfMaskedEdit.ValidationModeProperty, bind); bind = new Binding { Path = new PropertyPath("KeyboardType"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(SfMaskedEdit.KeyboardTypeProperty, bind); uiElement.Watermark = false; #endif #if WPF bind = new Binding { Path = new PropertyPath("IsNumeric"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(MaskedTextBox.IsNumericProperty, bind); bind = new Binding { Path = new PropertyPath("DateSeparator"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(MaskedTextBox.DateSeparatorProperty, bind); bind = new Binding { Path = new PropertyPath("DecimalSeparator"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(MaskedTextBox.DecimalSeparatorProperty, bind); bind = new Binding { Path = new PropertyPath("TimeSeparator"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(MaskedTextBox.TimeSeparatorProperty, bind); bind = new Binding { Path = new PropertyPath("PromptChar"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(MaskedTextBox.PromptCharProperty, bind); bind = new Binding { Path = new PropertyPath("Mask"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(MaskedTextBox.MaskProperty, bind); bind = new Binding { Path = new PropertyPath("MaskFormat"), Mode = BindingMode.TwoWay, Source = maskedColumn }; uiElement.SetBinding(MaskedTextBox.TextMaskFormatProperty, bind); uiElement.WatermarkTextIsVisible = false; #endif }
internal bool RaiseCurrentCellValidatingEvent(object oldValue, object newValue, TreeGridColumn column, out object changedNewValue, RowColumnIndex currentCellIndex, FrameworkElement currentCell, out string errorMessage, object rowData, TreeNode node) { var e = new TreeGridCurrentCellValidatingEventArgs(treeGrid) { OldValue = oldValue, NewValue = newValue, Column = column, IsValid = true, RowData = rowData, Node = node }; var isValid = treeGrid.RaiseCurrentCellValidatingEvent(e); changedNewValue = e.NewValue; var cell = currentCell as TreeGridCell; if (!isValid) { cell.SetError(e.ErrorMessage, false); } else if (errorMessages == null || !(errorMessages.Keys.Any(x => x == column.MappingName))) { cell.RemoveError(false); } errorMessage = e.ErrorMessage; return(isValid); }
private TreeGridView InitializeTreeGridView() { try { //TreeGridView Initialization TreeGridView treeGridView = new TreeGridView(); treeGridView.Size = new Size(530, 442); treeGridView.Location = new Point(2, 2); treeGridView.Name = BusinessConstants.DB4OBJECTS_TREEGRIDVIEW; treeGridView.RowHeadersVisible = false; treeGridView.ShowLines = true; treeGridView.Dock = DockStyle.Fill; treeGridView.Visible = true; treeGridView.AllowDrop = true; //Column Intialization //Field Column TreeGridColumn m_fieldColumn = new TreeGridColumn(); m_fieldColumn.DefaultNodeImage = null; m_fieldColumn.FillWeight = 386.9562F; m_fieldColumn.HeaderText = BusinessConstants.DB4OBJECTS_FIELD; m_fieldColumn.Name = BusinessConstants.DB4OBJECTS_FIELDCOLOUMN; m_fieldColumn.SortMode = DataGridViewColumnSortMode.NotSortable; m_fieldColumn.ReadOnly = true; m_fieldColumn.Width = 170; //Value Column TreeGridViewDateTimePickerColumn m_valueColumn = new TreeGridViewDateTimePickerColumn(); m_valueColumn.FillWeight = 50F; m_valueColumn.HeaderText = BusinessConstants.DB4OBJECTS_VALUEFORGRID; m_valueColumn.Name = BusinessConstants.DB4OBJECTS_VALUECOLUMN; m_valueColumn.SortMode = DataGridViewColumnSortMode.NotSortable; m_valueColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; m_valueColumn.ReadOnly = checkReadonlyStatus(); //Type Column DataGridViewTextBoxColumn m_typeColumn = new DataGridViewTextBoxColumn(); m_typeColumn.FillWeight = 50F; m_typeColumn.HeaderText = BusinessConstants.DB4OBJECTS_TYPE; m_typeColumn.Name = BusinessConstants.DB4OBJECTS_TYPECOLUMN; m_typeColumn.SortMode = DataGridViewColumnSortMode.NotSortable; m_typeColumn.ReadOnly = true; m_typeColumn.Width = 150; treeGridView.Columns.AddRange(new DataGridViewColumn[] { m_fieldColumn, m_valueColumn, m_typeColumn }); treeGridView.ImageList = m_imageListTreeGrid; treeGridView.ScrollBars = ScrollBars.Both; return treeGridView; } catch (Exception oEx) { LoggingHelper.HandleException(oEx); } return null; }
internal void RaiseCurrentCellValidatedEvent(object oldValue, object newValue, TreeGridColumn column, string errorMessage, object rowData, TreeNode treeNode) { var e = new TreeGridCurrentCellValidatedEventArgs(treeGrid) { OldValue = oldValue, NewValue = newValue, Column = column, ErrorMessage = errorMessage, RowData = rowData, Node = treeNode }; treeGrid.RaiseCurrentCellValidatedEvent(e); }
public override bool CanUpdateBinding(TreeGridColumn column) { return(false); }
/// <summary> /// Determines whether the binding for the column can be updated. /// Implement this method to update binding on particular renderer when the data context is set. /// </summary> /// <returns> /// Returns <b>true</b> if the binding is updated for the column. /// </returns> public virtual bool CanUpdateBinding(TreeGridColumn column) { return(column != null && column.canUpdateBinding); }
/// <summary> /// Processes the edit binding. /// </summary> /// <param name="uiElement">The unique identifier element.</param> /// <param name="column">Grid Column for the Editor</param> private void InitializeEditUIElement(PercentTextBox uiElement, TreeGridColumn column) { uiElement.TextSelectionOnFocus = false; var percentColumn = (TreeGridPercentColumn)column; var bind = percentColumn.ValueBinding.CreateEditBinding(percentColumn.GridValidationMode != GridValidationMode.None, column); uiElement.SetBinding(PercentTextBox.PercentValueProperty, bind); bind = new Binding { Path = new PropertyPath("AllowScrollingOnCircle"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(EditorBase.IsScrollingOnCircleProperty, bind); bind = new Binding { Path = new PropertyPath("MinValue"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.MinValueProperty, bind); bind = new Binding { Path = new PropertyPath("MaxValue"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.MaxValueProperty, bind); bind = new Binding { Path = new PropertyPath("PercentEditMode"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.PercentEditModeProperty, bind); bind = new Binding { Path = new PropertyPath("PercentDecimalDigits"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.PercentDecimalDigitsProperty, bind); bind = new Binding { Path = new PropertyPath("PercentDecimalSeparator"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.PercentDecimalSeparatorProperty, bind); bind = new Binding { Path = new PropertyPath("PercentGroupSeparator"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.PercentGroupSeparatorProperty, bind); bind = new Binding { Path = new PropertyPath("PercentGroupSizes"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.PercentGroupSizesProperty, bind); bind = new Binding { Path = new PropertyPath("PercentNegativePattern"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.PercentNegativePatternProperty, bind); bind = new Binding { Path = new PropertyPath("PercentPositivePattern"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.PercentPositivePatternProperty, bind); bind = new Binding { Path = new PropertyPath("PercentSymbol"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.PercentageSymbolProperty, bind); bind = new Binding { Path = new PropertyPath("AllowNullValue"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(EditorBase.UseNullOptionProperty, bind); bind = new Binding { Path = new PropertyPath("MaxValidation"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(EditorBase.MaxValidationProperty, bind); bind = new Binding { Path = new PropertyPath("MinValidation"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(EditorBase.MinValidationProperty, bind); bind = new Binding { Path = new PropertyPath("NullValue"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.NullValueProperty, bind); uiElement.WatermarkTextIsVisible = true; bind = new Binding { Path = new PropertyPath("NullText"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.WatermarkTextProperty, bind); #if WPF bind = new Binding { Path = new PropertyPath("TextDecorations"), Mode = BindingMode.TwoWay, Source = percentColumn }; uiElement.SetBinding(PercentTextBox.TextDecorationsProperty, bind); #endif }
/// <summary> /// Sets the focus to the specified current cell uielement. /// </summary> /// <param name="uiElement"> /// Specifies the corresponding current cell uielement. /// </param> /// <param name="needToFocus"> /// Decides whether the focus set to current cell uielement. /// </param> protected virtual void SetFocus(FrameworkElement uiElement, bool needToFocus) { if (uiElement != null && IsFocusable) { UIElement uielement; var focusedElement = FocusManagerHelper.GetFocusedUIElement(CurrentCellRendererElement); uielement = focusedElement ?? uiElement; TreeGridColumn column = null; if (needToFocus) { var columnIndex = TreeGrid.ResolveToGridVisibleColumnIndex(CurrentCellIndex.ColumnIndex); column = TreeGrid.Columns[columnIndex]; } //SupportsRenderOptimization condition checked to move the Focus always to CheckBox instead of DataGrid - WPF-22403 if (needToFocus && (IsInEditing || column.CanFocus() || !SupportsRenderOptimization)) { if (IsFocused) { #if WPF if (!uielement.IsFocused) { uielement.Focusable = true; Keyboard.Focus(uielement); } #endif return; } #if WPF uielement.Focus(); #else if (uielement is Control) { (uielement as Control).Focus(FocusState.Programmatic); isfocused = false; return; } #endif isfocused = true; } else { #if WPF this.TreeGrid.Focus(); #else this.treeGrid.Focus(FocusState.Programmatic); #endif isfocused = false; } } else { #if WPF TreeGrid.Focus(); #else TreeGrid.Focus(FocusState.Programmatic); #endif isfocused = false; } }
/// <summary> /// Constructs all the columns for the treegridview /// </summary> /// <param name="strErrMsg">Error message to be returned</param> /// <returns>True if opertaion is successfull;else false</returns> private bool DesignTableStyle(ref string strErrMsg) { try { string m_strMaskCols = "", m_strShowCols = ""; this.AutoGenerateColumns = false; //this.DataSource = dtSource; this.EditingControlShowing -= new DataGridViewEditingControlShowingEventHandler(TreeGridView_EditingControlShowing); //this.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(clsSearchGrid_EditingControlShowing); this.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(TreeGridView_EditingControlShowing); if (this.Columns.Count > 0) this.Columns.Clear(); iVisibleColumnCount = 0; for (int i = 0; i < dtSource.Columns.Count; i++) { int local0 = 0; if (strColNames[i].ToUpper().IndexOf("MASK") == 0) continue; iVisibleColumnCount++; if (TreeColumnIndex == i) { TreeGridColumn objTreeCol = new TreeGridColumn(); objTreeCol.HeaderText = strHeadings[i]; objTreeCol.DataPropertyName = dtSource.Columns[i].ColumnName; if (CheckReadOnlyColumn(i)) { objTreeCol.ReadOnly = true; } this.Columns.Insert(this.Columns.Count, objTreeCol); } else { DataGridViewTextBoxColumn dgTBCol = new DataGridViewTextBoxColumn(); dgTBCol.DataPropertyName = dtSource.Columns[i].ColumnName; dgTBCol.HeaderText = strHeadings[i]; if (strColNames[i].ToUpper().IndexOf("MASK") == 0) continue; if (CheckReadOnlyColumn(i)) { dgTBCol.ReadOnly = true; } if (CheckRightAlignColumn(i)) { //dgTBCol.CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleRight; dgTBCol.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; //dgTBCol.DataGridView.AlternatingRowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } else { dgTBCol.DefaultCellStyle.Alignment = DataGridViewContentAlignment.NotSet; //dgTBCol.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; //dgTBCol.DataGridView.AlternatingRowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; } if (CheckNumericColumn(i, ref local0)) { dgTBCol.DefaultCellStyle.Format = "N" + arlNumericColFloatSize[local0]; CultureInfo inf = new CultureInfo(CultureInfo.CurrentCulture.LCID, true); inf.NumberFormat.NumberGroupSeparator = CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator; inf.NumberFormat.NumberDecimalSeparator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; dgTBCol.DefaultCellStyle.FormatProvider = inf; //dgTBCol.DefaultCellStyle.Format = "F2"; ////dgTBCol.deDefaultCellStyle.NullValue = 0.00; ////this[this.CurrentRowIndex, i].DefaultValue = 0.00; //*** if ((Boolean)arlFixedLengthNumCols[local0]) { dgTBCol.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; dgTBCol.MaxInputLength = 21; dgTBCol.MinimumWidth = 115; dgTBCol.Width = 115; //dgTBCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet; } ////**** } else { //dgTBCol.Width = 200; //dgTBCol.Resizable = DataGridViewTriState.False; //dgTBCol.TextType = clsTxtBox.TypeEnum.String; //dgTBCol.TextBox.MaxLength = getMaxStrLength(i); //dgTBCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader; } this.Columns.Insert(this.Columns.Count, dgTBCol); } } this.Font = new Font(this.Font, FontStyle.Regular); this.Invalidate(); this.Refresh(); return true; } catch (Exception ex) { strErrMsg = ex.Source + " - " + ex.Message; return false; } }
public void SetCurrentCellState(RowColumnIndex currentCellIndex, FrameworkElement currentCellElement, bool isInEditing, bool isFocused, TreeGridColumn column, TreeDataColumnBase dc) { hasCurrentCellState = true; this.currentCellIndex = currentCellIndex; if (UseOnlyRendererElement) { this.currentCellElement = null; currentCellRendererElement = currentCellElement; } else { this.currentCellElement = currentCellElement; if (currentCellElement is TreeGridCell) { if (column.hasCellTemplate || column.hasCellTemplateSelector) { currentCellRendererElement = currentCellElement as FrameworkElement; } else { currentCellRendererElement = (currentCellElement as TreeGridCell).Content as FrameworkElement; } } } IsInEditing = isInEditing; if (isFocused) { this.SetFocus(this.IsFocusable); } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> public void InitializeComponent() { this.components = new System.ComponentModel.Container(); AdvancedDataGridView.TreeGridNode treeGridNode1 = new AdvancedDataGridView.TreeGridNode(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton4 = new System.Windows.Forms.ToolStripButton(); this.treeGridView1 = new AdvancedDataGridView.TreeGridView(); this.ColPCName = new AdvancedDataGridView.TreeGridColumn(); this.ColPCIP = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColPCMac = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColDownload = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColUpload = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColDownCap = new DataGridViewNumericUpDownElements.DataGridViewNumericUpDownColumn(); this.ColUploadCap = new DataGridViewNumericUpDownElements.DataGridViewNumericUpDownColumn(); this.ColBlock = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.ColSpoof = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.ContextMenuViews = new System.Windows.Forms.ContextMenuStrip(this.components); this.ViewMenuIP = new System.Windows.Forms.ToolStripMenuItem(); this.ViewMenuMAC = new System.Windows.Forms.ToolStripMenuItem(); this.ViewMenuDownload = new System.Windows.Forms.ToolStripMenuItem(); this.ViewMenuUpload = new System.Windows.Forms.ToolStripMenuItem(); this.ViewMenuDownloadCap = new System.Windows.Forms.ToolStripMenuItem(); this.ViewMenuUploadCap = new System.Windows.Forms.ToolStripMenuItem(); this.ViewMenuBlock = new System.Windows.Forms.ToolStripMenuItem(); this.ViewMenuSpoof = new System.Windows.Forms.ToolStripMenuItem(); this.imageList1 = new System.Windows.Forms.ImageList(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer2 = new System.Windows.Forms.Timer(this.components); this.timerSpoof = new System.Windows.Forms.Timer(this.components); this.SelfishNetTrayIcon = new System.Windows.Forms.NotifyIcon(this.components); this.timerDiscovery = new System.Windows.Forms.Timer(this.components); this.toolStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.treeGridView1)).BeginInit(); this.ContextMenuViews.SuspendLayout(); this.SuspendLayout(); // // toolStrip1 // this.toolStrip1.ImageScalingSize = new System.Drawing.Size(32, 32); this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripButton1, this.toolStripSeparator1, this.toolStripButton2, this.toolStripSeparator2, this.toolStripButton3, this.toolStripButton4 }); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(703, 39); this.toolStrip1.TabIndex = 0; this.toolStrip1.Text = "toolStrip1"; // // toolStripButton1 // this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton1.Image = global::Properties.Resources.search; this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton1.Name = "toolStripButton1"; this.toolStripButton1.Size = new System.Drawing.Size(36, 36); this.toolStripButton1.Text = "Network Discovery"; this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(6, 39); // // toolStripButton2 // this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton2.Image = global::Properties.Resources.play; this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton2.Name = "toolStripButton2"; this.toolStripButton2.Size = new System.Drawing.Size(36, 36); this.toolStripButton2.Text = "Start redirecting-spoofing"; this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click); // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Size = new System.Drawing.Size(6, 39); // // toolStripButton3 // this.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton3.Image = global::Properties.Resources.pause; this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton3.Name = "toolStripButton3"; this.toolStripButton3.Size = new System.Drawing.Size(36, 36); this.toolStripButton3.Text = "stop redirecting- spoofing"; this.toolStripButton3.Click += new System.EventHandler(this.toolStripButton3_Click); // // toolStripButton4 // this.toolStripButton4.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; this.toolStripButton4.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton4.Name = "toolStripButton4"; this.toolStripButton4.Size = new System.Drawing.Size(23, 36); this.toolStripButton4.Text = "Help"; this.toolStripButton4.Click += new System.EventHandler(this.toolStripButton4_Click); // // treeGridView1 // this.treeGridView1.AllowUserToAddRows = false; this.treeGridView1.AllowUserToDeleteRows = false; this.treeGridView1.AllowUserToOrderColumns = true; this.treeGridView1.AllowUserToResizeRows = false; this.treeGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.treeGridView1.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells; this.treeGridView1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.treeGridView1.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.RaisedHorizontal; this.treeGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; this.treeGridView1.ColumnHeadersHeight = 35; this.treeGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.ColPCName, this.ColPCIP, this.ColPCMac, this.ColDownload, this.ColUpload, this.ColDownCap, this.ColUploadCap, this.ColBlock, this.ColSpoof }); this.treeGridView1.ContextMenuStrip = this.ContextMenuViews; this.treeGridView1.Dock = System.Windows.Forms.DockStyle.Fill; this.treeGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; this.treeGridView1.ImageList = this.imageList1; this.treeGridView1.Location = new System.Drawing.Point(0, 39); this.treeGridView1.Name = "treeGridView1"; treeGridNode1.Height = 20; treeGridNode1.ImageIndex = 1; this.treeGridView1.Nodes.Add(treeGridNode1); this.treeGridView1.RowHeadersVisible = false; this.treeGridView1.ShowCellErrors = false; this.treeGridView1.ShowCellToolTips = false; this.treeGridView1.ShowEditingIcon = false; this.treeGridView1.ShowRowErrors = false; this.treeGridView1.Size = new System.Drawing.Size(703, 363); this.treeGridView1.TabIndex = 1; this.treeGridView1.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.treeGridView1_CellPainting); this.treeGridView1.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.treeGridView1_CellValueChanged); this.treeGridView1.CurrentCellDirtyStateChanged += new System.EventHandler(this.treeGridView1_CurrentCellDirtyStateChanged); // // ColPCName // this.ColPCName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.ColPCName.DefaultNodeImage = null; this.ColPCName.FillWeight = 180.4366F; this.ColPCName.HeaderText = "PC Name"; this.ColPCName.MinimumWidth = 40; this.ColPCName.Name = "ColPCName"; this.ColPCName.ReadOnly = true; this.ColPCName.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // ColPCIP // this.ColPCIP.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.ColPCIP.FillWeight = 119.7174F; this.ColPCIP.HeaderText = "IP"; this.ColPCIP.MinimumWidth = 35; this.ColPCIP.Name = "ColPCIP"; this.ColPCIP.ReadOnly = true; this.ColPCIP.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // ColPCMac // this.ColPCMac.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.ColPCMac.FillWeight = 106.599F; this.ColPCMac.HeaderText = "MAC"; this.ColPCMac.MinimumWidth = 35; this.ColPCMac.Name = "ColPCMac"; this.ColPCMac.ReadOnly = true; this.ColPCMac.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // ColDownload // this.ColDownload.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.ColDownload.FillWeight = 74.57431F; this.ColDownload.HeaderText = "Download KB/s"; this.ColDownload.MinimumWidth = 20; this.ColDownload.Name = "ColDownload"; this.ColDownload.ReadOnly = true; this.ColDownload.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // ColUpload // this.ColUpload.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.ColUpload.FillWeight = 70.42757F; this.ColUpload.HeaderText = "Upload KB/s"; this.ColUpload.MinimumWidth = 20; this.ColUpload.Name = "ColUpload"; this.ColUpload.ReadOnly = true; this.ColUpload.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // ColDownCap // this.ColDownCap.HeaderText = "Download Cap"; this.ColDownCap.Maximum = new decimal(new int[] { 10000, 0, 0, 0 }); this.ColDownCap.Name = "ColDownCap"; this.ColDownCap.ThousandsSeparator = true; // // ColUploadCap // this.ColUploadCap.HeaderText = "Upload Cap"; this.ColUploadCap.Maximum = new decimal(new int[] { 10000, 0, 0, 0 }); this.ColUploadCap.Name = "ColUploadCap"; this.ColUploadCap.ThousandsSeparator = true; // // ColBlock // this.ColBlock.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.ColBlock.FalseValue = "False"; this.ColBlock.FillWeight = 48.2451F; this.ColBlock.HeaderText = "Block"; this.ColBlock.MinimumWidth = 10; this.ColBlock.Name = "ColBlock"; this.ColBlock.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.ColBlock.TrueValue = "True"; // // ColSpoof // this.ColSpoof.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.ColSpoof.FalseValue = "False"; this.ColSpoof.HeaderText = "Spoof"; this.ColSpoof.MinimumWidth = 10; this.ColSpoof.Name = "ColSpoof"; this.ColSpoof.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.ColSpoof.TrueValue = "True"; this.ColSpoof.Visible = false; // // ContextMenuViews // this.ContextMenuViews.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.ViewMenuIP, this.ViewMenuMAC, this.ViewMenuDownload, this.ViewMenuUpload, this.ViewMenuDownloadCap, this.ViewMenuUploadCap, this.ViewMenuBlock, this.ViewMenuSpoof }); this.ContextMenuViews.Name = "ContextMenuViews"; this.ContextMenuViews.Size = new System.Drawing.Size(153, 180); this.ContextMenuViews.Text = "Columns Views"; // // ViewMenuIP // this.ViewMenuIP.Checked = true; this.ViewMenuIP.CheckOnClick = true; this.ViewMenuIP.CheckState = System.Windows.Forms.CheckState.Checked; this.ViewMenuIP.Name = "ViewMenuIP"; this.ViewMenuIP.Size = new System.Drawing.Size(152, 22); this.ViewMenuIP.Text = "IP"; this.ViewMenuIP.CheckStateChanged += new System.EventHandler(this.ViewMenuIP_CheckStateChanged); // // ViewMenuMAC // this.ViewMenuMAC.Checked = true; this.ViewMenuMAC.CheckOnClick = true; this.ViewMenuMAC.CheckState = System.Windows.Forms.CheckState.Checked; this.ViewMenuMAC.Name = "ViewMenuMAC"; this.ViewMenuMAC.Size = new System.Drawing.Size(152, 22); this.ViewMenuMAC.Text = "MAC"; this.ViewMenuMAC.CheckStateChanged += new System.EventHandler(this.ViewMenuMAC_CheckStateChanged); // // ViewMenuDownload // this.ViewMenuDownload.Checked = true; this.ViewMenuDownload.CheckOnClick = true; this.ViewMenuDownload.CheckState = System.Windows.Forms.CheckState.Checked; this.ViewMenuDownload.Name = "ViewMenuDownload"; this.ViewMenuDownload.Size = new System.Drawing.Size(152, 22); this.ViewMenuDownload.Text = "Download"; this.ViewMenuDownload.CheckStateChanged += new System.EventHandler(this.ViewMenuDownload_CheckStateChanged); // // ViewMenuUpload // this.ViewMenuUpload.Checked = true; this.ViewMenuUpload.CheckOnClick = true; this.ViewMenuUpload.CheckState = System.Windows.Forms.CheckState.Checked; this.ViewMenuUpload.Name = "ViewMenuUpload"; this.ViewMenuUpload.Size = new System.Drawing.Size(152, 22); this.ViewMenuUpload.Text = "Upload"; this.ViewMenuUpload.CheckStateChanged += new System.EventHandler(this.ViewMenuUpload_CheckStateChanged); // // ViewMenuDownloadCap // this.ViewMenuDownloadCap.Checked = true; this.ViewMenuDownloadCap.CheckOnClick = true; this.ViewMenuDownloadCap.CheckState = System.Windows.Forms.CheckState.Checked; this.ViewMenuDownloadCap.Name = "ViewMenuDownloadCap"; this.ViewMenuDownloadCap.Size = new System.Drawing.Size(152, 22); this.ViewMenuDownloadCap.Text = "Download Cap"; this.ViewMenuDownloadCap.CheckStateChanged += new System.EventHandler(this.DownloadCapToolStripMenuItem_CheckStateChanged); this.ViewMenuDownloadCap.Click += new System.EventHandler(this.DownloadCapToolStripMenuItem_Click); // // ViewMenuUploadCap // this.ViewMenuUploadCap.Checked = true; this.ViewMenuUploadCap.CheckState = System.Windows.Forms.CheckState.Checked; this.ViewMenuUploadCap.Name = "ViewMenuUploadCap"; this.ViewMenuUploadCap.Size = new System.Drawing.Size(152, 22); this.ViewMenuUploadCap.Text = "Upload Cap"; this.ViewMenuUploadCap.CheckStateChanged += new System.EventHandler(this.uploadCapToolStripMenuItem_CheckStateChanged); // // ViewMenuBlock // this.ViewMenuBlock.Checked = true; this.ViewMenuBlock.CheckOnClick = true; this.ViewMenuBlock.CheckState = System.Windows.Forms.CheckState.Checked; this.ViewMenuBlock.Name = "ViewMenuBlock"; this.ViewMenuBlock.Size = new System.Drawing.Size(152, 22); this.ViewMenuBlock.Text = "Block"; this.ViewMenuBlock.CheckStateChanged += new System.EventHandler(this.ViewMenuBlock_CheckStateChanged); // // ViewMenuSpoof // this.ViewMenuSpoof.CheckOnClick = true; this.ViewMenuSpoof.Name = "ViewMenuSpoof"; this.ViewMenuSpoof.Size = new System.Drawing.Size(152, 22); this.ViewMenuSpoof.Text = "Spoofed"; this.ViewMenuSpoof.CheckStateChanged += new System.EventHandler(this.ViewMenuSpoof_CheckStateChanged); // // imageList1 // this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); this.imageList1.TransparentColor = System.Drawing.Color.White; this.imageList1.Images.SetKeyName(0, "circle.png"); this.imageList1.Images.SetKeyName(1, "router.png"); // // timer1 // this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // // timer2 // this.timer2.Tick += new System.EventHandler(this.timer2_Tick); // // timerSpoof // this.timerSpoof.Tick += new System.EventHandler(this.timerSpoof_Tick); // // SelfishNetTrayIcon // this.SelfishNetTrayIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info; this.SelfishNetTrayIcon.BalloonTipText = "SelfishNet is minimized"; this.SelfishNetTrayIcon.BalloonTipTitle = "SelfishNet"; this.SelfishNetTrayIcon.Text = "SelfishNet"; this.SelfishNetTrayIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDoubleClick); // // timerDiscovery // this.timerDiscovery.Interval = 600000; // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(703, 402); this.Controls.Add(this.treeGridView1); this.Controls.Add(this.toolStrip1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.MaximizeBox = false; this.Name = "MainForm"; this.Text = "SelfishNetSabsab v0.1 Beta"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); this.Load += new System.EventHandler(this.MainForm_Load); this.Resize += new System.EventHandler(this.MainForm_Resize); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.treeGridView1)).EndInit(); this.ContextMenuViews.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); }
/// <summary> /// Starts an edit operation on a current cell. /// </summary> /// <param name="cellRowColumnIndex"> /// Specifies the row and column index of the cell to start an edit operation. /// </param> /// <param name="cellElement"> /// Specifies the UIElement of the cell to start an edit operation. /// </param> /// <param name="column"> /// The corresponding column to edit the cell. /// </param> /// <param name="record"> /// The corresponding record to edit the cell. /// </param> /// <returns> /// Returns <b>true</b> if the current cell starts an editing; otherwise, <b>false</b>. /// </returns> public virtual bool BeginEdit(RowColumnIndex cellRowColumnIndex, FrameworkElement cellElement, TreeGridColumn column, object record) { return(HasCurrentCellState && IsInEditing); }
/// <summary> /// Invoked when the UIElement for cell is prepared to render it in view . /// <see cref="Syncfusion.UI.Xaml.TreeGrid.Cells.TreeGridVirtualizingCellRendererBase"/> overrides this method and /// creates new UIElements and wires them with the parent cells control. /// </summary> /// <param name="dataColumn"> /// The corresponding column of the element. /// </param> /// <param name="record"> /// The corresponding Record for the element. /// </param> /// <param name="isInEdit"> /// Specifies whether the element is editable or not. /// </param> /// <returns> /// Returns the new cell UIElement. /// </returns> protected internal override FrameworkElement OnPrepareUIElements(TreeDataColumnBase dataColumn, object record, bool isInEdit) { RowColumnIndex cellRowColumnIndex = new RowColumnIndex(dataColumn.RowIndex, dataColumn.ColumnIndex); FrameworkElement cellContainer = dataColumn.ColumnElement; TreeGridColumn column = dataColumn.TreeGridColumn; FrameworkElement cellcontent = null; // Create TreeGridCell only for editable columns // UseOnlyRendererElement for Non-Editable columns if (!UseOnlyRendererElement) { if (dataColumn.ColumnElement == null) { throw new InvalidOperationException("ColumnElement can't be null in OnPrepareUIElements when UseOnlyRendererElement is false"); } cellContainer = dataColumn.ColumnElement; } else if (dataColumn.ColumnElement != null) { throw new InvalidOperationException("ColumnElement should be null in OnPrepareUIElements when UseOnlyRendererElement is true"); } if (this.SupportsRenderOptimization && !isInEdit) { if ((!column.hasCellTemplate && !column.hasCellTemplateSelector)) { // Cell Content will be created for Non Template cells. cellcontent = CreateOrRecycleDisplayUIElement(); InitializeDisplayElement(dataColumn, (D)cellcontent, record); WireDisplayUIElement((D)cellcontent); } else { // We wont create Cell Content for Templated cells. // TreeGridCell is used as RendererElement with template case. InitializeTemplateElement(dataColumn, (ContentControl)cellContainer, record); WireTemplateUIElement((ContentControl)cellContainer); } if (cellcontent != null && !UseOnlyRendererElement) { (cellContainer as TreeGridCell).Content = cellcontent; } } else { cellcontent = CreateOrEditRecycleUIElement(); if (dataColumn.TreeGridColumn != null) { dataColumn.TreeGridColumn.IsInSuspend = true; } InitializeEditElement(dataColumn, (E)cellcontent, record); if (dataColumn.TreeGridColumn != null) { dataColumn.TreeGridColumn.IsInSuspend = false; } WireEditUIElement((E)cellcontent); // TreeGridImageColumn, TreeeGridHyperLinkColumn and TreeGridCheckBoxColumn are Noneditable columns. //So content created and set to TreeGridCell. if (cellcontent != null && cellContainer is TreeGridCell) { (cellContainer as TreeGridCell).Content = cellcontent; } } return(UseOnlyRendererElement ? cellcontent : cellContainer); }
//Fix for IdataError based error is not updated while scrolling public override bool CanUpdateBinding(TreeGridColumn column) { return(true); // return column.GridValidationMode != GridValidationMode.None; }
protected override void OnColumnAdded(DataGridViewColumnEventArgs e) { if (typeof(TreeGridColumn).IsAssignableFrom(e.Column.GetType())) { if (_expandableColumn == null) { // identify the expanding column. _expandableColumn = (TreeGridColumn)e.Column; } else { // this.Columns.Remove(e.Column); //throw new InvalidOperationException("Only one TreeGridColumn per TreeGridView is supported."); } } // Expandable Grid doesn't support sorting. This is just a limitation of the sample. e.Column.SortMode = DataGridViewColumnSortMode.NotSortable; base.OnColumnAdded(e); }
private void UpdateListView() { //try //{ lock (_cache) { lock (statsTGV) { DataView infoDV = new DataView(_cache.Tables["StatisticInfo"]); if (!_columnsConfigured) { while (statsToolStripMenuItem.DropDownItems.Count > 2) { statsToolStripMenuItem.DropDownItems.RemoveAt(0); } statsTGV.Columns.Clear(); foreach (DataColumn dc in _cache.Tables["Statistics"].Columns) { if (dc.ColumnName == "boat_id") { TreeGridColumn tgc = new TreeGridColumn(); tgc.HeaderText = "Name"; tgc.Name = "Name"; tgc.Frozen = true; tgc.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; statsTGV.Columns.Add(tgc); DataGridViewTextBoxColumn color = new DataGridViewTextBoxColumn(); color.HeaderText = "Color"; color.Name = "Color"; color.Frozen = true; statsTGV.Columns.Add(color); } else if (dc.ColumnName == "leg_index" || dc.ColumnName == "tack_index") { } else { bool selectedByDefault = _replay.Boats[0].TotalStatistics.IsStatisticSelectedByDefault(dc.ColumnName); if (selectedByDefault) { DataGridViewTextBoxColumn dgvtbc = new DataGridViewTextBoxColumn(); dgvtbc.Name = dc.ColumnName; infoDV.RowFilter = "name='" + dc.ColumnName + "'"; string type = (string)infoDV[0]["type"]; string unit = (string)infoDV[0]["unit"]; string description = (string)infoDV[0]["description"]; if (unit != "other") { dgvtbc.HeaderText = dc.ColumnName + " (" + unit + ")"; dgvtbc.ToolTipText = "(" + unit + ") " + description; } statsTGV.Columns.Add(dgvtbc); } ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = dc.ColumnName; item.Checked = selectedByDefault; item.CheckOnClick = true; item.CheckedChanged += new EventHandler(selectStatisticToolStripMenuItem_Click); statsToolStripMenuItem.DropDownItems.Insert(statsToolStripMenuItem.DropDownItems.Count - 2, item); } } statsTGV.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.ColumnHeader); _columnsConfigured = true; } else { for (int i = 0; i < statsToolStripMenuItem.DropDownItems.Count; i++) { if (((ToolStripMenuItem)statsToolStripMenuItem.DropDownItems[i]).Checked) { if (statsToolStripMenuItem.DropDownItems[i].Text != "boat_id" && statsToolStripMenuItem.DropDownItems[i].Text != "leg_index" && !statsTGV.Columns.Contains(statsToolStripMenuItem.DropDownItems[i].Text)) { DataGridViewTextBoxColumn dgvtbc = new DataGridViewTextBoxColumn(); dgvtbc.Name = statsToolStripMenuItem.DropDownItems[i].Text; infoDV.RowFilter = "name='" + statsToolStripMenuItem.DropDownItems[i].Text + "'"; string type = (string)infoDV[0]["type"]; string unit = (string)infoDV[0]["unit"]; string description = (string)infoDV[0]["description"]; if (unit != "other") { dgvtbc.HeaderText = statsToolStripMenuItem.DropDownItems[i].Text + " (" + unit + ")"; dgvtbc.ToolTipText = "(" + unit + ") " + description; } statsTGV.Columns.Add(dgvtbc); } } else { if (statsTGV.Columns.Contains(statsToolStripMenuItem.DropDownItems[i].Text)) { statsTGV.Columns.Remove(statsTGV.Columns[statsToolStripMenuItem.DropDownItems[i].Text]); } } } } //statsTGV.Nodes.Clear(); int boatIndex = 0; TreeGridNode boat = null; int legIndex = 0; TreeGridNode leg = null; int tackIndex = 0; TreeGridNode tack = null; foreach (DataRow dr in _cache.Tables["Boats"].Rows) { string boatName = dr["name"].ToString() + " " + dr["number"].ToString(); Color boatColor = (Color)dr["color"]; Color boatColorLight = ColorHelper.Darken(boatColor); //Color.FromArgb(boatColor.R / 2, boatColor.G / 2, boatColor.B / 2); DataRow stats = _cache.Tables["Statistics"].Select("boat_id=" + dr["id"] + " and leg_index is null and tack_index is null")[0]; if (boatIndex < statsTGV.Nodes.Count) { for (int i = 0; i < statsTGV.Columns.Count; i++) { if (statsTGV.Columns[i].Name == "Name") { statsTGV.Nodes[boatIndex].Cells[i].Value = boatName; } else if (statsTGV.Columns[i].Name == "Color") { statsTGV.Nodes[boatIndex].Cells[i].Style.BackColor = boatColor; statsTGV.Nodes[boatIndex].Cells[i].Style.SelectionBackColor = boatColorLight; } else { //we might need to add cells if (i < statsTGV.Nodes[boatIndex].Cells.Count) { statsTGV.Nodes[boatIndex].Cells[statsTGV.Columns[i].Name].Value = FormatValue(stats[statsTGV.Columns[i].Name]); } else { //TreeGridCell c = new TreeGridCell(); DataGridViewTextBoxCell c = new DataGridViewTextBoxCell(); c.Value = FormatValue(stats[statsTGV.Columns[i].Name]); statsTGV.Nodes[boatIndex].Cells.Add(c); } } } //remove any excess nodes while (boatIndex >= statsTGV.Nodes.Count) { statsTGV.Nodes.RemoveAt(statsTGV.Nodes.Count - 1); } //remove any excess cells while (statsTGV.Nodes[boatIndex].Cells.Count > statsTGV.Columns.Count) { statsTGV.Nodes[boatIndex].Cells.RemoveAt(statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells.Count - 1); } boat = statsTGV.Nodes[boatIndex]; } else { List <object> values = new List <object>(); for (int i = 0; i < statsTGV.Columns.Count; i++) { if (statsTGV.Columns[i].Name == "Name") { values.Add(boatName); } else if (statsTGV.Columns[i].Name == "Color") { values.Add(""); } else { values.Add(FormatValue(stats[statsTGV.Columns[i].Name])); } } boat = statsTGV.Nodes.Add(values.ToArray()); } legIndex = 0; foreach (DataRow ldr in _cache.Tables["Legs"].Rows) { string legName = ldr["description"].ToString(); if (ldr["index"].ToString() != "") { DataRow[] drc = _cache.Tables["Statistics"].Select("boat_id=" + dr["id"] + " and leg_index=" + ldr["index"] + " and tack_index is null"); if (drc.Length > 0) { DataRow legstats = drc[0]; if (legIndex < boat.Nodes.Count) { for (int i = 0; i < statsTGV.Columns.Count; i++) { if (statsTGV.Columns[i].Name == "Name") { statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells[i].Value = legName; } else if (statsTGV.Columns[i].Name == "Color") { statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells[i].Style.BackColor = boatColor; statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells[i].Style.SelectionBackColor = boatColorLight; } else { //we might need to add cells if (i < statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells.Count) { statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells[i].Value = FormatValue(legstats[statsTGV.Columns[i].Name]); } else { //TreeGridCell c=new TreeGridCell(); DataGridViewTextBoxCell c = new DataGridViewTextBoxCell(); c.Value = FormatValue(legstats[statsTGV.Columns[i].Name]); statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells.Add(c); } } } //remove any excess nodes while (legIndex >= boat.Nodes.Count) { boat.Nodes.RemoveAt(boat.Nodes.Count - 1); } //remove any excess cells while (statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells.Count > statsTGV.Columns.Count) { statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells.RemoveAt(statsTGV.Nodes[boatIndex].Nodes[legIndex].Cells.Count - 1); } leg = statsTGV.Nodes[boatIndex].Nodes[legIndex]; } else { List <object> legvalues = new List <object>(); for (int i = 0; i < statsTGV.Columns.Count; i++) { if (statsTGV.Columns[i].Name == "Name") { legvalues.Add(legName); } else if (statsTGV.Columns[i].Name == "Color") { legvalues.Add(""); } else { legvalues.Add(FormatValue(legstats[statsTGV.Columns[i].Name])); } } leg = boat.Nodes.Add(legvalues.ToArray()); } } try { DataRow[] tackRows = _cache.Tables["Tacks"].Select(string.Format("boat_id={0} and leg_index={1}", dr["id"], ldr["index"]), "tack_index asc"); tackIndex = 0; foreach (DataRow tdr in tackRows) { string tackName = tdr["Name"].ToString(); DataRow[] trc = _cache.Tables["Statistics"].Select("boat_id=" + dr["id"] + " and leg_index=" + ldr["index"] + " and tack_index=" + tdr["tack_index"]); if (trc.Length > 0) { DataRow tackstats = trc[0]; if (tackIndex < leg.Nodes.Count) { for (int i = 0; i < statsTGV.Columns.Count; i++) { if (statsTGV.Columns[i].Name == "Name") { statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells[i].Value = tackName; } else if (statsTGV.Columns[i].Name == "Color") { statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells[i].Style.BackColor = boatColor; statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells[i].Style.SelectionBackColor = boatColorLight; } else { //we might need to add cells if (i < statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells.Count) { statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells[i].Value = FormatValue(tackstats[statsTGV.Columns[i].Name]); } else { //TreeGridCell c=new TreeGridCell(); DataGridViewTextBoxCell c = new DataGridViewTextBoxCell(); c.Value = FormatValue(tackstats[statsTGV.Columns[i].Name]); statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells.Add(c); } } } //remove any excess nodes while (tackIndex >= leg.Nodes.Count) { leg.Nodes.RemoveAt(leg.Nodes.Count - 1); } //remove any excess cells while (statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells.Count > statsTGV.Columns.Count) { statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells.RemoveAt(statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex].Cells.Count - 1); } tack = statsTGV.Nodes[boatIndex].Nodes[legIndex].Nodes[tackIndex]; } else { List <object> tackvalues = new List <object>(); for (int i = 0; i < statsTGV.Columns.Count; i++) { if (statsTGV.Columns[i].Name == "Name") { tackvalues.Add(tackName); } else if (statsTGV.Columns[i].Name == "Color") { tackvalues.Add(""); } else { tackvalues.Add(FormatValue(tackstats[statsTGV.Columns[i].Name])); } } tack = leg.Nodes.Add(tackvalues.ToArray()); } } tackIndex++; } } catch (Exception) { #warning catch with no implementation.... why the f**k did i do this? it must be for a reason } legIndex++; } } boatIndex++; } } } //} //catch (Exception e) //{ // #warning remove this try catch block for production // //this is just here for a breakpoint, delete it later // throw e; //} //statsTGV.SelectionMode = DataGridViewSelectionMode.CellSelect; }