コード例 #1
0
ファイル: MultiColumnListBox.cs プロジェクト: truonghinh/TnX
 //Protected Methods
 protected virtual void defaultDraw(object value, DrawSubItemEventArgs e)
 {
     e.Graphics.DrawString(value.ToString(),e.Font,new SolidBrush(e.ForeColor),e.Bounds);
 }
コード例 #2
0
ファイル: MultiColumnListBox.cs プロジェクト: truonghinh/TnX
 protected virtual void OnDrawSubItem(DrawSubItemEventArgs e)
 {
     object value = this.GetItemAt(e.Index,e.SubIndex);
     if(DrawMode == DrawMode.Normal && Items.Count > 0)
     {
         if((value as Image) != null)
             e.Graphics.DrawImageUnscaled((Image)value,e.Bounds);
         else if((value as Bitmap) != null)
         {
             IntPtr hBmp = ((Bitmap)value).GetHbitmap();
             e.Graphics.DrawImageUnscaled(Image.FromHbitmap(hBmp),e.Bounds);
             WinAPI.DeleteObject(hBmp);
         }
         else if((value as byte[]) != null)
         {
             try
             {
                 e.Graphics.DrawImageUnscaled(Image.FromStream(new MemoryStream((byte[])value)),e.Bounds);
             }
             catch(Exception ex)
             {
                 defaultDraw(value,e);
             }
         }
         else
             defaultDraw(value,e);
     }
     else if(DrawSubItem.GetInvocationList() != null)
         DrawSubItem.DynamicInvoke(new object[]{this,e});
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: truonghinh/TnX
        private void drawLBSubItem(object sender,DrawSubItemEventArgs e)
        {
            if(e.SubIndex == ((MultiColumnListBox)sender).TextIndex && (e.State & DrawItemState.Selected) != DrawItemState.Selected)
                e.Graphics.FillRectangle(new SolidBrush(SystemColors.ControlLight),e.Bounds);

            e.Graphics.DrawString(((MultiColumnListBox)sender).GetItemAt(e.Index,e.SubIndex).ToString(),e.Font,new SolidBrush(e.ForeColor),e.Bounds.Left,e.Bounds.Top+2);
        }