void InsertColumns() { int counter = 0; foreach (ListColumn m in myColumns) { Win32.LVCOLUMN lvc = new Win32.LVCOLUMN(); lvc.mask = 0x0001 | 0x0008 | 0x0002 | 0x0004; //LVCF_FMT|LVCF_SUBITEM|LVCF_WIDTH|LVCF_TEXT lvc.cx = m.Width; lvc.subItem = counter; lvc.text = m.Text; switch (m.TextAlign) { case HorizontalAlignment.Left: lvc.fmt = 0x0000; break; case HorizontalAlignment.Center: lvc.fmt = 0x0002; break; case HorizontalAlignment.Right: lvc.fmt = 0x0001; break; } if (headerImages != null && m.ImageIndex != -1) { lvc.mask |= 0x0010; //LVCF_IMAGE lvc.iImage = m.ImageIndex; lvc.fmt |= 0x0800; //LVCFMT_IMAGE if (m.ImageOnRight) { lvc.fmt |= 0x1000; } } //Send message LVN_INSERTCOLUMN Win32.SendMessage(this.Handle, 0x1000 + 97, counter, ref lvc); //Check if column is set to owner-draw //If so - send message HDM_SETITEM with HDF_OWNERDRAW flag set if (m.OwnerDraw) { Win32.HDITEM hdi = new Win32.HDITEM(); hdi.mask = (int)Win32.HDI.HDI_FORMAT; hdi.fmt = (int)Win32.HDF.HDF_OWNERDRAW; Win32.SendMessage(header.Handle, 0x1200 + 12, counter, ref hdi); } counter++; } }
void InsertColumns() { int counter = 0; foreach(ListColumn m in myColumns) { Win32.LVCOLUMN lvc = new Win32.LVCOLUMN(); lvc.mask = 0x0001|0x0008|0x0002|0x0004;//LVCF_FMT|LVCF_SUBITEM|LVCF_WIDTH|LVCF_TEXT lvc.cx = m.Width; lvc.subItem = counter; lvc.text = m.Text; switch(m.TextAlign) { case HorizontalAlignment.Left: lvc.fmt = 0x0000; break; case HorizontalAlignment.Center: lvc.fmt = 0x0002; break; case HorizontalAlignment.Right: lvc.fmt = 0x0001; break; } if(headerImages != null && m.ImageIndex != -1) { lvc.mask |= 0x0010;//LVCF_IMAGE lvc.iImage = m.ImageIndex; lvc.fmt |= 0x0800;//LVCFMT_IMAGE if(m.ImageOnRight) lvc.fmt |= 0x1000; } //Send message LVN_INSERTCOLUMN Win32.SendMessage(this.Handle,0x1000+97,counter,ref lvc); //Check if column is set to owner-draw //If so - send message HDM_SETITEM with HDF_OWNERDRAW flag set if(m.OwnerDraw) { Win32.HDITEM hdi = new Win32.HDITEM(); hdi.mask = (int)Win32.HDI.HDI_FORMAT; hdi.fmt = (int)Win32.HDF.HDF_OWNERDRAW; Win32.SendMessage(header.Handle,0x1200+12,counter,ref hdi); } counter++; } }