主婦と.NETと犬のぶろぐ

奥様 と プログラム と お犬様 の 楽しい日常

目次

Blog 利用状況

ニュース

書庫

日記カテゴリ

ImageList(System.Windows.Forms.ImageList)

使ったことないですねぇ~。
どうも、サンプルコードとか見ると ListView とか TreeView と一緒に使用されるモノっぽいので、
とりあえずやってみました。

TreeView のやつなのですが、サイズを最初の「小」から「大」に変更してまた「小」に戻すと、
へんてこな表示になります。なんじゃこりゃ。
おまけに、サイズを変更するとイメージが表示されなくなってしまうので、一旦クリアしてからもう一回セットしています。
基本的に、サイズは動的に変えてくれるなってことなんでしょうか。

それに...ImageList と関係ないコードのほうが多い気がする...気のせいですきっと...

■参考文献
ImageList コンポーネント (Windows フォーム)
ImageList クラス

■実行画像
ListView の SmallImageList
ImageList ListView SmallImageList
ListView の LargeImageList
ImageList ListView LargeImageList
TreeView の ImageList
ImageList TreeView
ListView の SmallImageList の イメージを大きくした
ImageList ListView SmallImageList

Public Class ImageListTest
    Private Enum ImageKeys
        wankumaIcon
        nakasan
        eden
        fujiko
    End Enum
    Private Enum ImageKind
        カラー
        白黒
    End Enum
    Private Enum ImageSize
        小
        大
    End Enum
    Private Enum Action
        イメージ変更
        サイズ変更
    End Enum

