主婦と.NETと犬のぶろぐ

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

目次

Blog 利用状況

ニュース

書庫

日記カテゴリ

CheckedListBox(System.Windows.Forms.CheckedListBox)

これもあんまり難しいことないですね。
MSDN フォーラムの記事で 以下のものを見つけたので、Button1 を押下した後に、
CheckedListBox を選択して、キーで M とか打ってみると Moo さんが最初に選択される。
CheckedListBoxに半角スペースで始まるItemを入れるとスペースキーでの挙動がおかしい
たしかに、これはこれで便利な気がします。

あと、個人的に興味深かったのは、CheckedItems や CheckedIndices 、SelectedItems や SelectedIndices プロパティの型ですね。

■参考文献
CheckedListBox クラス
ListBox.ObjectCollection クラス
CheckedListBox.CheckedItemCollection クラス
CheckedListBox.CheckedIndexCollection クラス
ListBox.SelectedObjectCollection クラス
ListBox.SelectedIndexCollection クラス

■実行画像
Button1 押下時
CheckedListBox Button1 押下時

Button2 押下時
CheckedListBox Button2 押下時

Public Class CheckedListBoxTest

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '' 複数行のサポート Me.CheckedListBox1.MultiColumn = True Me.CheckedListBox1.ColumnWidth = 100 Me.CheckedListBox1.Items.Clear() ' 表示するデータ Dim data As String() = _ {"中博俊", "じゃんぬねっと", "夏椰", "なおこ(・∀・)", _ "まゆりん", "Jitta", "trapemiya", "やねうらお", "囚人", _ "Moo", "maint", "επιστημη(えぴすてーめー)", _ "とっちゃん", "おぎわら", "えムナウ", "買太郎", _ "むたぐち", "aera", "taos", "ue", "ognac", _ "108bones", "ghost_shell", "黒龍", "koka", "inogucci", _ "ヽ(゚∀。)ノうぇね", "アクア", "n", "zee", "十郎", _ "Pandora", "刈歩 菜良", "R・田中一郎", "十兵衛(諸農)", _ "まさぶん", "まどか", "ゆき", "恣意の", "ひろえむ", _ "taka", "c", "DS7", "w", "沢渡真雪", "THREE-ONE", _ "Blue", "RAPT", "初音玲", "のぶさん", "ぽぴ王子", "g", "a", "s"} Me.CheckedListBox1.Items.AddRange(data) ' なおこを削除 Me.CheckedListBox1.Items.Remove("なおこ(・∀・)") ' なおこをえぴすさんの後に挿入 Me.CheckedListBox1.Items.Insert(11, "なおこ(・∀・)") ' なおこのチェック状態を設定 Me.CheckedListBox1.SetItemCheckState(11, CheckState.Checked) End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.CheckedListBox1.MultiColumn = False Me.CheckedListBox1.ColumnWidth = 0 Me.CheckedListBox1.Items.Clear() '' 項目選択時にチェックボックスにチェックが入ったりするようにする Me.CheckedListBox1.CheckOnClick = True Me.CheckedListBox1.BeginUpdate() Me.CheckedListBox1.Items.Add("えでん", False) '未チェック Me.CheckedListBox1.Items.Add("ふじこ", True) 'チェック Me.CheckedListBox1.Items.Add("オット", CheckState.Indeterminate) 'CheckStateでの指定もOK Me.CheckedListBox1.EndUpdate() ' ふじこを最初に選択する Me.CheckedListBox1.SetSelected(1, True) End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click '' すべてのアイテムを取得 Console.WriteLine(StrDup(50, "="c)) Console.WriteLine("アイテム数:" & Me.CheckedListBox1.Items.Count.ToString()) For Each listitm As Object In Me.CheckedListBox1.Items 'ListBox.ObjectCollection Console.WriteLine(Convert.ToString(listitm)) Next
'' チェックされているアイテムを取得 Console.WriteLine(StrDup(50, "="c)) Console.WriteLine("チェックされているアイテム数:" & Me.CheckedListBox1.CheckedItems.Count.ToString()) For Each checkedlistitm As Object In Me.CheckedListBox1.CheckedItems 'CheckedListBox.CheckedItemCollection 'Checked または Indeterminate である項目だけ Console.WriteLine(Convert.ToString(checkedlistitm)) Next
'' チェックされているインデックスを取得 Console.WriteLine(StrDup(50, "="c)) Console.WriteLine("チェックされているインデックス数:" & Me.CheckedListBox1.CheckedIndices.Count.ToString()) For Each checkedlistitm As Object In Me.CheckedListBox1.CheckedIndices 'CheckedListBox.CheckedIndexCollection 'Checked または Indeterminate である項目だけ Console.WriteLine(Convert.ToString(checkedlistitm)) Next
'' チェックされていないアイテムを取得 Console.WriteLine(StrDup(50, "="c)) Dim uncheckedCount As Integer For index As Integer = 0 To Me.CheckedListBox1.Items.Count - 1 If Me.CheckedListBox1.GetItemCheckState(index) = CheckState.Unchecked Then Console.WriteLine(Convert.ToString(Me.CheckedListBox1.Items(index))) uncheckedCount += 1 End If Next Console.WriteLine("チェックされていないアイテム数:" & uncheckedCount.ToString())
'' 項目選択されているアイテムを取得 Console.WriteLine(StrDup(50, "="c)) Console.WriteLine("項目選択されているアイテム数:" & Me.CheckedListBox1.SelectedItems.Count.ToString()) For Each selectedlistitm As Object In Me.CheckedListBox1.SelectedItems 'ListBox.SelectedObjectCollection Console.WriteLine(Convert.ToString(selectedlistitm)) Next
'' 項目選択されているアイテムを取得 Console.WriteLine(StrDup(50, "="c)) Console.WriteLine("項目選択されているインデックス数:" & Me.CheckedListBox1.SelectedIndices.Count.ToString()) For Each selectedIndex As Integer In Me.CheckedListBox1.SelectedIndices 'ListBox.SelectedIndexCollection 'Checked または Indeterminate である項目だけ Console.WriteLine(Convert.ToString(selectedIndex)) Next End Sub End Class

