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

dllee

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

網誌 |相簿 |好友 |留言板
轉貼 使用列舉的方式取得列表 | 主頁 | 好友 MSN 送來網址最好確認再點
November 11, 2007
轉貼 Item Of ComboBox以文找文
dllee 在天空部落發表於11:30:40 |  程式語言.C#
 
本文轉貼自我 MSN ShareSpace 2005/6/18 的Item Of ComboBox:

今天終於去下載了 .NET SDK,試試 csc /out:sample.exe sample.cs 還真是簡單
以下是最近在學 GDI+ 時,修改書本的範例,所得到的心得,原本以為,.NET ComboBox 為什麼 List Item 只能放 object 沒有 string,原來她把這兩個東西給合併了。

附件:ItemOfComboBox.cs

PS1. MSN Spaces 不太適合貼程式碼... 金害...
PS2. 我貼的圖內含程式原始碼及 csc 輸出的可執行檔喔,下載改名為 .zip 可解出。
/*
 * Created by 記事本 [:P]
 * User: Lee, Dong-Liang  dllee@edirect168.com
 * Date: 2005/06/18
 */
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() 的方法
			// 得到字串作列表,而加入的物件之後可以直接取出使用。
			this.cBoxHatchStyle.Items.Add(HatchStyle.BackwardDiagonal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Cross); // 與 LargeGrid 相同?!
			this.cBoxHatchStyle.Items.Add(HatchStyle.DarkDownwardDiagonal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.DarkHorizontal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.DarkUpwardDiagonal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.DarkVertical);
			this.cBoxHatchStyle.Items.Add(HatchStyle.DashedDownwardDiagonal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.DashedHorizontal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.DashedUpwardDiagonal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.DashedVertical);
			this.cBoxHatchStyle.Items.Add(HatchStyle.DiagonalBrick);
			this.cBoxHatchStyle.Items.Add(HatchStyle.DiagonalCross);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Divot);
			this.cBoxHatchStyle.Items.Add(HatchStyle.DottedDiamond);
			this.cBoxHatchStyle.Items.Add(HatchStyle.DottedGrid);
			this.cBoxHatchStyle.Items.Add(HatchStyle.ForwardDiagonal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Horizontal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.HorizontalBrick);
			this.cBoxHatchStyle.Items.Add(HatchStyle.LargeCheckerBoard);
			this.cBoxHatchStyle.Items.Add(HatchStyle.LargeConfetti);
			this.cBoxHatchStyle.Items.Add(HatchStyle.LargeGrid);
			this.cBoxHatchStyle.Items.Add(HatchStyle.LightDownwardDiagonal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.LightHorizontal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.LightUpwardDiagonal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.LightVertical);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Max);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Min);
			this.cBoxHatchStyle.Items.Add(HatchStyle.NarrowHorizontal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.NarrowVertical);
			this.cBoxHatchStyle.Items.Add(HatchStyle.OutlinedDiamond);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Percent05);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Percent10);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Percent20);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Percent25);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Percent30);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Percent40);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Percent50);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Percent60);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Percent70);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Percent75);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Percent80);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Percent90);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Plaid);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Shingle);
			this.cBoxHatchStyle.Items.Add(HatchStyle.SmallCheckerBoard);
			this.cBoxHatchStyle.Items.Add(HatchStyle.SmallConfetti);
			this.cBoxHatchStyle.Items.Add(HatchStyle.SmallGrid);
			this.cBoxHatchStyle.Items.Add(HatchStyle.SolidDiamond);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Sphere);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Trellis);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Vertical);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Wave);
			this.cBoxHatchStyle.Items.Add(HatchStyle.Weave);
			this.cBoxHatchStyle.Items.Add(HatchStyle.WideDownwardDiagonal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.WideUpwardDiagonal);
			this.cBoxHatchStyle.Items.Add(HatchStyle.ZigZag);
			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();
		}
	}
}

附件:ItemOfComboBox.cs

誰推薦這篇文章:
留言 (0) | 引用 (0) | 人氣 () | 轉寄 | 檢舉
此分類上一篇:轉貼 使用列舉的方式取得列表 | 主頁 | 此分類下一篇:Test Simple Paint Object
引用 (你可以針對此文寫一篇屬於自己的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 天空部落
會員登入│免費註冊