1 // 2 // TestCombo.cs 3 // 4 // Author: Duncan Mak (duncan@ximian.com) 5 // 6 // Copyright (C) 2003, Duncan Mak, Ximian Inc. 7 // 8 9 using System; 10 11 using Gtk; 12 13 namespace WidgetViewer { 14 public class TestCombo 15 { 16 static Window window = null; 17 static Gtk.Combo combo = null; 18 Create()19 public static Gtk.Window Create () 20 { 21 window = new Window ("GtkCombo"); 22 window.SetDefaultSize (200, 100); 23 24 VBox box1 = new VBox (false, 0); 25 window.Add (box1); 26 27 VBox box2 = new VBox (false, 10); 28 box2.BorderWidth = 10; 29 box1.PackStart (box2, true, true, 0); 30 31 combo = new Gtk.Combo (); 32 string[] pop = {"Foo", "Bar"}; 33 combo.PopdownStrings = pop; 34 combo.Entry.Activated += new EventHandler (OnComboActivated); 35 box2.PackStart (combo, true, true, 0); 36 37 HSeparator separator = new HSeparator (); 38 39 box1.PackStart (separator, false, false, 0); 40 41 box2 = new VBox (false, 10); 42 box2.BorderWidth = 10; 43 box1.PackStart (box2, false, false, 0); 44 45 Button button = new Button (Stock.Close); 46 button.Clicked += new EventHandler (OnCloseClicked); 47 button.CanDefault = true; 48 49 box2.PackStart (button, true, true, 0); 50 button.GrabDefault (); 51 return window; 52 } 53 OnCloseClicked(object o, EventArgs args)54 static void OnCloseClicked (object o, EventArgs args) 55 { 56 window.Destroy (); 57 } 58 OnComboActivated(object o, EventArgs args)59 static void OnComboActivated (object o, EventArgs args) 60 { 61 string text = ((Gtk.Entry) o).Text; 62 63 // combo.AppendString (text); 64 // combo.SetPopdownStrings (text); 65 } 66 } 67 } 68 69 70