投稿日時 : 2006年12月12日 14:01

Feedback

# Articles like these put the consumer in the direvr seat-very important. 2012/01/28 2:00 Janaya

Articles like these put the consumer in the direvr seat-very important.

# Articles like these put the consumer in the direvr seat-very important. 2012/01/28 2:00 Janaya

Articles like these put the consumer in the direvr seat-very important.

# As the admin of this web site is working, no doubt very rapidly it will be well-known, due to its quality contents. 2019/05/03 17:49 As the admin of this web site is working, no doubt

As the admin of this web site is working, no doubt very rapidly it will
be well-known, due to its quality contents.

# Hello this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I'm starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience. Any help would 2019/07/24 10:38 Hello this is kind of of off topic but I was wonde

Hello this is kind of of off topic but I was wondering if blogs
use WYSIWYG editors or if you have to manually code with HTML.
I'm starting a blog soon but have no coding knowledge so I wanted to get guidance from someone
with experience. Any help would be greatly appreciated!

# Hello this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I'm starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience. Any help would 2019/07/24 10:39 Hello this is kind of of off topic but I was wonde

Hello this is kind of of off topic but I was wondering if blogs
use WYSIWYG editors or if you have to manually code with HTML.
I'm starting a blog soon but have no coding knowledge so I wanted to get guidance from someone
with experience. Any help would be greatly appreciated!

# Hello this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I'm starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience. Any help would 2019/07/24 10:40 Hello this is kind of of off topic but I was wonde

Hello this is kind of of off topic but I was wondering if blogs
use WYSIWYG editors or if you have to manually code with HTML.
I'm starting a blog soon but have no coding knowledge so I wanted to get guidance from someone
with experience. Any help would be greatly appreciated!

# Hello this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I'm starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience. Any help would 2019/07/24 10:41 Hello this is kind of of off topic but I was wonde

Hello this is kind of of off topic but I was wondering if blogs
use WYSIWYG editors or if you have to manually code with HTML.
I'm starting a blog soon but have no coding knowledge so I wanted to get guidance from someone
with experience. Any help would be greatly appreciated!

