string GetSubItemText( int row, int col ) { // I am going to use the Windows API since using the .NET // ListViewSubItem.Text property is causing the nasty side // effect of changing the text when I draw the string using TextUtil.DrawText, // even though that is not my intention at all. // I am not sure about why this is happening but using the API solves the problem LVITEM lvi = new LVITEM(); lvi.iItem = row; lvi.mask = ( int )ListViewItemFlags.LVIF_TEXT; lvi.iSubItem = col; lvi.cchTextMax = BUFFER_SIZE; lvi.pszText = Marshal.AllocHGlobal( BUFFER_SIZE ); WindowsAPI.SendMessage( Handle, ( int )ListViewMessages.LVM_GETITEMTEXTW, row, ref lvi ); string text = Marshal.PtrToStringAuto( lvi.pszText ); return text; }
public static extern void SendMessage(IntPtr hWnd, int msg, int wParam, ref LVITEM lParam);