Resources绑定到ComboBox
将Resources中的几个图片 绑定到ComboBox1
方便我运行时选择 怎么做?
[解决办法]
没人看见这个贴?
[解决办法]
有这么难?
[解决办法]
直接绑定我感觉 .. 我不会 你可以通过之判断然后拿图片和值绑定! 不知道可以不?
[解决办法]
你可以通过之判断然后拿图片和值绑定!??
[解决办法]
可能我说的不明白
Resources 有一些图片
我希望将他们的名字绑定到 ComboBox1 里边
然后通过 ComboBox1 来选择不同的图片
[解决办法]
好几天了
[解决办法]
该回复于2009-08-16 09:47:09被版主删除
[解决办法]
又过了两天
[解决办法]
'这段代码你参考下,看了半天ResourceSets ,ResourceReader 还是不太懂怎么用
Private Sub btnBulid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBulid.Click
Try
Dim rw As New Resources.ResourceWriter("res.resources")
With rw
.AddResource("100_5062", Image.FromFile("d:\My Documents\My Pictures\100_5062.jpg"))
'...
.AddResource("Name", "张三")
.Generate()
.Close()
End With
Catch ex As Exception
MsgBox("btnBulid_Click:" + ex.Message, MsgBoxStyle.Information, Me.Text)
End Try
End Sub
Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click
Try
Dim reader As New Resources.ResourceReader("res.resources")
Dim en As IDictionaryEnumerator = reader.GetEnumerator()
While en.MoveNext()
If en.Key = "100_5062" Then
Me.PictureBox1.Image = CType(en.Value, Image)
Exit While
End If
End While
reader.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Catch ex As Exception
MsgBox("Form1_Load:" + ex.Message, MsgBoxStyle.Information, Me.Text)
End Try
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbbChangePic.SelectedIndexChanged
If cbbChangePic.SelectedIndex = -1 Then
Else
Dim selectValue = cbbChangePic.SelectedItem.ToString.Trim
changePic(selectValue)
End If
End Sub