異世界


2013年6月8日 星期六

Gtk# 執行時期產生 Button Widget

   1: /* ----------------------------------------
   2: * 產生一個 Gtk.Button , 放置於 fixed2  容器中
   3: * 並設定於fixed2 容器 中的絕對位置 *
   4: * ----------------------------------------*/
   5: int BtnCnt = 0;
   6: protected void btnOnClick (object sender, System.EventArgs e)
   7: {
   8:  BtnCnt++;
   9:  string strBuf = string.Format("Btn_{0}",BtnCnt);
  10:  Button btn = new Gtk.Button(strBuf);
  11:  btn.WidthRequest = 80;
  12:  btn.CanFocus = true;
  13:  btn.Name = strBuf;
  14:  btn.UseUnderline = true;
  15:  btn.Label = strBuf;
  16:  this.fixed2.Add (btn);
  17:  ( (Gtk.Fixed.FixedChild)(this.fixed2 [btn])).X = 20;
  18: ( (Gtk.Fixed.FixedChild)(this.fixed2 [btn])).Y = 20 + BtnCnt*50;
  19:  
  20:  
  21: // Gtk.Fixed.FixedChild ww = (Gtk.Fixed.FixedChild)(this.fixed2 [btn]);
  22:  
  23: ww.X = 20;
  24:  
  25: ww.Y = 20 + BtnCnt*50;
  26:  
  27:  btn.Show();
  28:  //throw new System.NotImplementedException ();
  29: }

image


image

沒有留言:

張貼留言