# Attractive component of content. I simply stumbled upon your web site and in accession capital to claim that I acquire actually loved account your weblog posts. Anyway I'll be subscribing for your augment or even I fulfillment you get admission to const 2019/08/14 22:32 Attractive component of content. I simply stumbled

Attractive component of content. I simply stumbled upon your
web site and in accession capital to claim that I acquire actually loved
account your weblog posts. Anyway I'll be subscribing for your augment
or even I fulfillment you get admission to constantly rapidly.

# I was suggested this web site by my cousin. I'm not sure whether this post is written by him as nobody else know such detailed about my problem. You're incredible! Thanks! 2019/08/24 11:31 I was suggested this web site by my cousin. I'm no

I was suggested this web site by my cousin. I'm not sure whether this
post is written by him as nobody else know such detailed about my
problem. You're incredible! Thanks!

# FSTOOrNYgXiXHbS 2021/07/03 3:20 https://amzn.to/365xyVY

Only a smiling visitor here to share the love (:, btw great design and style.

# is erectile dysfunction secondary to ptsd 2021/07/07 19:15 hcqs tablet

hydroxochloriquine https://plaquenilx.com/# what are the side effects of hydroxychloroquine

# re: CheckedListBox(System.Windows.Forms.CheckedListBox) 2021/07/14 14:23 hydrochloroquine

cloraquinn https://chloroquineorigin.com/# is hydroxychloroquine quinine

# re: CheckedListBox(System.Windows.Forms.CheckedListBox) 2021/07/24 17:56 hydroxychloroquine

chloroguine https://chloroquineorigin.com/# hydroxychloroquine meaning

# Reloj casio digital, hay que ponerle la pila, funcionaba perfectamente el día que lo deje en un cajón. 2021/10/13 17:22 Reloj casio digital, hay que ponerle la pila, func

Reloj casio digital, hay que ponerle la pila, funcionaba perfectamente el día que lo deje en un cajón.

# Reloj casio digital, hay que ponerle la pila, funcionaba perfectamente el día que lo deje en un cajón. 2021/10/13 17:25 Reloj casio digital, hay que ponerle la pila, func

Reloj casio digital, hay que ponerle la pila, funcionaba perfectamente el día que lo deje en un cajón.

# Reloj casio digital, hay que ponerle la pila, funcionaba perfectamente el día que lo deje en un cajón. 2021/10/13 17:28 Reloj casio digital, hay que ponerle la pila, func

Reloj casio digital, hay que ponerle la pila, funcionaba perfectamente el día que lo deje en un cajón.

# Filtra por productos libres en los Centros de Distribución de MTY y CDMX para envíos nacionales salvo Tijuana y Mexicali. 2021/11/15 0:11 Filtra por productos libres en los Centros de Dist

Filtra por productos libres en los Centros de Distribución de MTY y CDMX para envíos
nacionales salvo Tijuana y Mexicali.

# By using this site, a person agree to the Terms of Use and Privacy Policy. 2021/11/15 7:16 By using this site, a person agree to the Terms of

By using this site, a person agree to the Terms
of Use and Privacy Policy.

# O frete grátis está sujeito ao peso, custo e distância do envio. 2023/11/17 9:59 O frete grátis está sujeito ao peso, cus

O frete grátis está sujeito ao peso, custo e distância do envio.

# Este 1er reloj digital ze presentó bajo este nombre de Casiotron y disponía en este momento en aquel luego de 10 útiles funciones adicionales. 2023/12/08 0:35 Este 1er reloj digital ze presentó bajo este

Este 1er reloj digital ze presentó bajo este nombre de Casiotron y
disponía en este momento en aquel luego de 10
útiles funciones adicionales.

# Quaisquer pedidos efetuados estão sujeitos à confirmação da disponibilidade de elemento em nosso estoque. 2023/12/23 7:55 Quaisquer pedidos efetuados estão sujeitos &#

Quaisquer pedidos efetuados estão sujeitos à confirmação da
disponibilidade de elemento em nosso estoque.

タイトル  
名前  
Url
コメント