Click here to Skip to main content
15,889,721 members
Home / Discussions / C#
   

C#

 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
Saksida Bojan26-Feb-10 7:00
Saksida Bojan26-Feb-10 7:00 
GeneralRe: Drawing onto a Windows Form without freezing it Pin
Luc Pattyn26-Feb-10 6:46
sitebuilderLuc Pattyn26-Feb-10 6:46 
QuestionQuad Tree With images Pin
mallikharjunrao8426-Feb-10 3:17
mallikharjunrao8426-Feb-10 3:17 
AnswerRe: Quad Tree With images PinPopular
RugbyLeague26-Feb-10 3:29
RugbyLeague26-Feb-10 3:29 
GeneralRe: Quad Tree With images Pin
Pete O'Hanlon26-Feb-10 5:15
mvePete O'Hanlon26-Feb-10 5:15 
GeneralRe: Quad Tree With images Pin
Keith Barrow26-Feb-10 5:27
professionalKeith Barrow26-Feb-10 5:27 
QuestionListView Column Sort Arrow Pin
#realJSOP26-Feb-10 3:17
mve#realJSOP26-Feb-10 3:17 
AnswerTry this Pin
Pete O'Hanlon26-Feb-10 5:39
mvePete O'Hanlon26-Feb-10 5:39 
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

namespace JSOPTest
{
  [EditorBrowsable(EditorBrowsableState.Never)]
  public static class ExListView
  {
    [StructLayout(LayoutKind.Sequential)]
    private struct LVCOLUMN
    {
      public Int32 mask;
      public Int32 cx;
      [MarshalAs(UnmanagedType.LPTStr)]
      public string pszText;
      public IntPtr hbm;
      public Int32 cchTextMax;
      public Int32 fmt;
      public Int32 iSubItem;
      public Int32 iImage;
      public Int32 iOrder;
    }

    private const Int32 HDI_FORMAT = 0x4;
    private const Int32 HDF_SORTUP = 0x400;
    private const Int32 HDF_SORTDOWN = 0x200;
    private const Int32 LVM_GETHEADER = 0x101f;
    private const Int32 HDM_GETITEM = 0x120b;
    private const Int32 HDM_SETITEM = 0x120c;

    [DllImport("user32.dll")]
    private static extern IntPtr SendMessage(
        IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

    [DllImport("user32.dll", EntryPoint = "SendMessage")]
    private static extern IntPtr SendMessageLVCOLUMN(IntPtr hWnd, 
        Int32 Msg, 
        IntPtr wParam, 
        ref LVCOLUMN lPLVCOLUMN);

    public static void SetSortIcon(ListView ListViewControl, 
        int ColumnIndex, 
        SortOrder Order)
    {
      IntPtr ColumnHeader = SendMessage(ListViewControl.Handle, 
          LVM_GETHEADER, 
          IntPtr.Zero, IntPtr.Zero);

      for (int ColumnNumber = 0; 
          ColumnNumber <= ListViewControl.Columns.Count - 1; 
          ColumnNumber++)
      {
        IntPtr ColumnPtr = new IntPtr(ColumnNumber);
        LVCOLUMN lvColumn = new LVCOLUMN();
        lvColumn.mask = HDI_FORMAT;
        SendMessageLVCOLUMN(ColumnHeader, HDM_GETITEM, ColumnPtr, ref lvColumn);

        if (!(Order ==   SortOrder.None) && ColumnNumber == ColumnIndex)
        {
          switch (Order)
          {
            case   SortOrder.Ascending:
              lvColumn.fmt &= ~HDF_SORTDOWN;
              lvColumn.fmt |= HDF_SORTUP;
              break;
            case   SortOrder.Descending:
              lvColumn.fmt &= ~HDF_SORTUP;
              lvColumn.fmt |= HDF_SORTDOWN;
              break;
          }
        }
        else
        {
          lvColumn.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP;
        }

        SendMessageLVCOLUMN(ColumnHeader, HDM_SETITEM, ColumnPtr, ref lvColumn);
      }
    }
  }

}

"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys | Onyx



GeneralRe: Try this Pin
#realJSOP26-Feb-10 9:02
mve#realJSOP26-Feb-10 9:02 
GeneralRe: Try this Pin
Pete O'Hanlon26-Feb-10 9:46
mvePete O'Hanlon26-Feb-10 9:46 
GeneralRe: Try this Pin
#realJSOP27-Feb-10 0:55
mve#realJSOP27-Feb-10 0:55 
GeneralRe: Try this Pin
#realJSOP27-Feb-10 3:58
mve#realJSOP27-Feb-10 3:58 
GeneralRe: Try this Pin
Pete O'Hanlon1-Mar-10 1:12
mvePete O'Hanlon1-Mar-10 1:12 
GeneralRe: Try this Pin
Pete O'Hanlon1-Mar-10 9:34
mvePete O'Hanlon1-Mar-10 9:34 
AnswerRe: ListView Column Sort Arrow Pin
-tusk-22-Jun-11 6:10
-tusk-22-Jun-11 6:10 
GeneralRe: ListView Column Sort Arrow Pin
-tusk-24-Jun-11 2:57
-tusk-24-Jun-11 2:57 
Question2d array in c# Pin
Aljaz11126-Feb-10 3:05
Aljaz11126-Feb-10 3:05 
AnswerRe: 2d array in c# Pin
Pete O'Hanlon26-Feb-10 3:17
mvePete O'Hanlon26-Feb-10 3:17 
GeneralRe: 2d array in c# Pin
Aljaz11126-Feb-10 3:20
Aljaz11126-Feb-10 3:20 
GeneralRe: 2d array in c# [modified] Pin
Dan Mos26-Feb-10 3:26
Dan Mos26-Feb-10 3:26 
GeneralRe: 2d array in c# Pin
harold aptroot26-Feb-10 4:24
harold aptroot26-Feb-10 4:24 
GeneralRe: 2d array in c# Pin
Aljaz11126-Feb-10 6:39
Aljaz11126-Feb-10 6:39 
GeneralRe: 2d array in c# Pin
harold aptroot26-Feb-10 6:46
harold aptroot26-Feb-10 6:46 
GeneralRe: 2d array in c# Pin
Aljaz11126-Feb-10 7:47
Aljaz11126-Feb-10 7:47 
GeneralRe: 2d array in c# Pin
harold aptroot26-Feb-10 8:05
harold aptroot26-Feb-10 8:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.