2
ListView
헤더 색상을 어떻게 변경합니까? 코드 작성 방법을 알고 있다면 코드 예제를 제공하십시오.목록보기 헤더의 색을 변경 하시겠습니까?
private System.Windows.Forms.ListView lvFiles;
ListView
헤더 색상을 어떻게 변경합니까? 코드 작성 방법을 알고 있다면 코드 예제를 제공하십시오.목록보기 헤더의 색을 변경 하시겠습니까?
private System.Windows.Forms.ListView lvFiles;
여기는 좋은 질문이 아닙니다.
ListView lvFiles= new ListView();
public Form1()
{
InitializeComponent();
lvFiles.View = View.Details;
lvFiles.OwnerDraw = true;
lvFiles.Size = new Size(200, 100);
lvFiles.DrawColumnHeader += new DrawListViewColumnHeaderEventHandler(lv_DrawColumn Header);
lvFiles.DrawSubItem += new DrawListViewSubItemEventHandler(lv_DrawSubItem);
lv.Columns.Add("Col1");
lv.Columns.Add("Col1");
lv.Columns.Add("Col1");
this.Controls.Add(lv);
lv.Items.Add(new ListViewItem(new string[] { "One", "Two","Three" }));
lv.Items.Add(new ListViewItem(new string[] { "One", "Two","Three" }));
lv.Items.Add(new ListViewItem(new string[] { "One", "Two","Three" }));
}
void lv_DrawSubItem(object sender, DrawListViewSubItemEventArgse)
{
if ((e.ItemState & ListViewItemStates.Focused) 0)
{
e.Graphics.FillRectangle(SystemBrushes.Highlight,e.Bounds);
e.Graphics.DrawString(e.Item.Text, lv.Font,SystemBrushes.HighlightText, e.Bounds);
}
else
{
e.DrawBackground();
e.DrawText();
}
}
void lv_DrawColumnHeader(object sender,DrawListViewColumnHeaderEventArgs e)
{
e.Graphics.FillRectangle(Brushes.GreenYellow, e.Bounds);
e.DrawText();
}
이 도움이 될 수 있습니다 : http://stackoverflow.com/questions/8818224/how-to-change-listview-headers-forecolor-c-sharp-windows-form-application –