protected string GetHeaderItemText( int index ) { // I get the bug that I get on the ListView if // I use the columns collection to retreive the text // That's why I prefer to use the Windows API HDITEM hdi = new HDITEM(); hdi.mask = ( int )HeaderItemFlags.HDI_TEXT; hdi.cchTextMax = BUFFER_SIZE; hdi.pszText = Marshal.AllocHGlobal( BUFFER_SIZE ); WindowsAPI.SendMessage( hHeader, ( int )HeaderControlMessages.HDM_GETITEMW, index, ref hdi ); string text = Marshal.PtrToStringAuto( hdi.pszText ); return text; }
public static extern void SendMessage(IntPtr hWnd, int msg, int wParam, ref HDITEM lParam);
public static extern void SendMessage(IntPtr hWnd, int msg, int wParam, ref HDITEM lParam);