只需点击一下按钮即可更改面板

时间:2015-03-31 01:39:25

标签: vb.net button click panel

我正在制作一个程序,我正在添加一个实用程序表单,我有按钮和面板。 1个面板的1个按钮,所以如果他们点击按钮我有代码,而另一个面板可见则隐藏并显示另一个面板。出于某种原因,我必须单击该按钮两次才能更改为其他面板,不确定原因。

代码:

Private Sub btnAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbout.Click
    If pnlAbout.Visible = False Then
        pnlAbout.Visible = True
    Else
        If pnlProfile.Visible = True Then
            pnlProfile.Visible = False
            pnlAbout.Visible = True

            If pnlUpdates.Visible = True Then
                pnlUpdates.Visible = False
                pnlAbout.Visible = True
            End If
        End If
    End If
End Sub
Private Sub btnProfile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProfile.Click
    If pnlProfile.Visible = False Then
        pnlProfile.Visible = True
    Else
        If pnlAbout.Visible = True Then
            pnlAbout.Visible = False
            pnlProfile.Visible = True

            If pnlUpdates.Visible = True Then
                pnlUpdates.Visible = False
                pnlProfile.Visible = True
            End If
        End If
        End If
End Sub
Private Sub btnUpdates_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdates.Click
    If pnlUpdates.Visible = False Then
        pnlUpdates.Visible = True
    Else
        If pnlAbout.Visible = True Then
            pnlAbout.Visible = False
            pnlUpdates.Visible = True

            If pnlProfile.Visible = True Then
                pnlProfile.Visible = False
                pnlUpdates.Visible = True
            End If
        End If
    End If
End Sub

2 个答案:

答案 0 :(得分:1)

您的代码可归纳为:

Private Sub btnAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbout.Click
    pnlAbout.Visible = True
    pnlProfile.Visible = False
    pnlUpdates.Visible = False
End Sub
Private Sub btnProfile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProfile.Click
    pnlAbout.Visible = False
    pnlProfile.Visible = True
    pnlUpdates.Visible = False
End Sub
Private Sub btnUpdates_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdates.Click
    pnlAbout.Visible = False
    pnlProfile.Visible = False
    pnlUpdates.Visible = True
End Sub

您需要两次,因为第一次点击可以看到正确的面板,第二次(如果幸运的话)可见的那一面是不可见的。

答案 1 :(得分:0)

您的代码可以概括为:

_CompileToDalvikWithDx:
  C:\Program Files\Java\jdk1.8.0_102\\bin\java.exe -jar C:\java\androidsdk\android-sdk\tools\proguard\lib\proguard.jar -include C:\java\androidsdk\android-sdk\tools\proguard\proguard-android.txt -include obj\Release\proguard\proguard_xamarin.cfg -include obj\Release\proguard\proguard_project_references.cfg -include obj\Release\proguard\proguard_project_primary.cfg -include proguard.cfg "-injars 'obj\Release\proguard\__proguard_input__.jar';'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v7.0\mono.android.jar';'obj\Release\__library_projects__\FormsViewGroup\library_project_imports\formsviewgroup.jar';'obj\Release\__library_projects__\HockeySDK.AndroidBindings\library_project_imports\bin\classes.jar';'C:\Users\buildguest\AppData\Local\Xamarin\Xamarin.Android.Support.Animated.Vector.Drawable\23.3.0.0\embedded\classes.jar';'C:\Users\buildguest\AppData\Local\Xamarin\Xamarin.Android.Support.Design\23.3.0.0\embedded\classes.jar';'C:\Users\buildguest\AppData\Local\Xamarin\Xamarin.Android...
  java.io.IOException: Can't read [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v7.0\mono.android.jar] (Can't process class [android/app/ActivityTracker.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7)))
    at proguard.InputReader.readInput(InputReader.java:230)
    at proguard.InputReader.readInput(InputReader.java:200)
    at proguard.InputReader.readInput(InputReader.java:178)
    at proguard.InputReader.execute(InputReader.java:78)
    at proguard.ProGuard.readInput(ProGuard.java:196)
    at proguard.ProGuard.execute(ProGuard.java:78)
    at proguard.ProGuard.main(ProGuard.java:492)
  Caused by: java.io.IOException: Can't process class [android/app/ActivityTracker.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7))
    at proguard.io.ClassReader.read(ClassReader.java:112)
    at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
    at proguard.io.JarReader.read(JarReader.java:65)
    at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65)
    at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53)
    at proguard.InputReader.readInput(InputReader.java:226)
    ... 6 more
  Caused by: java.lang.UnsupportedOperationException: Unsupported class version number [52.0] (maximum 51.0, Java 1.7)
    at proguard.classfile.util.ClassUtil.checkVersionNumbers(ClassUtil.java:140)
    at proguard.classfile.io.ProgramClassReader.visitProgramClass(ProgramClassReader.java:88)
    at proguard.classfile.ProgramClass.accept(ProgramClass.java:346)
    at proguard.io.ClassReader.read(ClassReader.java:91)
    ... 11 more
  Picked up JAVA_TOOL_OPTIONS:  -Dfile.encoding=UTF8
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2025,3): Error MSB6006: "java.exe" exited with code 1.