##試した事
以前投稿したコードから改変しました。
##ソースコード
Form1
1 2Imports System.IO 3 Imports System 4 Imports System.Globalization 5 Imports System.Threading 6 7 Public Class Form1 8 9 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 10 If ListBox1.SelectedIndex = 0 Then 11 '新しいフォームです。 12 Form2.Show() 13 Me.Hide() 14 End If 15 End Sub 16End Class
Form2
1Imports System.ComponentModel 2Imports System.Globalization 3 4Public Class Form2 5 Private list As New Dictionary(Of String, Image)() 6 7 Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load 8 TextBox1.Enabled = False 9 list.Add("あ1", My.Resources.A00) 10 list.Add("あ2", My.Resources.A01) 11 list.Add("あ3", My.Resources.A02) 12 list.Add("い1", My.Resources.A03) 13 list.Add("い2", My.Resources.A04) 14 list.Add("い3", My.Resources.A05) 15 ComboBox1.DisplayMember = "Key" 16 ComboBox1.ValueMember = "Value" 17 ComboBox1.DataSource = New BindingSource(list, Nothing) 18 End Sub 19 Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged 20 TextBox1.Text = ComboBox1.GetItemText(ComboBox1.SelectedItem) 21 'PictureBox1.Image = TryCast(ComboBox1.SelectedValue, Image) 22 End Sub 23 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 24 PictureBox1.Image = TryCast(ComboBox1.SelectedValue, Image) 25 End Sub 26 Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged 27 Dim cca = New CultureInfo("ja-jp").CompareInfo 28 Dim opt As CompareOptions 29 opt = opt Or CompareOptions.IgnoreWidth '全角と半角を区別しない 30 opt = opt Or CompareOptions.IgnoreKanaType 'ひらがなとカタカナを区別しない 31 opt = opt Or CompareOptions.IgnoreCase '大文字と小文字を区別しない 32 opt = opt Or CompareOptions.IgnoreNonSpace '文字列比較で分音文字などの結合の分音文字を無視することを示します。 33 opt = opt Or CompareOptions.IgnoreSymbols '文字列の比較が空白文字が区切り記号、通貨記号、パーセント記号、数学記号、アンパサンド、やなどの記号を無視することを示します。 34 35 Dim txt As String = TextBox2.Text 36 37 ComboBox1.DataSource = List.Where( 38 Function(s) 39 Return 0 = cca.Compare(Strings.Left(s.Key, txt.Length), txt, opt) 40 End Function).ToArray() 41 42 End Sub 43 44 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click 45 Me.Hide() 46 Form1.Show() 47 End Sub 48End Class
コレクションのインスタンス?で文字入力、画像は表示させる事にしたのですか
##おしえて欲しいこと。
画像、文字入力、数字(番号)を追加したい事なのですが
Private list As New Dictionary(Of String, Image)()
これをもし
Private list As New Dictionary(Of String, Image'Integer)()
list (of String, Image'Integer)
にしたいんですが初心者なので頑張って努力して覚えようとしています。
どのように改変したらいいのでしょうか?
お願いいたします。
##バージョンなど
Vistualstudio2019
Vistual basic
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2019/03/18 15:00
2019/03/18 20:10
退会済みユーザー
2019/03/19 08:51