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 = HeaderItemFlags.HDI_TEXT; hdi.cchTextMax = BUFFER_SIZE; hdi.pszText = Marshal.AllocHGlobal(BUFFER_SIZE); WindowsAPI.SendMessage(hHeader, HeaderControlMessages.HDM_GETITEMW, index, ref hdi); string text = Marshal.PtrToStringAuto(hdi.pszText); return text; }
public static extern void SendMessage(IntPtr hWnd, HeaderControlMessages msg, int wParam, ref HDITEM lParam);