private void InitializeDataListView(FastObjectListView olv) { olv.UseAlternatingBackColors = true; olv.AlternateRowBackColor = Color.Bisque; olv.ShowItemCountOnGroups = true; olv.OwnerDraw = true; // Zonder dit attribuut werden de checkboxes niet getekend maar kwam er True/False te staan. olv.FullRowSelect = true; //olv.CheckBoxes = true; olv.CellEditActivation = FastObjectListView.CellEditActivateMode.DoubleClick; olv.UseFiltering = true; olv.UseFilterIndicator = true; olv.GroupWithItemCountFormat = "{0} ({1} Leden)"; olv.GroupWithItemCountSingularFormat = "{0} ({1} Lid)"; olv.HeaderWordWrap = true; olv.View = System.Windows.Forms.View.Details; olv.ShowGroups = false; olv.EmptyListMsg = "This list is empty."; olv.AddDecoration(new EditingCellBorderDecoration(true)); olv.UseSubItemCheckBoxes = true; // Make the tooltips look somewhat different //olv.CellToolTip.BackColor = Color.Black; //olv.CellToolTip.ForeColor = Color.AntiqueWhite; //olv.HeaderToolTip.BackColor = Color.AntiqueWhite; //olv.HeaderToolTip.ForeColor = Color.Black; //olv.HeaderToolTip.IsBalloon = true; }
public static void ConfigureFOLV(ref FastObjectListView FOLV, Type Cls, System.Drawing.Font Fnt, ImageList ImageList, string PrimarySortColumnName = "", SortOrder PrimarySortOrder = SortOrder.Ascending, string SecondarySortColumnName = "", SortOrder SecondarySortOrder = SortOrder.Ascending, List <string> FilterColumnList = null, Color Clr = new Color(), int RowHeight = 0, bool ShowGroups = false) { try { FOLV.AllowColumnReorder = true; FOLV.CellEditActivation = ObjectListView.CellEditActivateMode.DoubleClick; FOLV.CopySelectionOnControlC = true; FOLV.FullRowSelect = true; FOLV.GridLines = true; FOLV.HideSelection = false; FOLV.IncludeColumnHeadersInCopy = true; FOLV.OwnerDraw = true; FOLV.SelectColumnsOnRightClick = true; FOLV.SelectColumnsOnRightClickBehaviour = ObjectListView.ColumnSelectBehaviour.ModelDialog; FOLV.SelectedColumnTint = Color.LawnGreen; FOLV.ShowCommandMenuOnRightClick = true; FOLV.ShowFilterMenuOnRightClick = true; FOLV.ShowGroups = false; FOLV.ShowImagesOnSubItems = true; FOLV.ShowItemCountOnGroups = true; FOLV.ShowItemToolTips = true; FOLV.ShowSortIndicators = true; FOLV.SortGroupItemsByPrimaryColumn = true; FOLV.TintSortColumn = true; FOLV.UseFiltering = true; FOLV.UseHyperlinks = false; //may cause column save/restore error? FOLV.CellEditActivation = ObjectListView.CellEditActivateMode.DoubleClick; FOLV.UseCellFormatEvents = true; FOLV.UseNotifyPropertyChanged = true; if (ImageList != null) { FOLV.SmallImageList = ImageList; } if (Fnt != null) { FOLV.Font = Fnt; } else { FOLV.Font = new Font("Consolas", 8, FontStyle.Regular); } if (Clr.IsEmpty) { FOLV.ForeColor = Clr; } PropertyInfo[] IIProps2 = Cls.GetProperties(); //Cls.GetType().GetProperties // Uncomment this to see a fancy cell highlighting while editing EditingCellBorderDecoration EC = new EditingCellBorderDecoration(true); EC.UseLightbox = true; FOLV.AddDecoration(EC); FOLV.BuildList(); int colcnt = 0; foreach (PropertyInfo ei in IIProps2) { if (typeof(IEnumerable).IsAssignableFrom(ei.PropertyType) && !(ei.PropertyType.Name == "String")) { continue; } else if (ei.PropertyType.Name == "Object") { continue; } colcnt = colcnt + 1; OLVColumn cl = new OLVColumn(); if (ImageList != null) { //if (FOLV.Name == "FOLV_UpdateList" && colcnt == 1) //{ // cl.ImageGetter = GetImageForUpdateList; //} //else if (FOLV.Name == "FOLV_BlocklistViewer" && ei.Name == "RegionalInternetRegistry") //{ // cl.ImageGetter = GetImageForBlocklistViewerRIR; //} //else if (FOLV.Name == "FOLV_Apps" && colcnt == 1) //{ // cl.ImageGetter = GetImageForProdList; //} } //cl.AspectName = ei.Name cl.UseFiltering = true; cl.Searchable = true; cl.Text = ei.Name; cl.Name = ei.Name; cl.DataType = ei.PropertyType; cl.AspectName = ei.Name; if (ei.PropertyType.Name == "Int64" || ei.PropertyType.Name == "Int32" || ei.PropertyType.Name == "Timespan") { cl.TextAlign = HorizontalAlignment.Right; } if (ei.Name == "UniqueID" || ei.Name == "FoundElementList") { cl.MinimumWidth = 0; cl.MaximumWidth = 0; cl.Width = 0; } else { cl.MinimumWidth = 50; //cl.MaximumWidth = 20000 //cl.Width = -2 } if (ei.Name.ToLower().Contains("url")) { cl.Hyperlink = true; } //If cl.DataType = GetType(Boolean) Then // cl.CheckBoxes = True // cl.IsEditable = False //End If if (ei.Name.ToLower() == PrimarySortColumnName.ToLower()) { FOLV.PrimarySortColumn = cl; FOLV.PrimarySortOrder = PrimarySortOrder; //SortOrder.Descending //cl.ImageGetter = AddressOf GetImageFromProd } if (ei.Name.ToLower() == SecondarySortColumnName.ToLower()) { FOLV.SecondarySortColumn = cl; FOLV.SecondarySortOrder = SecondarySortOrder; //SortOrder.Descending } FOLV.Columns.Add(cl); } //OLV.RebuildColumns() FOLV.Refresh(); FOLV.BuildList(); Application.DoEvents(); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } finally { } }
public static void ConfigureFOLV(FastObjectListView FOLV, Type Cls, System.Drawing.Font Fnt = null, ImageList ImageList = null, string PrimarySortColumnName = "", SortOrder PrimarySortOrder = SortOrder.Ascending, string SecondarySortColumnName = "", SortOrder SecondarySortOrder = SortOrder.Ascending, List <string> FilterColumnList = null, Color Clr = new Color(), int RowHeight = 0, bool ShowGroups = false, bool GridLines = true) { //Global_GUI.InvokeIFRequired(FOLV, () => //{ try { FOLV.AllowColumnReorder = true; FOLV.CopySelectionOnControlC = true; FOLV.FullRowSelect = true; FOLV.GridLines = GridLines; FOLV.HideSelection = false; FOLV.IncludeColumnHeadersInCopy = true; FOLV.OwnerDraw = true; FOLV.SelectColumnsOnRightClick = true; FOLV.SelectColumnsOnRightClickBehaviour = ObjectListView.ColumnSelectBehaviour.InlineMenu; FOLV.SelectedColumnTint = Color.LawnGreen; FOLV.ShowCommandMenuOnRightClick = true; FOLV.ShowFilterMenuOnRightClick = true; FOLV.ShowGroups = false; FOLV.ShowImagesOnSubItems = true; FOLV.ShowItemCountOnGroups = true; FOLV.ShowItemToolTips = true; FOLV.ShowSortIndicators = true; FOLV.SortGroupItemsByPrimaryColumn = true; FOLV.TintSortColumn = true; FOLV.UseFiltering = true; FOLV.UseHyperlinks = true; //may cause column save/restore error? FOLV.CellEditActivation = ObjectListView.CellEditActivateMode.DoubleClick; FOLV.UseCellFormatEvents = true; FOLV.UseNotifyPropertyChanged = true; if (ImageList != null) { FOLV.SmallImageList = ImageList; } if (Fnt != null) { FOLV.Font = Fnt; } else { FOLV.Font = new Font("Consolas", 8, FontStyle.Regular); } if (Clr.IsEmpty) { FOLV.ForeColor = Clr; } object[] IIProps2 = Cls.GetProperties(); //Cls.GetType().GetProperties //if (IIProps2.Length == 0) // IIProps2 = Cls.GetFields(); // Uncomment this to see a fancy cell highlighting while editing EditingCellBorderDecoration EC = new EditingCellBorderDecoration(true); EC.UseLightbox = true; FOLV.AddDecoration(EC); FOLV.BuildList(); int colcnt = 0; //for (int i = 0; i < IIProps2.Length; i++) //{ // object ei = IIProps2[i]; //} foreach (PropertyInfo ei in IIProps2) { if (typeof(IEnumerable).IsAssignableFrom(ei.PropertyType) && !(ei.PropertyType.Name == "String")) { continue; } else if (ei.PropertyType.Name == "Object") { continue; } colcnt = colcnt + 1; OLVColumn cl = new OLVColumn(); if (FOLV.SmallImageList != null) { if (string.Equals(FOLV.Name, "folv_history", StringComparison.OrdinalIgnoreCase)) { if (colcnt == 1) { cl.ImageGetter = GetImageForHistoryList; } else if (ei.Name == "IsPerson") { cl.ImageGetter = GetImageForHistoryListPerson; cl.AspectToStringConverter = delegate(object x) { return(String.Empty); }; } else if (ei.Name == "Success") { cl.ImageGetter = GetImageForHistoryListSuccess; cl.AspectToStringConverter = delegate(object x) { return(String.Empty); }; } } else if (string.Equals(FOLV.Name, "FOLV_AIServers", StringComparison.OrdinalIgnoreCase)) { if (colcnt == 1) { cl.ImageGetter = GetImageForAIServerList; } } else if (string.Equals(FOLV.Name, "FOLV_Cameras", StringComparison.OrdinalIgnoreCase)) { if (colcnt == 1) { cl.ImageGetter = GetImageForCameraList; } } //else if (FOLV.Name == "FOLV_BlocklistViewer" && ei.Name == "RegionalInternetRegistry") //{ // cl.ImageGetter = GetImageForBlocklistViewerRIR; //} //else if (FOLV.Name == "FOLV_Apps" && colcnt == 1) //{ // cl.ImageGetter = GetImageForProdList; //} } //cl.AspectName = ei.Name cl.UseFiltering = true; cl.Searchable = true; cl.Text = ei.Name; cl.Name = ei.Name; cl.DataType = ei.PropertyType; cl.AspectName = ei.Name; if (cl.Name == "Func" || ei.PropertyType.Name == "Int64" || ei.PropertyType.Name == "Int32" || ei.PropertyType.Name == "Timespan") { cl.TextAlign = HorizontalAlignment.Right; } if (ei.Name == "UniqueID" || ei.Name == "FoundElementList") { cl.MinimumWidth = 0; cl.MaximumWidth = 0; cl.Width = 0; } else { cl.MinimumWidth = 50; //cl.MaximumWidth = 20000 //cl.Width = -2 } if (ei.Name.IndexOf("url", StringComparison.OrdinalIgnoreCase) >= 0) { cl.Hyperlink = true; } if ((ei.Name.Has("percent") || ei.Name.Has("threshold") || ei.Name.Has("confidence")) && (ei.PropertyType == typeof(double) || ei.PropertyType == typeof(int) || ei.PropertyType == typeof(float))) { cl.AspectToStringFormat = "{0:0.#}%"; } //if (ei.PropertyType == typeof(ThreadSafe.Boolean)) //{ // if (FOLV.Name == "FOLV_AIServers") // { // cl.AspectGetter = delegate (object rowObject) // { // bool ret = false; // ClsURLItem obj = (ClsURLItem)rowObject; // if (ei.Name == "Enabled") // { // ret = obj.Enabled.ReadFullFence(); // } // else if (ei.Name == "InUse") // { // ret = obj.InUse.ReadFullFence(); // } // else // { // int test = 0; // } // return ret; // }; // cl.DataType = typeof(bool); // cl.CheckBoxes = true; // } //} //if (ei.Name == "Enabled") //{ // int test = 0; //} //if (ei.PropertyType == typeof(Boolean)) //{ // cl.CheckBoxes = true; // cl.IsEditable = false; //} if (string.Equals(ei.Name, PrimarySortColumnName, StringComparison.OrdinalIgnoreCase)) { FOLV.PrimarySortColumn = cl; FOLV.PrimarySortOrder = PrimarySortOrder; //SortOrder.Descending //cl.ImageGetter = AddressOf GetImageFromProd } if (string.Equals(ei.Name, SecondarySortColumnName, StringComparison.OrdinalIgnoreCase)) { FOLV.SecondarySortColumn = cl; FOLV.SecondarySortOrder = SecondarySortOrder; //SortOrder.Descending } FOLV.AllColumns.Add(cl); //Columns vs AllColumns? } //restore column state if it exists FOLVRestoreState(FOLV); //OLV.RebuildColumns() FOLV.Refresh(); FOLV.BuildList(); FOLV.RebuildColumns(); //Application.DoEvents(); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } finally { } //}); }
private void InitializeDataListView(FastObjectListView olv) { olv.UseSubItemCheckBoxes = true; //zonder dit attribuut komen de checkboxes niet op de lijst te staan olv.AddDecoration(new EditingCellBorderDecoration(true)); olv.CellEditFinishing += new BrightIdeasSoftware.CellEditEventHandler(this.olv_CellEditFinishing); }
private void InitializeDataListView(FastObjectListView olv) { olv.UseSubItemCheckBoxes = true; //zonder dit attribuut komen de checkboxes niet op de lijst te staan olv.AddDecoration(new EditingCellBorderDecoration(true)); }