NodeViewオブジェクトを使用して、次のようにユーザーにデータを出力します(Gtk#チュートリアル):
[Gtk.TreeNode (ListOnly=true)]
public class MyTreeNode : Gtk.TreeNode {
string song_title;
public MyTreeNode (string artist, string song_title)
{
Artist = artist;
this.song_title = song_title;
}
[Gtk.TreeNodeValue (Column=0)]
public string Artist;
[Gtk.TreeNodeValue (Column=1)]
public string SongTitle {get { return song_title; } }
}
Gtk.NodeStore store;
Gtk.NodeStore Store
{
get {
if (store == null)
{
store = new Gtk.NodeStore (typeof(MyTreeNode));
store.AddNode (new MyTreeNode ("The Beatles", "Yesterday"));
store.AddNode (new MyTreeNode ("Peter Gabriel", "In Your Eyes"));
store.AddNode (new MyTreeNode ("Rush", "Fly By Night"));
}
return store;
}
}
protected void OnButton1Clicked (object sender, EventArgs e)
{
// Create a column with title Artist and bind its renderer to model column 0
nodeview1.AppendColumn ("Artist", new Gtk.CellRendererText (), "text", 0);
// Create a column with title 'Song Title' and bind its renderer to model column 1
nodeview1.AppendColumn ("Song Title", new Gtk.CellRendererText (), "text", 1);
nodeview1.ShowAll ();
nodeview1.NodeStore=Store;
}
しかし、NodeViewの一部の行(「ビートルズ」-「昨日」など)に色を付けるにはどうすればよいですか?NodeViewスタイルのBackgrounds、BaseColors、Foregroundsなどを変更して試しましたが、機能しません。
編集:私はちょうどこの方法で列の色を変更できることに気づきました:
protected void OnButton1Clicked (object sender, EventArgs e)
{
// Create a column with title Artist and bind its renderer to model column 0
nodeview1.AppendColumn ("Artist", new Gtk.CellRendererText (), "text", 0);
// Create a column with title 'Song Title' and bind its renderer to model column 1
nodeview1.AppendColumn ("Song Title", new Gtk.CellRendererText (), "text", 1);
nodeview1.ShowAll ();
nodeview1.NodeStore=Store;
nodeview1.Columns[0].Cells[0].CellBackgroundGdk=new Gdk.Color(0,255,0);
}
しかし、どうすれば特定のセルの色を変更できますか?