• yam天空
  • 天空部落
  • 新聞
  • 登入 註冊 網誌隨便逛
  • 加入天空部落
  • 聽不見我愛你活動

網誌 相簿 影音 PK吧! Honda嬉遊趣
即時新聞 影音新聞 新聞專輯 政治新聞 財經新聞 娛樂新聞 運動新聞 兩岸新聞 科技新聞
管理介面 發表網誌 發表日記 上傳相片 上傳影音 管理留言
推薦這個部落格: 368

dllee

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

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

本文轉貼自我 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 台灣部落格列表
Add to Technorati Favorites Join My Community at MyBloglog!
Free PageRank Checker site statistics
MyHotPost 台灣部落格列表 dllee 統計 ping
藍眼觀注 BO樂區什麼都有... 現在就去看看!
 ◆另開新頁與我MSN◆
廣告(收益全數做公益)
搜尋天空網誌
搜尋:
個人檔案
個人圖檔
ID:dllee
暱稱:dllee
地區:桃園縣
  • 訂閱 |
    • 我要訂閱此部落格的
    • 日記
    • 網誌
    • 相簿
  • 好友 |
    • 好友功能
    • 觀看好友列表
    • 觀看人緣列表
  • 人氣 |
  • 簡介 

文章分類
  • 自製軟體 (10)
  •  程式語言 (18)
  • Ubuntu (4)
  •   程式語言.BCB (2)
  •   程式語言.C# (8)
  •  應用軟體 (41)
  •   MSN (8)
  •  網站架設 (51)
  •   部落軌道 (8)
  •  電腦硬體 (8)
  • 遊戲育樂 (14)
  • 未分類 (4)
  • 日常生活 (43)
  • 網路硬碟 (17)
部落格大串連
推薦好站不可錯過
  • 紫晶數位--電腦遊戲
  • miroko 網路硬碟
  • Delphi.Ktop 程式論壇
  • 文建會兒童文化館中文繪本
  • 兒童英文繪本
  • 為為的快打高手
  • 遊戲世界
  • 小遊戲天堂
  • 好玩遊戲網
  • 好玩遊戲天堂遊戲區
  • Web Game @Live
  • 網路電視線上直播
  • 無理雪兒~
  • 小雪狼 Graffiti
  • dllee在痞客邦
Google 廣告
dllee的感謝您的留言 ^_^
  • 羽:
    我是羽~ ...
  • alice0123:
    我有留言卡位了:p&m...
  • celia05168:
    爵給小咪的 ...
  • abc:
    衛生紙使用後沖入馬桶,...
  • cctsai:
    花時製作 實在好棒...
  • 拆組達人:
    太不貼心了!怎麼沒有在...
  • Nova:
    為什麼沒有口紅印…為什...
  • 羽:
    我是羽~ ...
  • pailing:
    早就知道愛麗絲的手藝很...
  • erica71624:
    真是羨慕~噗噗^O^&...
dllee的最近文章發表
  • 2010年公爵城堡首頁...
  • 愛麗絲手工卡片-200...
  • 解決 Ubuntu...
  • 野兔家三萬踩踩樂獎品收...
  • 在 Windows...
  • 在 Windows...
  • 幫親友拯救...
  • 中秋節搶鍵盤最後機會
  • [開箱文]技嘉鍵盤滑鼠組入手
  • [轉貼]...
  • [轉貼]...
  • [轉貼] 瞎密?...
  • [推]88水災心連心!...
  • 天空部落之快速推文到B...
  • 是作公益?還是為名利?
部落軌道 Blog Orbit
☞ 點我加入部落軌道 ☜
☞ 點我加入BO樂區 ☜

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