// The user reordered the columns. Resort. protected override void OnColumnReordered(System.Windows.Forms.ColumnReorderedEventArgs e) { // This raises the ColumnReordered event. base.OnColumnReordered(e); // If the main program canceled, do nothing. if (e.Cancel) { return; } // Rebuild the list of sort sub-items. SetSortSubitems( ); // Fix the list up to account for the moved column. MoveArrayItem(_sortSubitems, e.OldDisplayIndex, e.NewDisplayIndex); // Resort. this.Sort( ); }
private void ListDownloads_ColumnReordered(object sender, ColumnReorderedEventArgs e) { string[] oldOrder = new string[this.ListDownloads.Columns.Count]; // Fetch the pre-reorder column order foreach (ColumnHeader col in this.ListDownloads.Columns) { oldOrder[col.DisplayIndex] = ((int)this.downloadColOrder[col.Index]).ToString(CultureInfo.InvariantCulture); } List<string> newOrder = new List<string>(oldOrder); string moveCol = newOrder[e.OldDisplayIndex]; // Re-order the data to match the new column order newOrder.RemoveAt(e.OldDisplayIndex); newOrder.Insert(e.NewDisplayIndex, moveCol); // Save the new column order to the preference Settings.DownloadCols = string.Join(",", newOrder.ToArray()); if (e.OldDisplayIndex == 0 || e.NewDisplayIndex == 0) { // The reorder involves column 0 which contains the icons, so re-initialise the list e.Cancel = true; this.InitDownloadList(); } }
protected virtual void OnColumnReordered(ColumnReorderedEventArgs e) { throw null; }
private void MyList_ColumnReordered(object sender, ColumnReorderedEventArgs e) { DetailsListView lst = (DetailsListView)sender; if (_cfgLocal == null) return; if (_iconCol) { _cfgLocal.Width1 = lst.Columns[0].Width; _cfgLocal.Width3 = lst.Columns[1].Width; } else { int[] darr = new int[lst.Columns.Count]; for (int i = 0; i < lst.Columns.Count; i++) { darr[lst.Columns[i].DisplayIndex] = i; } MyCommon.MoveArrayItem(darr, e.OldDisplayIndex, e.NewDisplayIndex); for (int i = 0; i < lst.Columns.Count; i++) { switch (darr[i]) { case 0: _cfgLocal.DisplayIndex1 = i; break; case 1: _cfgLocal.DisplayIndex2 = i; break; case 2: _cfgLocal.DisplayIndex3 = i; break; case 3: _cfgLocal.DisplayIndex4 = i; break; case 4: _cfgLocal.DisplayIndex5 = i; break; case 5: _cfgLocal.DisplayIndex6 = i; break; case 6: _cfgLocal.DisplayIndex7 = i; break; case 7: _cfgLocal.DisplayIndex8 = i; break; } } _cfgLocal.Width1 = lst.Columns[0].Width; _cfgLocal.Width2 = lst.Columns[1].Width; _cfgLocal.Width3 = lst.Columns[2].Width; _cfgLocal.Width4 = lst.Columns[3].Width; _cfgLocal.Width5 = lst.Columns[4].Width; _cfgLocal.Width6 = lst.Columns[5].Width; _cfgLocal.Width7 = lst.Columns[6].Width; _cfgLocal.Width8 = lst.Columns[7].Width; } _modifySettingLocal = true; _isColumnChanged = true; }
internal void ReorderColumn (ColumnHeader col, int index, bool fireEvent) { if (fireEvent) { ColumnReorderedEventHandler eh = (ColumnReorderedEventHandler) (Events [ColumnReorderedEvent]); if (eh != null){ ColumnReorderedEventArgs args = new ColumnReorderedEventArgs (col.Index, index, col); eh (this, args); if (args.Cancel) { header_control.Invalidate (); item_control.Invalidate (); return; } } } int column_count = Columns.Count; if (reordered_column_indices == null) { reordered_column_indices = new int [column_count]; for (int i = 0; i < column_count; i++) reordered_column_indices [i] = i; } if (reordered_column_indices [index] == col.Index) return; int[] curr = reordered_column_indices; int [] result = new int [column_count]; int curr_idx = 0; for (int i = 0; i < column_count; i++) { if (curr_idx < column_count && curr [curr_idx] == col.Index) curr_idx++; if (i == index) result [i] = col.Index; else result [i] = curr [curr_idx++]; } ReorderColumns (result, true); }
private void _tgMsgs_ColumnReordered(object sender, ColumnReorderedEventArgs e) { Config.Instance.ForumColumnOrder = _tgMsgs.ColumnsOrder; }
/// <include file='doc\ListView.uex' path='docs/doc[@for="ListView.OnColumnReordered"]/*' /> /// <devdoc> /// Fires the column header rearranged event. /// </devdoc> protected virtual void OnColumnReordered(ColumnReorderedEventArgs e) { ColumnReorderedEventHandler handler = (ColumnReorderedEventHandler) Events[EVENT_COLUMNREORDERED]; if (handler != null) handler(this, e); }
/// <summary> /// On column reorder we update the settings. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void lvResearchPoints_ColumnReordered(object sender, ColumnReorderedEventArgs e) { m_columnsChanged = true; }
private void lstGames_ColumnReordered(object sender, ColumnReorderedEventArgs e) { columnReorderThread = new Thread(new ThreadStart(ColumnReorderWorker)); columnReorderThread.Start(); }
private void listViewLogMessages_ColumnReordered(object sender, ColumnReorderedEventArgs e) { LogColumn lc = e.Header.Tag as LogColumn; if (lc == null) { e.Cancel = true; return; } logger.Debug("Moving '{0}' from {1} to {2}", lc.Name, e.OldDisplayIndex, e.NewDisplayIndex); if (e.NewDisplayIndex > e.OldDisplayIndex) { _session.Columns.Insert(e.NewDisplayIndex, lc); _session.Columns.RemoveAt(e.OldDisplayIndex - 1); } else { _session.Columns.RemoveAt(e.OldDisplayIndex - 1); _session.Columns.Insert(e.NewDisplayIndex - 1, lc); } e.Cancel = true; ReloadColumns(); }
/// <summary> /// On column reorder we update the settings. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listView_ColumnReordered(object sender, ColumnReorderedEventArgs e) { m_columnsChanged = true; }
private void lvDesign_ColumnReordered(object sender, ColumnReorderedEventArgs e) { var layout = XDocument.Parse(this.LayoutXml.OuterXml); var cells = layout.Descendants().First().Descendants().First().Descendants(); var source = cells.ElementAt(e.OldDisplayIndex); var target = cells.ElementAt(e.NewDisplayIndex); if (e.OldDisplayIndex > e.NewDisplayIndex) { target.AddBeforeSelf(source); } else { target.AddAfterSelf(source); } source.Remove(); this.LayoutXml.LoadXml(layout.ToString()); this.IsLayoutXmlChanged = true; }
private void HandleColumnReordered(object sender, ColumnReorderedEventArgs e) { // Disallow reordering the checkbox column, either by moving it or moving something into its place if (HasCheckBoxColumn && (e.OldDisplayIndex == 0 || e.NewDisplayIndex == 0)) { e.Cancel = true; return; } // At this point, we want to re-arrange the dependent parts of the display (the filter bar and the main data area) // to reflect the re-ordering of the columns. // However, the system has not actually re-ordered them. So we must simulate the order it is going to change // them to. // Now we want an array of integers showing how they are re-ordered. // columnDisplayOrder[i] is the position that element i in the old (previous, not original) order will have in the new order. // Note that we cannot depend on e.OldDisplayIndex. In Windows, this is the position in the // most recent previous display order; in Mono, it is the position in the original sequence. // However, both systems seem to pass us the columns with each header having its pre-change // DisplayIndex intact. var columnDisplayOrder = Enumerable.Range(0, Columns.Count).ToList(); var reorderedColumnHeader = columnDisplayOrder[e.Header.DisplayIndex]; columnDisplayOrder.Remove(reorderedColumnHeader); columnDisplayOrder.Insert(e.NewDisplayIndex, reorderedColumnHeader); // Let affected browse view update its columns of data if (ColumnDragDropReordered != null) ColumnDragDropReordered(this, new ColumnDragDropReorderedEventArgs(columnDisplayOrder)); //Adjust the browseViewer column ordering whenever columns are moved. m_bv.OrderForColumnsDisplay = m_orderForColumnsDisplay; }
private void listLogPackets_ColumnReordered(object sender, ColumnReorderedEventArgs e) { PacketLogColumn col = _config.Columns[e.OldDisplayIndex]; _config.Columns.RemoveAt(e.OldDisplayIndex); _config.Columns.Insert(e.NewDisplayIndex, col); OnConfigChanged(); }
private void OnColumnReorderedEvent(object sender, SWF.ColumnReorderedEventArgs args) { RaiseAutomationEvent(); }
private void TgMsgsColumnReordered(object sender, ColumnReorderedEventArgs e) { Config.Instance.SearchColumnOrder = _tgMsgs.ColumnsOrder; }
/* D O C O L U M N R E O R D E R */ /*---------------------------------------------------------------------------- %%Function: DoColumnReorder %%Qualified: AzLog.AzLogWindow.DoColumnReorder %%Contact: rlittle Handle a drag of the column header (reordering the columns) ----------------------------------------------------------------------------*/ private void DoColumnReorder(object sender, ColumnReorderedEventArgs e) { m_azlvs.MoveColumn(e.OldDisplayIndex, e.NewDisplayIndex); // just notify it of the move, this doesn't change anything until we save because the listview already did the move for us. DirtyView(true); // really, this is just about remembering the tab order... }
/// <summary> /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed. /// <example> /// columnreorderedeventhandler.BeginInvoke(sender, e, callback); /// </example> /// </summary> public static IAsyncResult BeginInvoke(this ColumnReorderedEventHandler columnreorderedeventhandler, Object sender, ColumnReorderedEventArgs e, AsyncCallback callback) { if(columnreorderedeventhandler == null) throw new ArgumentNullException("columnreorderedeventhandler"); return columnreorderedeventhandler.BeginInvoke(sender, e, callback, null); }
/// <summary> /// Upon column reordering we force a column settings update. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lvSkills_ColumnReordered(object sender, ColumnReorderedEventArgs e) { m_columnsOrderChanged = true; }
public void ColumnReordered (object sender, ColumnReorderedEventArgs e) { columnReordered++; }
private unsafe bool WmNotify(ref Message m) { NativeMethods.NMHDR* nmhdr = (NativeMethods.NMHDR*)m.LParam; // column header custom draw message handling if (nmhdr->code == NativeMethods.NM_CUSTOMDRAW && OwnerDraw) { try { NativeMethods.NMCUSTOMDRAW* nmcd = (NativeMethods.NMCUSTOMDRAW*)m.LParam; // Find out which stage we're drawing switch (nmcd->dwDrawStage) { case NativeMethods.CDDS_PREPAINT: { m.Result = (IntPtr)(NativeMethods.CDRF_NOTIFYITEMDRAW); return true; // we are done - don't do default handling } case NativeMethods.CDDS_ITEMPREPAINT: { Graphics g = Graphics.FromHdcInternal(nmcd->hdc); Rectangle r = Rectangle.FromLTRB(nmcd->rc.left, nmcd->rc.top, nmcd->rc.right, nmcd->rc.bottom); DrawListViewColumnHeaderEventArgs e = null; try { Color foreColor = ColorTranslator.FromWin32(SafeNativeMethods.GetTextColor(new HandleRef(this, nmcd->hdc))); Color backColor = ColorTranslator.FromWin32(SafeNativeMethods.GetBkColor(new HandleRef(this, nmcd->hdc))); Font font = GetListHeaderFont(); e = new DrawListViewColumnHeaderEventArgs(g, r, (int)(nmcd->dwItemSpec), columnHeaders[(int)nmcd->dwItemSpec], (ListViewItemStates)(nmcd->uItemState), foreColor, backColor, font); OnDrawColumnHeader(e); } finally { g.Dispose(); } if (e.DrawDefault) { m.Result = (IntPtr)(NativeMethods.CDRF_DODEFAULT); return false; } else { m.Result = (IntPtr)(NativeMethods.CDRF_SKIPDEFAULT); return true; // we are done - don't do default handling } } default: return false; //default handling } } catch (Exception e) { Debug.Fail("Exception occurred attempting to setup header custom draw. Disabling custom draw for the column header", e.ToString()); m.Result = (IntPtr)NativeMethods.CDRF_DODEFAULT; } } if (nmhdr->code == NativeMethods.NM_RELEASEDCAPTURE && listViewState[LISTVIEWSTATE_columnClicked]) { listViewState[LISTVIEWSTATE_columnClicked] = false; OnColumnClick(new ColumnClickEventArgs(columnIndex)); } if (nmhdr->code == NativeMethods.HDN_BEGINTRACKA || nmhdr->code == NativeMethods.HDN_BEGINTRACKW) { this.listViewState[LISTVIEWSTATE_headerControlTracking] = true; // Reset our tracking information for the new BEGINTRACK cycle. this.listViewState1[LISTVIEWSTATE1_cancelledColumnWidthChanging] = false; this.newWidthForColumnWidthChangingCancelled = -1; this.listViewState1[LISTVIEWSTATE1_cancelledColumnWidthChanging] = false; NativeMethods.NMHEADER nmheader = (NativeMethods.NMHEADER) m.GetLParam(typeof(NativeMethods.NMHEADER)); if (this.columnHeaders != null && this.columnHeaders.Length > nmheader.iItem) { this.columnHeaderClicked = this.columnHeaders[nmheader.iItem]; this.columnHeaderClickedWidth = this.columnHeaderClicked.Width; } else { this.columnHeaderClickedWidth = -1; this.columnHeaderClicked = null; } } if (nmhdr->code == NativeMethods.HDN_ITEMCHANGINGA || nmhdr->code == NativeMethods.HDN_ITEMCHANGINGW) { NativeMethods.NMHEADER nmheader = (NativeMethods.NMHEADER) m.GetLParam(typeof(NativeMethods.NMHEADER)); if (columnHeaders != null && nmheader.iItem < columnHeaders.Length && (this.listViewState[LISTVIEWSTATE_headerControlTracking] || this.listViewState[LISTVIEWSTATE_headerDividerDblClick])) { // SECREVIEW: // UnsafeNativeMethods.PtrToStructure asserts ReflectionPermission. // We are fine asserting this permission because the HDITEM2 type is our type and we have control over it // and over what it does in its constructor. NativeMethods.HDITEM2 hdItem = (NativeMethods.HDITEM2) UnsafeNativeMethods.PtrToStructure((IntPtr) nmheader.pItem, typeof(NativeMethods.HDITEM2)); int newColumnWidth = ((hdItem.mask & NativeMethods.HDI_WIDTH) != 0) ? hdItem.cxy : -1; ColumnWidthChangingEventArgs colWidthChanging = new ColumnWidthChangingEventArgs(nmheader.iItem, newColumnWidth); OnColumnWidthChanging(colWidthChanging); m.Result = (IntPtr) (colWidthChanging.Cancel ? 1 : 0); if (colWidthChanging.Cancel) { hdItem.cxy = colWidthChanging.NewWidth; // We are called inside HDN_DIVIDERDBLCLICK. // Turn off the compensation that our processing of HDN_DIVIDERDBLCLICK would otherwise add. if (this.listViewState[LISTVIEWSTATE_headerDividerDblClick]) { this.listViewState[LISTVIEWSTATE_columnResizeCancelled] = true; } this.listViewState1[LISTVIEWSTATE1_cancelledColumnWidthChanging] = true; this.newWidthForColumnWidthChangingCancelled = colWidthChanging.NewWidth; // skip default processing return true; } else { return false; } } } if ((nmhdr->code == NativeMethods.HDN_ITEMCHANGEDA || nmhdr->code == NativeMethods.HDN_ITEMCHANGEDW) && !this.listViewState[LISTVIEWSTATE_headerControlTracking]) { NativeMethods.NMHEADER nmheader = (NativeMethods.NMHEADER)m.GetLParam(typeof(NativeMethods.NMHEADER)); if (columnHeaders != null && nmheader.iItem < columnHeaders.Length) { int w = columnHeaders[nmheader.iItem].Width; if (this.columnHeaderClicked == null || (this.columnHeaderClicked == this.columnHeaders[nmheader.iItem] && this.columnHeaderClickedWidth != -1 && this.columnHeaderClickedWidth != w)) { // // If the user double clicked on the column header and we still need to compensate for the column resize // then don't fire ColumnWidthChanged because at this point the column header does not have the final width. // if (this.listViewState[LISTVIEWSTATE_headerDividerDblClick]) { if (this.CompensateColumnHeaderResize(m, this.listViewState[LISTVIEWSTATE_columnResizeCancelled]) == 0) { OnColumnWidthChanged(new ColumnWidthChangedEventArgs(nmheader.iItem)); } } else { OnColumnWidthChanged(new ColumnWidthChangedEventArgs(nmheader.iItem)); } } } this.columnHeaderClicked = null; this.columnHeaderClickedWidth = -1; ISite site = Site; // [....], this seems like a really wierd place to annouce this change... if (site != null) { IComponentChangeService cs = (IComponentChangeService)site.GetService(typeof(IComponentChangeService)); if (cs != null) { try { cs.OnComponentChanging(this, null); } catch (CheckoutException coEx) { if (coEx == CheckoutException.Canceled) { return false; } throw coEx; } } } } if (nmhdr->code == NativeMethods.HDN_ENDTRACKA || nmhdr->code == NativeMethods.HDN_ENDTRACKW) { Debug.Assert(this.listViewState[LISTVIEWSTATE_headerControlTracking], "HDN_ENDTRACK and HDN_BEGINTRACK are out of [....]..."); this.listViewState[LISTVIEWSTATE_headerControlTracking] = false; if (this.listViewState1[LISTVIEWSTATE1_cancelledColumnWidthChanging]) { m.Result = (IntPtr) 1; if (this.newWidthForColumnWidthChangingCancelled != -1) { NativeMethods.NMHEADER nmheader = (NativeMethods.NMHEADER)m.GetLParam(typeof(NativeMethods.NMHEADER)); if (this.columnHeaders != null && this.columnHeaders.Length > nmheader.iItem) { this.columnHeaders[nmheader.iItem].Width = this.newWidthForColumnWidthChangingCancelled; } } this.listViewState1[LISTVIEWSTATE1_cancelledColumnWidthChanging] = false; this.newWidthForColumnWidthChangingCancelled = -1; // skip default processing return true; } else { return false; } } if (nmhdr->code == NativeMethods.HDN_ENDDRAG) { NativeMethods.NMHEADER header = (NativeMethods.NMHEADER) m.GetLParam(typeof(NativeMethods.NMHEADER)); if (header.pItem != IntPtr.Zero) { // SECREVIEW: // UnsafeNativeMethods.PtrToStructure asserts ReflectionPermission. // We are fine asserting this permission because the HDITEM type is our type and we have control over it // and over what it does in its constructor. NativeMethods.HDITEM2 hdItem = (NativeMethods.HDITEM2) UnsafeNativeMethods.PtrToStructure((IntPtr) header.pItem, typeof(NativeMethods.HDITEM2)); if ((hdItem.mask & NativeMethods.HDI_ORDER) == NativeMethods.HDI_ORDER) { int from = this.Columns[header.iItem].DisplayIndex; int to = hdItem.iOrder; // check this if (from == to) { return false; } // sometimes ComCtl gives us bogus values for HDIItem.iOrder. // vsw 541880. if (to < 0) { return false; } ColumnReorderedEventArgs chrevent = new ColumnReorderedEventArgs(from, to, this.Columns[header.iItem]); OnColumnReordered(chrevent); if (chrevent.Cancel) { m.Result = new IntPtr(1); return true; } else { // set the display indices. This is not an expensive operation because // we only set an integer in the column header class int lowDI = Math.Min(from, to); int hiDI = Math.Max(from, to); bool hdrMovedForward = to > from; ColumnHeader movedHdr = null; int[] indices = new int[this.Columns.Count]; for (int i = 0; i < this.Columns.Count; i ++) { ColumnHeader hdr = this.Columns[i]; if (hdr.DisplayIndex == from) { movedHdr = hdr; } else if (hdr.DisplayIndex >= lowDI && hdr.DisplayIndex <= hiDI) { hdr.DisplayIndexInternal -= hdrMovedForward ? 1 : -1; } indices[i] = hdr.DisplayIndexInternal; } movedHdr.DisplayIndexInternal = to; indices[movedHdr.Index] = movedHdr.DisplayIndexInternal; SetDisplayIndices( indices ); #if DEBUG CheckDisplayIndices(); #endif } } } } if (nmhdr->code == NativeMethods.HDN_DIVIDERDBLCLICKA || nmhdr->code == NativeMethods.HDN_DIVIDERDBLCLICKW) { // We need to keep track that the user double clicked the column header divider // so we know that the column header width is changing. this.listViewState[LISTVIEWSTATE_headerDividerDblClick] = true; // Reset ColumnResizeCancelled. // It will be set if the user cancels the ColumnWidthChanging event. this.listViewState[LISTVIEWSTATE_columnResizeCancelled] = false; bool columnResizeCancelled = false; // ComCtl32 does not add enough padding when resizing the first column via mouse double click. // See vsw 336709 for a complete explanation including listing of the comctl32 code. // Our wrapper will add 2 pixels. (1 pixel is not enough, 3 pixels is too much) // Send the message to ComCtl32 so that it resizes the column. try { DefWndProc(ref m); } finally { this.listViewState[LISTVIEWSTATE_headerDividerDblClick] = false; columnResizeCancelled = this.listViewState[LISTVIEWSTATE_columnResizeCancelled]; this.listViewState[LISTVIEWSTATE_columnResizeCancelled] = false; } this.columnHeaderClicked = null; this.columnHeaderClickedWidth = -1; if (columnResizeCancelled) { // If the column resize was cancelled then apply the NewWidth supplied by the user. if (this.newWidthForColumnWidthChangingCancelled != -1) { NativeMethods.NMHEADER nmheader = (NativeMethods.NMHEADER) m.GetLParam(typeof(NativeMethods.NMHEADER)); if (this.columnHeaders != null && this.columnHeaders.Length > nmheader.iItem) { this.columnHeaders[nmheader.iItem].Width = this.newWidthForColumnWidthChangingCancelled; } } // Tell ComCtl that the HDN_DIVIDERDBLCLICK was cancelled. m.Result = (IntPtr) 1; } else { // Compensate for the column resize. int compensateForColumnResize = this.CompensateColumnHeaderResize(m, columnResizeCancelled); if (compensateForColumnResize != 0) { #if DEBUG NativeMethods.NMHEADER header = (NativeMethods.NMHEADER) m.GetLParam(typeof(NativeMethods.NMHEADER)); Debug.Assert(header.iItem == 0, "we only need to compensate for the first column resize"); Debug.Assert(this.columnHeaders.Length > 0, "there should be a column that we need to compensate for"); #endif ColumnHeader col = this.columnHeaders[0]; col.Width += compensateForColumnResize; } } // We called DefWndProc so we don't need default handling. return true; } return false; // still need default handling }
public void TestColumnReorderedEventArgs () { int oldindex = 7; int newindex = 26; ColumnHeader ch = new ColumnHeader (); ch.Text = "TestHeader"; ColumnReorderedEventArgs e = new ColumnReorderedEventArgs (oldindex, newindex, ch); Assert.AreEqual (oldindex, e.OldDisplayIndex, "A1"); Assert.AreEqual (newindex, e.NewDisplayIndex, "A2"); Assert.AreEqual (ch, e.Header, "A3"); Assert.AreEqual (false, e.Cancel, "A4"); }
void SortableListView_ColumnReordered(object sender, ColumnReorderedEventArgs e) { if (e.OldDisplayIndex == this._sortColumn) { this._sortColumn = e.NewDisplayIndex; this.ListViewItemSorter = new ListViewItemComparer(this._sortColumn, this._sortOrder); } }
private unsafe bool WmNotify(ref Message m) { System.Windows.Forms.NativeMethods.NMHDR* lParam = (System.Windows.Forms.NativeMethods.NMHDR*) m.LParam; if ((lParam->code == -12) && this.OwnerDraw) { try { System.Windows.Forms.NativeMethods.NMCUSTOMDRAW* nmcustomdrawPtr = (System.Windows.Forms.NativeMethods.NMCUSTOMDRAW*) m.LParam; switch (nmcustomdrawPtr->dwDrawStage) { case 1: m.Result = (IntPtr) 0x20; return true; case 0x10001: { Graphics graphics = Graphics.FromHdcInternal(nmcustomdrawPtr->hdc); Rectangle bounds = Rectangle.FromLTRB(nmcustomdrawPtr->rc.left, nmcustomdrawPtr->rc.top, nmcustomdrawPtr->rc.right, nmcustomdrawPtr->rc.bottom); DrawListViewColumnHeaderEventArgs e = null; try { Color foreColor = ColorTranslator.FromWin32(System.Windows.Forms.SafeNativeMethods.GetTextColor(new HandleRef(this, nmcustomdrawPtr->hdc))); Color backColor = ColorTranslator.FromWin32(System.Windows.Forms.SafeNativeMethods.GetBkColor(new HandleRef(this, nmcustomdrawPtr->hdc))); Font listHeaderFont = this.GetListHeaderFont(); e = new DrawListViewColumnHeaderEventArgs(graphics, bounds, (int) nmcustomdrawPtr->dwItemSpec, this.columnHeaders[(int) nmcustomdrawPtr->dwItemSpec], (ListViewItemStates) nmcustomdrawPtr->uItemState, foreColor, backColor, listHeaderFont); this.OnDrawColumnHeader(e); } finally { graphics.Dispose(); } if (e.DrawDefault) { m.Result = IntPtr.Zero; return false; } m.Result = (IntPtr) 4; return true; } } return false; } catch (Exception) { m.Result = IntPtr.Zero; } } if ((lParam->code == -16) && this.listViewState[0x20000]) { this.listViewState[0x20000] = false; this.OnColumnClick(new ColumnClickEventArgs(this.columnIndex)); } if ((lParam->code == -306) || (lParam->code == -326)) { this.listViewState[0x4000000] = true; this.listViewState1[2] = false; this.newWidthForColumnWidthChangingCancelled = -1; this.listViewState1[2] = false; System.Windows.Forms.NativeMethods.NMHEADER nmheader = (System.Windows.Forms.NativeMethods.NMHEADER) m.GetLParam(typeof(System.Windows.Forms.NativeMethods.NMHEADER)); if ((this.columnHeaders != null) && (this.columnHeaders.Length > nmheader.iItem)) { this.columnHeaderClicked = this.columnHeaders[nmheader.iItem]; this.columnHeaderClickedWidth = this.columnHeaderClicked.Width; } else { this.columnHeaderClickedWidth = -1; this.columnHeaderClicked = null; } } if ((lParam->code == -300) || (lParam->code == -320)) { System.Windows.Forms.NativeMethods.NMHEADER nmheader2 = (System.Windows.Forms.NativeMethods.NMHEADER) m.GetLParam(typeof(System.Windows.Forms.NativeMethods.NMHEADER)); if (((this.columnHeaders != null) && (nmheader2.iItem < this.columnHeaders.Length)) && (this.listViewState[0x4000000] || this.listViewState[0x20000000])) { System.Windows.Forms.NativeMethods.HDITEM2 hditem = (System.Windows.Forms.NativeMethods.HDITEM2) System.Windows.Forms.UnsafeNativeMethods.PtrToStructure(nmheader2.pItem, typeof(System.Windows.Forms.NativeMethods.HDITEM2)); int newWidth = ((hditem.mask & 1) != 0) ? hditem.cxy : -1; ColumnWidthChangingEventArgs args2 = new ColumnWidthChangingEventArgs(nmheader2.iItem, newWidth); this.OnColumnWidthChanging(args2); m.Result = args2.Cancel ? ((IntPtr) 1) : IntPtr.Zero; if (!args2.Cancel) { return false; } hditem.cxy = args2.NewWidth; if (this.listViewState[0x20000000]) { this.listViewState[0x40000000] = true; } this.listViewState1[2] = true; this.newWidthForColumnWidthChangingCancelled = args2.NewWidth; return true; } } if (((lParam->code == -301) || (lParam->code == -321)) && !this.listViewState[0x4000000]) { System.Windows.Forms.NativeMethods.NMHEADER nmheader3 = (System.Windows.Forms.NativeMethods.NMHEADER) m.GetLParam(typeof(System.Windows.Forms.NativeMethods.NMHEADER)); if ((this.columnHeaders != null) && (nmheader3.iItem < this.columnHeaders.Length)) { int width = this.columnHeaders[nmheader3.iItem].Width; if ((this.columnHeaderClicked == null) || (((this.columnHeaderClicked == this.columnHeaders[nmheader3.iItem]) && (this.columnHeaderClickedWidth != -1)) && (this.columnHeaderClickedWidth != width))) { if (this.listViewState[0x20000000]) { if (this.CompensateColumnHeaderResize(m, this.listViewState[0x40000000]) == 0) { this.OnColumnWidthChanged(new ColumnWidthChangedEventArgs(nmheader3.iItem)); } } else { this.OnColumnWidthChanged(new ColumnWidthChangedEventArgs(nmheader3.iItem)); } } } this.columnHeaderClicked = null; this.columnHeaderClickedWidth = -1; ISite site = this.Site; if (site != null) { IComponentChangeService service = (IComponentChangeService) site.GetService(typeof(IComponentChangeService)); if (service != null) { try { service.OnComponentChanging(this, null); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw exception; } return false; } } } } if ((lParam->code == -307) || (lParam->code == -327)) { this.listViewState[0x4000000] = false; if (!this.listViewState1[2]) { return false; } m.Result = (IntPtr) 1; if (this.newWidthForColumnWidthChangingCancelled != -1) { System.Windows.Forms.NativeMethods.NMHEADER nmheader4 = (System.Windows.Forms.NativeMethods.NMHEADER) m.GetLParam(typeof(System.Windows.Forms.NativeMethods.NMHEADER)); if ((this.columnHeaders != null) && (this.columnHeaders.Length > nmheader4.iItem)) { this.columnHeaders[nmheader4.iItem].Width = this.newWidthForColumnWidthChangingCancelled; } } this.listViewState1[2] = false; this.newWidthForColumnWidthChangingCancelled = -1; return true; } if (lParam->code == -311) { System.Windows.Forms.NativeMethods.NMHEADER nmheader5 = (System.Windows.Forms.NativeMethods.NMHEADER) m.GetLParam(typeof(System.Windows.Forms.NativeMethods.NMHEADER)); if (nmheader5.pItem != IntPtr.Zero) { System.Windows.Forms.NativeMethods.HDITEM2 hditem2 = (System.Windows.Forms.NativeMethods.HDITEM2) System.Windows.Forms.UnsafeNativeMethods.PtrToStructure(nmheader5.pItem, typeof(System.Windows.Forms.NativeMethods.HDITEM2)); if ((hditem2.mask & 0x80) == 0x80) { int displayIndex = this.Columns[nmheader5.iItem].DisplayIndex; int iOrder = hditem2.iOrder; if (displayIndex == iOrder) { return false; } if (iOrder < 0) { return false; } ColumnReorderedEventArgs args3 = new ColumnReorderedEventArgs(displayIndex, iOrder, this.Columns[nmheader5.iItem]); this.OnColumnReordered(args3); if (args3.Cancel) { m.Result = new IntPtr(1); return true; } int num5 = Math.Min(displayIndex, iOrder); int num6 = Math.Max(displayIndex, iOrder); bool flag = iOrder > displayIndex; ColumnHeader header = null; int[] indices = new int[this.Columns.Count]; for (int i = 0; i < this.Columns.Count; i++) { ColumnHeader header2 = this.Columns[i]; if (header2.DisplayIndex == displayIndex) { header = header2; } else if ((header2.DisplayIndex >= num5) && (header2.DisplayIndex <= num6)) { header2.DisplayIndexInternal -= flag ? 1 : -1; } indices[i] = header2.DisplayIndexInternal; } header.DisplayIndexInternal = iOrder; indices[header.Index] = header.DisplayIndexInternal; this.SetDisplayIndices(indices); } } } if ((lParam->code != -305) && (lParam->code != -325)) { return false; } this.listViewState[0x20000000] = true; this.listViewState[0x40000000] = false; bool columnResizeCancelled = false; try { this.DefWndProc(ref m); } finally { this.listViewState[0x20000000] = false; columnResizeCancelled = this.listViewState[0x40000000]; this.listViewState[0x40000000] = false; } this.columnHeaderClicked = null; this.columnHeaderClickedWidth = -1; if (columnResizeCancelled) { if (this.newWidthForColumnWidthChangingCancelled != -1) { System.Windows.Forms.NativeMethods.NMHEADER nmheader6 = (System.Windows.Forms.NativeMethods.NMHEADER) m.GetLParam(typeof(System.Windows.Forms.NativeMethods.NMHEADER)); if ((this.columnHeaders != null) && (this.columnHeaders.Length > nmheader6.iItem)) { this.columnHeaders[nmheader6.iItem].Width = this.newWidthForColumnWidthChangingCancelled; } } m.Result = (IntPtr) 1; } else { int num8 = this.CompensateColumnHeaderResize(m, columnResizeCancelled); if (num8 != 0) { ColumnHeader header3 = this.columnHeaders[0]; header3.Width += num8; } } return true; }
protected virtual void OnColumnReordered (ColumnReorderedEventArgs e) { ColumnReorderedEventHandler creh = (ColumnReorderedEventHandler) (Events [ColumnReorderedEvent]); if (creh != null) creh (this, e); }
private void GridColumnReordered(object sender, ColumnReorderedEventArgs e) { Config.Instance.FavoritesColumnOrder = _grid.ColumnsOrder; }
/// <summary> /// Override the OnColumnReordered method to do what we want /// </summary> /// <param name="e"></param> protected override void OnColumnReordered(ColumnReorderedEventArgs e) { base.OnColumnReordered(e); // The internal logic of the .NET code behind a ENDDRAG event means that, // at this point, the DisplayIndex's of the columns are not yet as they are // going to be. So we have to invoke a method to run later that will remember // what the real DisplayIndex's are. this.BeginInvoke(new MethodInvoker(this.RememberDisplayIndicies)); }
private void objectListView1_ColumnReordered(object sender, ColumnReorderedEventArgs e) { SaveStateToSettings(); }