Default implementation for ListView OwnerDraw

后端 未结 5 1101
萌比男神i
萌比男神i 2020-12-10 04:18

I have a ListView where I wish to tweak the drawing of items (for example highlighting certain strings in list view itmes), however I don\'t want to radically alter the way

5条回答
  •  天涯浪人
    2020-12-10 05:00

      private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
      {
          e.DrawBackground(); 
          if (e.Item.Selected) 
          {
              e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(250, 194, 87)), e.Bounds); 
          } 
          e.Graphics.DrawString(e.Item.Text, new Font("Arial", 10), new SolidBrush(Color.Black), e.Bounds); 
    
      }
    

提交回复
热议问题