yam 蕃薯藤
天空部落
  • 網誌
  • 相簿
  • 影音
  • 夯集
  • PK吧!
  • 揪便宜
  • i鬥圖
  • la zorza
  • 買房子
新聞
  • 即時新聞
  • 影音新聞
  • 新聞專輯
  • 政治新聞
  • 財經新聞
  • 娛樂新聞
  • 運動新聞
  • 兩岸新聞
  • 科技新聞
註冊 登入
夯集
隨便逛
  • 正妹
  • 熱門
  • 網誌
  • 旅遊/攝影
  • 愛情/交友
  • 親子/教育
  • 美食/休閒
  • 設計/創作
  • 家族/同好
  • 影視/音樂
  • 社會/人文
  • 時尚/美容
  • 寵物/生活
  • 工作/職場
  • 科技/金融
  • 運動/健康
  • 交通/運輸
  • 相簿
  • COSPLAY
  • 布袋戲迷
  • 電玩漫畫
  • 女生照片
  • 藝術寫真
  • 攝影作品
  • 男生照片
  • 影視娛樂
  • 大眼小布
  • 情侶拍拍
  • 旅遊紀錄
  • 朋友團體
  • 人文藝術
  • more...
推薦這個部落格: 523

dllee

除了忙與盲之外,也要停下來想一想、看一看... 建議使用 FireFox 或 IE7 以上版本瀏覽。
使用 IE6 若看不到網頁請留個言唷
  • ☞ 網誌分類列表 ☜
    • ※ 網誌分類列表 ※
    •   自製軟體
    •   程式語言
    •   ├ 程式語言.BCB
    •   └ 程式語言.C#
    •   應用軟體
    •   └ MSN
    •   網站架設
    •   └ 部落軌道
    •   Ubuntu
    •   電腦硬體
    •   遊戲育樂
    •   日常生活
    •   └ 乾癬
    •   網路硬碟
    •  ◎不分類網誌列表◎ 
  • ☞ 顯示工具列 ☜

網誌 |相簿 |好友 |留言板
NO$GBA 2.5b 已可順暢模擬 NDS | 主頁 | 轉貼 Item Of ComboBox
November 11, 2007
轉貼 使用列舉的方式取得列表以文找文
dllee 在天空部落發表於11:44:26 |  程式語言.C#
 
本文轉貼自我 MSN ShareSpace 2005/6/25 的 使用列舉的方式取得列表:

與上週一樣的範例,不同之處只是使用了列舉的方式,而不是笨笨的一個一個列出。總算是試用了 foreach

/*
 * Created by 記事本 [:P]
 * User: Lee, Dong-Liang  dllee@edirect168.com
 * Date: 2005/06/25
 */
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace ItemOfComboBox
{
 public class MainForm : System.Windows.Forms.Form
 {
  private System.Windows.Forms.ComboBox cBoxHatchStyle;
  private System.Windows.Forms.Button SelectColor;
  private System.Windows.Forms.Button SelectBKColor;

  public MainForm()
  {
   // cBoxHatchStyle
   this.cBoxHatchStyle = new System.Windows.Forms.ComboBox();
   this.cBoxHatchStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
   this.cBoxHatchStyle.Location = new System.Drawing.Point(20, 10);
   this.cBoxHatchStyle.Name = "cBoxHatchStyle";
   this.cBoxHatchStyle.Size = new System.Drawing.Size(200, 20);
   this.cBoxHatchStyle.TabIndex = 16;
   this.cBoxHatchStyle.SelectedIndexChanged += new System.EventHandler(this.CBoxHatchStyleSelectedIndexChanged);

   // SelectColor
   this.SelectColor = new System.Windows.Forms.Button();
   this.SelectColor.BackColor = System.Drawing.Color.Blue;
   this.SelectColor.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
   this.SelectColor.Location = new System.Drawing.Point(250, 10);
   this.SelectColor.Name = "SelectColor";
   this.SelectColor.TabIndex = 8;
   this.SelectColor.Text = "Color1";
   this.SelectColor.Click += new System.EventHandler(this.SelectColorClick);

   // SelectBKColor
   this.SelectBKColor = new System.Windows.Forms.Button();
   this.SelectBKColor.BackColor = System.Drawing.Color.Yellow;
   this.SelectBKColor.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
   this.SelectBKColor.Location = new System.Drawing.Point(350, 10);
   this.SelectBKColor.Name = "SelectBKColor";
   this.SelectBKColor.TabIndex = 15;
   this.SelectBKColor.Text = "Color2";
   this.SelectBKColor.Click += new System.EventHandler(this.SelectBKColorClick);

   // MainForm
   this.ClientSize = new System.Drawing.Size(600, 400);
   this.Controls.Add(this.cBoxHatchStyle);
   this.Controls.Add(this.SelectColor);
   this.Controls.Add(this.SelectBKColor);
   this.Name = "MainForm";
   this.Text = "ItemOfComboBox : HatchSytle Example by http://dllee.ktop.com.tw";
   this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form_Paint);
   this.ActiveControl = this.cBoxHatchStyle;

   // C# 的 comboBox 可以直接加入物件,它似乎會自己取 .ToString() 的方法
   // 得到字串作列表,而加入的物件之後可以直接取出使用。
   // <2005-06-25> 使用列舉的方式取得列表。
   Array hsList = Enum.GetValues( typeof( HatchStyle ) );
    foreach ( HatchStyle hs in hsList )
     this.cBoxHatchStyle.Items.Add(hs);
   this.cBoxHatchStyle.SelectedIndex=1;
  }
  
  [STAThread]
  public static void Main(string[] args)
  {
   Application.Run(new MainForm());
  }

  void SelectColorClick(object sender, System.EventArgs e)
  {
   ColorDialog clrDlg = new ColorDialog();
   clrDlg.Color = this.SelectColor.BackColor;
   if (clrDlg.ShowDialog() == DialogResult.OK)
   {
    this.SelectColor.BackColor = clrDlg.Color;
    this.Invalidate();
   }
   clrDlg.Dispose();
  }
  
  void SelectBKColorClick(object sender, System.EventArgs e)
  {
   ColorDialog clrDlg = new ColorDialog();
   clrDlg.Color = this.SelectBKColor.BackColor;
   if (clrDlg.ShowDialog() == DialogResult.OK)
   {
    this.SelectBKColor.BackColor = clrDlg.Color;
    this.Invalidate();
   }
   clrDlg.Dispose();
  }

  void Form_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
  {
   Graphics g = e.Graphics;
   // 物件轉換成其他類別
   HatchStyle selectedHatchStyle = (HatchStyle)Convert.ChangeType(
     this.cBoxHatchStyle.SelectedItem,typeof(HatchStyle));
   // Create a hatch brush with selected hatch style and colors
   HatchBrush brush = new HatchBrush(selectedHatchStyle,
     this.SelectColor.BackColor, this.SelectBKColor.BackColor);
   // Fill rectangle
   g.FillRectangle(brush, this.ClientRectangle);
   // Dispose of objects
   brush.Dispose();
  }

  void CBoxHatchStyleSelectedIndexChanged(object sender, System.EventArgs e)
  {
   this.Invalidate();
  }
 }
}