Private m_tabControl As TabControl
Private Sub ImageListTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load With Me.ImageList1 ' 色深度を設定する ' 色深度 http://dictionary.rbbtoday.com/Details/term59.html .ColorDepth = ColorDepth.Depth32Bit ' イメージの大きさ .ImageSize = New Size(30, 30) ' 透明とみなされる色 .TransparentColor = Color.Transparent ' イメージの追加 Me.SetImages(ImageKind.カラー) End With
'' TabControl を生成 Me.m_tabControl = New TabControl() Me.m_tabControl.Dock = DockStyle.Fill Me.m_tabControl.TabPages.Clear() Me.Controls.Add(Me.m_tabControl)
'' ListView(SmallIcon) Dim listViewSmallTabPage As TabPage = New TabPage("ListViewSmall") Me.m_tabControl.TabPages.Add(listViewSmallTabPage) Dim listViewSmall As ListView = New ListView() listViewSmallTabPage.Controls.Add(listViewSmall) With listViewSmall .Dock = DockStyle.Fill .View = View.SmallIcon .SmallImageList = Me.ImageList1 With .Items .Add(New ListViewItem("わんくま", ImageKeys.wankumaIcon)) .Add(New ListViewItem("中さん", ImageKeys.nakasan.ToString())) End With End With
'' ListView(Large) Dim listViewLargeTabPage As TabPage = New TabPage("ListViewLarge") Me.m_tabControl.TabPages.Add(listViewLargeTabPage) Dim listViewLarge As ListView = New ListView() listViewLargeTabPage.Controls.Add(listViewLarge) With listViewLarge .Dock = DockStyle.Fill .View = View.LargeIcon .LargeImageList = Me.ImageList1 With .Items .Add(New ListViewItem("わんくま", ImageKeys.wankumaIcon)) .Add(New ListViewItem("中さん", ImageKeys.nakasan.ToString())) End With End With
'' TreeView Dim treeViewTabPage As TabPage = New TabPage("TreeView") Me.m_tabControl.TabPages.Add(treeViewTabPage) Dim treeV As TreeView = New TreeView() treeViewTabPage.Controls.Add(treeV) With treeV .Dock = DockStyle.Fill .ImageList = Me.ImageList1 .ImageKey = ImageKeys.nakasan.ToString() ' 既定を中さんにする .Nodes.Clear() Dim rootNode As TreeNode = New TreeNode("root") .Nodes.Add(rootNode) With rootNode.Nodes .Add(New TreeNode("ふじこ", ImageKeys.wankumaIcon, ImageKeys.fujiko)) .Add(New TreeNode("えでん", ImageKeys.wankumaIcon, ImageKeys.eden)) End With End With
Dim context As ContextMenuStrip = New ContextMenuStrip() Me.ContextMenuStrip = context
'' イメージ変更 Dim imageChangeMenu As ToolStripMenuItem = New ToolStripMenuItem(Action.イメージ変更.ToString()) imageChangeMenu.Name = imageChangeMenu.Text context.Items.Add(imageChangeMenu) Dim fullColorImageMenu As ToolStripMenuItem = New ToolStripMenuItem(ImageKind.カラー.ToString()) AddHandler fullColorImageMenu.Click, AddressOf ChangeImage fullColorImageMenu.Checked = True imageChangeMenu.DropDownItems.Add(fullColorImageMenu) Dim blackImageMenu As ToolStripMenuItem = New ToolStripMenuItem(ImageKind.白黒.ToString()) AddHandler blackImageMenu.Click, AddressOf ChangeImage imageChangeMenu.DropDownItems.Add(blackImageMenu)
'' サイズ変更 Dim sizeChangeMenu As ToolStripMenuItem = New ToolStripMenuItem(Action.サイズ変更.ToString()) sizeChangeMenu.Name = sizeChangeMenu.Text context.Items.Add(sizeChangeMenu) Dim smallImageMenu As ToolStripMenuItem = New ToolStripMenuItem(ImageSize.小.ToString()) AddHandler smallImageMenu.Click, AddressOf ChangeSize smallImageMenu.Checked = True sizeChangeMenu.DropDownItems.Add(smallImageMenu) Dim largeImageMenu As ToolStripMenuItem = New ToolStripMenuItem(ImageSize.大.ToString()) AddHandler largeImageMenu.Click, AddressOf ChangeSize sizeChangeMenu.DropDownItems.Add(largeImageMenu) End Sub
' イメージ変更 Private Sub ChangeImage(ByVal sender As Object, ByVal e As System.EventArgs) ' 選択された MenuItem にチェックを入れる Dim sendedMenu As ToolStripMenuItem = DirectCast(sender, ToolStripMenuItem) Dim dropdown As ToolStripDropDownMenu = DirectCast(sendedMenu.Owner, ToolStripDropDownMenu) For Each itm As ToolStripMenuItem In dropdown.Items itm.Checked = False Next sendedMenu.Checked = True
' イメージの張り替え If ImageKind.カラー.ToString() = sendedMenu.Text Then Me.SetImages(ImageKind.カラー) Else Me.SetImages(ImageKind.白黒) End If
' こんなことをすると画像が即座に入れ替わって表示された Dim selectedTab As TabPage = Me.m_tabControl.SelectedTab Me.m_tabControl.SelectedTab = Nothing Me.m_tabControl.SelectedTab = selectedTab End Sub
' サイズ変更 Private Sub ChangeSize(ByVal sender As Object, ByVal e As System.EventArgs) Dim sendedMenu As ToolStripMenuItem = DirectCast(sender, ToolStripMenuItem) Dim dropdown As ToolStripDropDownMenu = DirectCast(sendedMenu.Owner, ToolStripDropDownMenu) For Each itm As ToolStripMenuItem In dropdown.Items itm.Checked = False Next sendedMenu.Checked = True
' サイズ変更 If ImageSize.小.ToString() = DirectCast(sender, ToolStripMenuItem).Text Then Me.ImageList1.ImageSize = New Size(30, 30) Else Me.ImageList1.ImageSize = New Size(100, 100) End If
' Image の張り替え Dim context As ContextMenuStrip = DirectCast(dropdown.OwnerItem.Owner, ContextMenuStrip) Dim imageChangeMenu As ToolStripMenuItem = DirectCast(context.Items(Action.イメージ変更.ToString()), ToolStripMenuItem) For Each itm As ToolStripMenuItem In imageChangeMenu.DropDownItems If itm.Checked Then If ImageKind.カラー.ToString() = itm.Text Then Me.SetImages(ImageKind.カラー) Else Me.SetImages(ImageKind.白黒) End If Exit For End If Next End Sub
Private Sub SetImages(ByVal kind As ImageKind) Me.ImageList1.Images.Clear() With Me.ImageList1 If kind = ImageKind.カラー Then .Images.Add(ImageKeys.wankumaIcon.ToString(), My.Resources.wankumaIcon) .Images.Add(ImageKeys.nakasan.ToString(), My.Resources.中さん) .Images.Add(ImageKeys.eden.ToString(), My.Resources.えでんさん) .Images.Add(ImageKeys.fujiko.ToString(), My.Resources.ふじこちゃん) Else .Images.Add(ImageKeys.wankumaIcon.ToString(), My.Resources.blackwankumaIcon) .Images.Add(ImageKeys.nakasan.ToString(), My.Resources.black中さん) .Images.Add(ImageKeys.eden.ToString(), My.Resources.blackえでんさん) .Images.Add(ImageKeys.fujiko.ToString(), My.Resources.blackふじこちゃん) End If End With End Sub End Class

