CodePanic! > C#.NET Tips > 今ここ
■ノードの背景色を設定する
NodeのBackColorプロパティーに色を指定します。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// わかりやすいように幅全体を選択状態にします(任意)
treeView1.FullRowSelect = true;
treeView1.ShowLines = false;
// 適当に10個のNodeを登録し、それぞれの背景色を設定
for (int i = 0; i < 10; i++)
{
TreeNode node = treeView1.Nodes.Add(i.ToString());
node.BackColor = Color.Pink;
}
}
}
}
Copyright © 2008.07 - shougo suzaki
|