誰推薦這篇文章:
留言 (0) | 引用 (0) | 人氣 () | 轉寄 | 檢舉
此分類上一篇:C# Console - 在 EmEditor 編譯 | 主頁 | 此分類下一篇:轉貼 Item Of ComboBox
引用 (你可以針對此文寫一篇屬於自己的blog/想法,並給作者一個通告)
引用
留言 (0筆)
發表你的留言 (字數限制 最多 2000 個中文字)
注意! 此篇留言為私密留言
Name:



是 否
內容:
檢視行動版網頁  |  檢視正常版網頁
系統公告
熱情贊助
部落格貼紙
網摘、引用、連結,不轉載

My Blog History MyHotPost
Add to Technorati Favorites
Free PageRank Checker site statistics

藍眼觀注
 ◆另開新頁與我MSN◆

廣告(收益全數做公益)
搜尋天空網誌
搜尋:
個人檔案
個人圖檔
ID:dllee
暱稱:dllee
地區:桃園縣
  • 好友 |
    • 好友功能
    • 觀看好友列表
    • 觀看人緣列表
  • 人氣 |
  • 簡介 

文章分類
  • 自製軟體 (10)
  • 程式語言 (18)
  •  程式語言.BCB (2)
  •  程式語言.C# (8)
  • 應用軟體 (42)
  •  MSN (10)
  • 網站架設 (51)
  •  部落軌道 (8)
  • Ubuntu (5)
  • 電腦硬體 (8)
  • 遊戲育樂 (14)
  • 日常生活 (45)
  •  乾癬 (10)
  • 未分類 (6)
  • 網路硬碟 (18)
  • 寫手體驗 (2)
部落格大串連
推薦好站不可錯過
  • 紫晶數位--電腦遊戲
  • miroko 網路硬碟
  • Delphi.Ktop 程式論壇
  • 文建會兒童文化館中文繪本
  • 兒童英文繪本
  • 為為的快打高手
  • 遊戲世界
  • 小遊戲天堂
  • 好玩遊戲網
  • 好玩遊戲天堂遊戲區
  • Web Game @Live
  • 網路電視線上直播
  • 無理雪兒~
  • 小雪狼 Graffiti
  • dllee在痞客邦
Google 廣告
dllee的感謝您的留言 ^_^
  • 小晴:
    乾癬在我身上已經有20...
  • 月玲姐姐:
    只有得病者才能體會其中...
  • 很困擾的乾癬:
    我弟弟有乾癬的病史已經...
  • hanson.334:
    桃園哪裡有可以根治乾癬...
  • peijung:
    我在輸入密碼時可能按到...
  • 世賢:
    右下角黃色氣球通知是系...
  • 煩惱的女孩:
    我是最近才知道...
  • pailing:
    這幾天yam更改了工具...
  • 妙覺明:
    寫的真的很好.辛苦了....
  • 好煩惱的女孩:
    不好意思 我想請問一下...
dllee的最近文章發表
  • 我是 dllee
  • 暫時失去寫網誌的 Fu~~~
  • 個人資料暫存
  • M群簡易使用說明
  • 乾癬記錄 我的乾癬正在改變
  • 乾癬治療畢業分享
  • 乾癬治療分享第九,十,十一週
  • 乾癬治療分享第六,七,八週
  • 乾癬治療分享第四,五週
  • 乾癬治療分享第三週
  • 乾癬治療分享第二週
  • 乾癬治療分享第一週
  • MSN 連絡人邀請及...
  • 請天空小尖兵增加留言預...
  • 自明天開始每週六到九條...
部落軌道 Blog Orbit
☞ 點我加入部落軌道 ☜

ShoutMix chat widget
Plurk.com
感謝您留下足跡
Blogger in the world
世界上誰在看dllee
人氣指數
當日人次:
累積人次:
yam揪便宜
yam今日我最殺
RSS 訂閱
RSS2
ATOM
CC授權
其它資訊
本部落所刊登之內容,皆由作者個人所提供,不代表 yam 天空部落 本身立場。
POWERED BY
POWERED BY 天空部落
會員登入│免費註冊