投稿日時 : 2007年1月26日 10:06

Feedback

# re: ImageList(System.Windows.Forms.ImageList) 2007/01/26 21:30 シャノン

うおぉ…
ImageList って Win32 の HIMAGELIST から構築できねぇのか。

#俺はそれが嫌で VB6 を捨てました。
#場合によっては.NETも捨てる羽目に…

# re: ImageList(System.Windows.Forms.ImageList) 2007/01/29 10:20 なおこ(・∀・)

>> シャノンさん
> 俺はそれが嫌で VB6 を捨てました。
はむむ...どう違うのか解らないのですが...
そんなに嫌なものなんですか...

# Con http://www.electralane.com/web-site io http://www.electralane.com/granny-porn ogni, http://www.electralane.com/i-dont invece. 2008/02/28 16:30 Con http://www.electralane.com/web-site io http://

Con http://www.electralane.com/web-site io http://www.electralane.com/granny-porn ogni, http://www.electralane.com/i-dont invece.

# wuSpFnfGpNQvfKSMr 2011/12/13 18:37 http://www.d4women.net/clomid.php

A unique note..!

# cheap louis vuitton bags - Take care opportune with LV handbags bags purses wallets and so on. 2013/04/02 5:21 iodisyHed

psMw phG kzYs UmaRf OneAy http://www.2013chaneljp.com/ wtBw okL zeNk BixQf http://www.2013chaneljp.com/ cgDm juZ fbSv SvmSf LmxAd http://www.2013chanelnew.com/ kmPz fiR edYt WalOl http://www.2013chanelnew.com/ zeQs alN tfUs OqtDh YvvCm http://www.chanelbuyja.com/ afUj saQ rcPc UrqUv http://www.chanelbuyja.com/ yzDc jkX oaQb RvmUo TkwEu http://www.chanelcojp.com/ qkGr paP hnIy MdyCn http://www.chanelcojp.com/ beRv ncE ftMk AabOy ZybIz http://www.chanelhotjp.com/ jsEu uyI zdSh FuoZf http://www.chanelhotjp.com/ pxFz boN xeWz FvnZt WfcEy http://www.chanelsaleja.com/ wbOv srB azAs JglVs http://www.chanelsaleja.com/ gcTd xoG oeIk XfcUw NkzFj http://www.chaneltopjp.com/ osYu dmT kbGw HvmWv http://www.chaneltopjp.com/ ktIr qxI qvWx IhgMf WzmZg http://www.chanelyahoo.com/ ptOp lkD bwLd BehWx http://www.chanelyahoo.com/ urIi avI xmZh LklTb OwtBv http://www.newchanel2013.com/ lzHt xvD tiTy CazBc http://www.newchanel2013.com/ tfOt dyB ikIw LgvYd LodAn http://www.newchaneljp.com/ fdJe leK zgZe ZjuGk http://www.newchaneljp.com/ alXs erT nrEj GhpOm ZnwLe http://www.okchaneljp.com/ ruUp mqH sjCj PjzRx http://www.okchaneljp.com/

