/// <summary> /// Mostrar en un tooltip la descripción de la Propiedad cuando se pase el mouse por encima /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void newGrid_CellMouseEnter(object sender, DataGridViewCellEventArgs e) { DataGridView newGrid = (DataGridView)sender; BindingSource bs = (BindingSource)newGrid.DataSource; // Mostrar en un tooltip la descripción de la Propiedad cuando se pase el mouse por encima if (e.RowIndex == -1 && e.ColumnIndex != -1 && newGrid.DataSource != null) { Type tipo = TypeMethods.HeuristicallyDetermineType((IEnumerable)bs.DataSource); var property = tipo.GetProperty(newGrid.Columns[e.ColumnIndex].DataPropertyName); var description = TypeMethods.GetDescriptionFromPropertyInfo(property); if (string.IsNullOrWhiteSpace(description)) { tt.Hide(newGrid); } else { tt.SetToolTip(newGrid, description); } } //else //{ // tt.Hide(newGrid); //} }
void MasterGridView_CellMouseEnter(object sender, DataGridViewCellEventArgs e) { // Show tooltip of Property Description in Header's Column if (e.RowIndex == -1 && e.ColumnIndex != -1 && this.DataSource != null) { string description = string.Empty; if (DataSource is BindingSource) { var tipo = ((BindingSource)DataSource).Current.GetType(); var property = tipo.GetProperty(this.Columns[e.ColumnIndex].DataPropertyName); description = TypeMethods.GetDescriptionFromPropertyInfo(property); } else { return; } if (string.IsNullOrWhiteSpace(description)) { tt.Hide(this); } else { tt.SetToolTip(this, description); } } //else //{ // tt.Hide(this); //} }
internal void AddChildgrid(IList listOfDetail, string name) { DataGridView grid = new DataGridView(); // poner un contador en el rowheader grid.RowPostPaint += cModule.rowPostPaint_HeaderCount; // Mostrar en un tooltip la descripción de la Propiedad cuando se pase el mouse por encima grid.CellMouseEnter += newGrid_CellMouseEnter; grid.CellEndEdit += grid_CellEndEdit; grid.KeyDown += grid_KeyDown; Type tipo = TypeMethods.HeuristicallyDetermineType(listOfDetail); ConfigChildGrid.configColumns(grid, tipo); cModule.applyGridTheme(grid); // Agregar la data BindingSource bs = new BindingSource(); bs.DataSource = listOfDetail; bs.AllowNew = true; grid.DataSource = bs; cModule.setGridColumnStyleAfterBinding(grid); // Existen algunas colecciones del tipo doble que no queremos que se muestren if (TypeMethods.HeuristicallyDetermineType(listOfDetail) != typeof(double)) { TabPage tabpage = new TabPage { Text = name }; tabpage.ToolTipText = TypeMethods.GetDescriptionFromType(tipo); tabpage.Controls.Add(grid); this.TabPages.Add(tabpage); } }
/// <summary> /// Abre/Cierra la subGrilla de detalle /// </summary> /// <param name="rowIndex">Índice del registro a editar</param> private void OpenDetail(int rowIndex) { if (lstCurrentRows.Contains(rowIndex)) { lstCurrentRows.Clear(); this.Rows[rowIndex].Height = rowDefaultHeight; this.Rows[rowIndex].DividerHeight = rowDefaultDivider; } else { if (lstCurrentRows.Count != 0) { int eRow = lstCurrentRows[0]; lstCurrentRows.Clear(); this.Rows[eRow].Height = rowDefaultHeight; this.Rows[eRow].DividerHeight = rowDefaultDivider; this.ClearSelection(); doCollapseRow = true; this.Rows[eRow].Selected = true; } lstCurrentRows.Add(rowIndex); Type parentType = TypeMethods.HeuristicallyDetermineType((IList)this.DataSource); object parentObject = this.Rows[rowIndex].DataBoundItem; // Detalle detailTabControl.TabPages.Clear(); detailTabControl.openDetailEvent += detailTabControl_OpenDetail; if (parentObject != null) { foreach (FieldInfo childField in parentType.GetFields()) { if (childField.FieldType.IsGenericType && childField.FieldType.GetGenericTypeDefinition() == typeof(List <>) && childField.FieldType.GetGenericTypeDefinition() != typeof(List <double>)) { IList listOfDetail = (IList)childField.GetValue(parentObject); string name = TypeMethods.GetDescriptionFromFieldInfo(childField); detailTabControl.AddChildgrid(listOfDetail, name); } } } // expandir la fila if (detailTabControl.HasChildren) { this.Rows[rowIndex].Height = rowExpandedHeight; this.Rows[rowIndex].DividerHeight = rowExpandedDivider; } else { detailTabControl.Visible = false; } } this.ClearSelection(); doCollapseRow = true; this.Rows[rowIndex].Selected = true; }