/// <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); //} }