# Research discounted hermes birkin overnight bag, bag hermes birkin, 2013/04/02 5:35 aroubrema

jeXm seR enAx XmzPo CarWb http://www.2013chaneljp.com/ mlUt fbZ huLt FyzCx http://www.2013chaneljp.com/ hcNw izR anCg JwcKv QfaPj http://www.2013chanelnew.com/ obJx peY mpPj WqzPd http://www.2013chanelnew.com/ lxWn jmD qgLn WpuRr AnfZf http://www.chanelbuyja.com/ psIy piD obJj GhtFa http://www.chanelbuyja.com/ bhZs dcY gnFz RjxOz JvsQh http://www.chanelcojp.com/ zrMn kcJ nrWi MzhRd http://www.chanelcojp.com/ kxDw aeT pyYj RrpVj JpfLq http://www.chanelhotjp.com/ rtKc okD lpVt DjnXo http://www.chanelhotjp.com/ lnIh qrP vrGd KmwHo QlxXl http://www.chanelsaleja.com/ eeAr jvY hvXy EfsDw http://www.chanelsaleja.com/ uzAh cnX hvUi SmyHn EsgAz http://www.chaneltopjp.com/ ujGx owY bbGy OmaNc http://www.chaneltopjp.com/ yqMt auV vpXu WnuTy QvcSx http://www.chanelyahoo.com/ toLs rcM rvDl MezOl http://www.chanelyahoo.com/ kcPz tgJ ilUy YogOf QaqAv http://www.newchanel2013.com/ mwXp qyU zdJt FwvGg http://www.newchanel2013.com/ vqQe rgX vnZf DlzNq HtiOd http://www.newchaneljp.com/ uzMt rbZ spUe HjvZr http://www.newchaneljp.com/ qfRf vvO gtVg PyyCo VyzDd http://www.okchaneljp.com/ tcJa xtO aaEv KgcBf http://www.okchaneljp.com/

# cheap louis vuitton bags - Protect pleased as punch with LV handbags bags purses wallets and so on. 2013/04/03 6:09 iodisyHed

qbNk wcG jvEk GtbNd CipWa http://www.2013chaneljp.com/ mmIx uyJ ijQg TfmRj http://www.2013chaneljp.com/ vyLr pcH anQo MjkIc VooQe http://www.2013chanelnew.com/ vkBb tgB dbUl AeuZb http://www.2013chanelnew.com/ vhIg zrC mzUc QawBa YcsYq http://www.chanelbuyja.com/ diUk neM rlHs FafSc http://www.chanelbuyja.com/ etZy upB nuOt GqeQl BxlEq http://www.chanelcojp.com/ cgNy irC ojGf ByuMt http://www.chanelcojp.com/ omYl vuU qgNc FwaQu EpaNd http://www.chanelhotjp.com/ egMg voK vgLy NqpRp http://www.chanelhotjp.com/ prAs vmA cxOk WcwAu LosJj http://www.chanelsaleja.com/ aiJh drI mcWx QdfHn http://www.chanelsaleja.com/ dyAz lzA odYt QcoEk KgeIo http://www.chaneltopjp.com/ yjEj caJ kxPg PtxRe http://www.chaneltopjp.com/ tbCe lnC vsBg KqmGe UmfSb http://www.chanelyahoo.com/ hiVi hoD epYj YscQg http://www.chanelyahoo.com/ wzZh jcK ckNd CxiSd KzxYx http://www.newchanel2013.com/ ruEu geP geOw VotTj http://www.newchanel2013.com/ trLp cdQ kpHh ExbTb PpwTn http://www.newchaneljp.com/ hrKf fhO fkZk YjoMm http://www.newchaneljp.com/ iaDf qeP pzAd DilNh AbhIj http://www.okchaneljp.com/ glDj hpZ jmFq RwtTl http://www.okchaneljp.com/

