मैं इस तरह से उपयोगकर्ता के लिए उत्पादन के आंकड़ों के NodeView वस्तु का उपयोग करें (जीटीके # ट्यूटोरियल):जीटीके # NodeView रंग पंक्तियों
[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 की कुछ पंक्तियों "बीटल्स" रंग कर सकते हैं - "कल ", उदाहरण के लिए)? मैंने नोड व्यू स्टाइल की पृष्ठभूमि को बदलकर ऐसा करने की कोशिश की: पृष्ठभूमि, बेसकॉलर्स, फोरग्राउंड और अन्य लेकिन यह काम नहीं करता है।
संपादित करें: मैं बस एहसास हुआ, कि मैं स्तंभ का रंग इस तरह से बदल सकते हैं:
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);
}
लेकिन मैं एक विशेष सेल का रंग कैसे बदल सकते हैं?
मैं अभी यह कोशिश नहीं कर सकता, इसलिए एक टिप्पणी के रूप में: आप सेल रेंडरर को कुछ कस्टम के साथ बदल सकते हैं जो सेल को उचित रंग वाले विजेट से भरता है। –
मुझे ऐसा कुछ नहीं मिल रहा है। नोडव्यू में सेल – Mixim
के लिए कुछ ईवेंट नहीं है यह एक घटना नहीं है। आप वर्तमान में 'Gtk.CellRendererText' वर्ग का उपयोग कर रहे हैं, लेकिन इसके बजाय, ['Gtk.CellRenderer'] से अपने सेल रेंडरर क्लास को प्राप्त करना संभव है (http://docs.go-mono.com/?link= टी% 3aGtk.CellRenderer) अपने 'GetSize' और' रेंडर 'विधियों को ओवरराइड करके। –