Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 如何在visual studio 2015中检查列表框的值_Wpf_Visual Studio - Fatal编程技术网

Wpf 如何在visual studio 2015中检查列表框的值

Wpf 如何在visual studio 2015中检查列表框的值,wpf,visual-studio,Wpf,Visual Studio,我正在使用visualbasic 我有一个大约10-12个值的列表框。我很好奇如何检查所选的值 我所要做的就是根据列表框中的选定值更改图像源 Dim I As Long Dim msg As String If ListBox1.ListIndex <> -1 Then For I = 0 To ListBox1.ColumnCount - 1 msg = msg & ListBox1.Column(I) & vbCr

我正在使用visualbasic

我有一个大约10-12个值的列表框。我很好奇如何检查所选的值

我所要做的就是根据列表框中的选定值更改图像源

Dim I As Long
Dim msg As String

    If ListBox1.ListIndex <> -1 Then
        For I = 0 To ListBox1.ColumnCount - 1
            msg = msg & ListBox1.Column(I) & vbCrLf
        Next I
    End If

    MsgBox msg
以下是我目前掌握的代码:

    ' For Each item As ListItem In lstBox.Items 
      If item.Value = "My Value" 
      lblNumber.Content = "$123"
      End If  
      Next

如果我正确理解您的问题,您可以使用以下代码:

Private Sub Button_Click()
If ListBox.ListIndex <> -1 Then MsgBox ListBox.Value
End Sub
Private子按钮\u Click()
如果ListBox.ListIndex为-1,则为MsgBox ListBox.Value
端接头
但是,如果我不明白,请告诉我

编辑:以下是您想要的吗?此代码应在列表框中显示所选值

Dim I As Long
Dim msg As String

    If ListBox1.ListIndex <> -1 Then
        For I = 0 To ListBox1.ColumnCount - 1
            msg = msg & ListBox1.Column(I) & vbCrLf
        Next I
    End If

    MsgBox msg
Dim I尽可能长
作为字符串的Dim msg
如果ListBox1.ListIndex为-1,则
对于ListBox1.ColumnCount-1的I=0
msg=msg&ListBox1.第(I)列和vbCrLf
接下来我
如果结束
MsgBox味精

如果我正确理解您的问题,您可以使用以下代码:

Private Sub Button_Click()
If ListBox.ListIndex <> -1 Then MsgBox ListBox.Value
End Sub
Private子按钮\u Click()
如果ListBox.ListIndex为-1,则为MsgBox ListBox.Value
端接头
但是,如果我不明白,请告诉我

编辑:以下是您想要的吗?此代码应在列表框中显示所选值

Dim I As Long
Dim msg As String

    If ListBox1.ListIndex <> -1 Then
        For I = 0 To ListBox1.ColumnCount - 1
            msg = msg & ListBox1.Column(I) & vbCrLf
        Next I
    End If

    MsgBox msg
Dim I尽可能长
作为字符串的Dim msg
如果ListBox1.ListIndex为-1,则
对于ListBox1.ColumnCount-1的I=0
msg=msg&ListBox1.第(I)列和vbCrLf
接下来我
如果结束
MsgBox味精

我试过那个代码,但没用。值显然不是ListBox的一部分。我要做的是让用户选择一个列表框。所以在我的屏幕上有一个图像和一个列表框。我想要的是,当用户从列表中选择一个项目时,我希望它更新图片。我道歉。你有没有试过的代码?当没有给出他们尝试过的例子时,很难对一个人的提问做出假设。我还假设您是用VBA编程的?对不起,我一般不熟悉编码。Visual Studio和VBA之间有区别吗?我正在使用“Visual Studio 2015 Express”程序,如果有帮助,我的项目将在Visual basic中使用WPF进行编码。我使用的是.NET Framework 4.5.2。Visual Studio是您运行的IDE。您的项目是用VBA编码的。如果您使用的是WPF,是否包括XAML?啊,对不起。我真的帮不了你太多了,因为我没有意识到这是在触摸XAML。然而,如果你向其他用户展示你的尝试,你更有可能得到更好的答案。值显然不是ListBox的一部分。我要做的是让用户选择一个列表框。所以在我的屏幕上有一个图像和一个列表框。我想要的是,当用户从列表中选择一个项目时,我希望它更新图片。我道歉。你有没有试过的代码?当没有给出他们尝试过的例子时,很难对一个人的提问做出假设。我还假设您是用VBA编程的?对不起,我一般不熟悉编码。Visual Studio和VBA之间有区别吗?我正在使用“Visual Studio 2015 Express”程序,如果有帮助,我的项目将在Visual basic中使用WPF进行编码。我使用的是.NET Framework 4.5.2。Visual Studio是您运行的IDE。您的项目是用VBA编码的。如果您使用的是WPF,是否包括XAML?啊,对不起。我真的帮不了你太多了,因为我没有意识到这是在触摸XAML。然而,如果你向其他用户展示你的尝试,你更有可能得到更好的答案。