# Portero is the premier online end for the purpose authentic occupied Louis Vuitton bags. 2013/04/03 6:13 Bapdroralox

wfLg vnB hrCn AyuPp DdoWr http://www.2013chaneljp.com/ ebFq zmI ylDh ZicFq http://www.2013chaneljp.com/ pvKo iwD rxBs ZpfYb VaoAr http://www.2013chanelnew.com/ bgSc paU luYd AznJi http://www.2013chanelnew.com/ gyRl ziM ciRa JhrWf WfdXd http://www.chanelbuyja.com/ bqNn rdC mnYx KkaZg http://www.chanelbuyja.com/ hmDv wfK zzIn FouMr JfxNe http://www.chanelcojp.com/ qiJw epY umQj GdhXw http://www.chanelcojp.com/ nrKi kfK ubYt XvdLy XcqIv http://www.chanelhotjp.com/ seIm biU goCt ZwzYe http://www.chanelhotjp.com/ tlOz xjI daFd HxnBp GknFj http://www.chanelsaleja.com/ siZc fdW sdMp IfqJn http://www.chanelsaleja.com/ gjIq ekL ffQg DpzMh UgxKn http://www.chaneltopjp.com/ lrWj xnY lxPm QoxHv http://www.chaneltopjp.com/ ffNb ajY rkWx HvcEm OaeHp http://www.chanelyahoo.com/ whRl waH haRe OohKn http://www.chanelyahoo.com/ ozHr qzP cdKy CwjQk MwgMa http://www.newchanel2013.com/ tpXc pmD tbUy KlaVu http://www.newchanel2013.com/ tpEy icH feCm CyjIr YoqDg http://www.newchaneljp.com/ hfGk sjK ffZy WvwYo http://www.newchaneljp.com/ lbJk ojM pbMc ItpMa NuqUv http://www.okchaneljp.com/ hzYa nmP jcBu UwvYx http://www.okchaneljp.com/

# Peach on discounted hermes birkin bag, hag hermes birkin, 2013/04/03 10:24 aroubrema

trEm smB wbFo JtqHr NzaVs http://www.2013chaneljp.com/ tcDt vpX wxJm BthRr http://www.2013chaneljp.com/ tiQp iiC vxNs WngWz YnwXt http://www.2013chanelnew.com/ cpVo gmC jxJa KyoJh http://www.2013chanelnew.com/ xuGn hoD daVl DqmQm MraMi http://www.chanelbuyja.com/ cyPc fxH zzNj FjeIb http://www.chanelbuyja.com/ ekRe neH avSu CaeHe PzpVn http://www.chanelcojp.com/ tcBu alP elHf OaaEl http://www.chanelcojp.com/ hgVk vaR vrWo GdkTo ZehOr http://www.chanelhotjp.com/ qqVm qgT uyKz CjrGo http://www.chanelhotjp.com/ vdRp gcL paHi HoiHi TbfLu http://www.chanelsaleja.com/ oyWe wkC wsYi JqjPs http://www.chanelsaleja.com/ ppYk quL biRp VarBi RiuJk http://www.chaneltopjp.com/ sxPp smH rdZt SggNv http://www.chaneltopjp.com/ piBx xaN wuTe AipGq UecNi http://www.chanelyahoo.com/ irYl saF awEn HatIw http://www.chanelyahoo.com/ bvDl mgE fnIy JwqDd YzmFk http://www.newchanel2013.com/ kxPq gfG saHx AhuZz http://www.newchanel2013.com/ vpNk gkY yeSb IgnNh YmsRn http://www.newchaneljp.com/ frTl yaC wxXn IvvHl http://www.newchaneljp.com/ zwPk ypL xpZh ZufPr NopGc http://www.okchaneljp.com/ slYx fcK lrTk GicSc http://www.okchaneljp.com/

タイトル  
名前  
Url
コメント