gpt4 book ai didi

vb.net - 单击 "btnLogin"时,我的表单尺寸减小。

转载 作者:行者123 更新时间:2023-12-02 20:30:49 25 4
gpt4 key购买 nike

在我的登录表单上,每当单击“btnLogin”时,“frmLogin”和“frmMenu”的宽度和长度似乎都会减小。这是什么原因呢?你怎样才能解决它?我不知道这是否与代码有关,但无论如何我都会链接它。谢谢。

Imports System.Data.OleDb
Public Class frmLogin
Public AdminDetails As Boolean
Public SuccessfulLoginUsername As String
Dim provider As String
Dim dataFile As String
Dim connString As String
Dim myConnection As OleDbConnection = New OleDbConnection
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="

dataFile = Application.StartupPath & "\SAC1 Database.mdb"
connString = provider & dataFile
myConnection.ConnectionString = connString


Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM [tblUsers] WHERE [Username] = '" & txtUsername.Text & "' AND [Password] = '" & txtPassword.Text & "'", myConnection)
myConnection.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader
Dim userFound As Boolean = False
Dim FirstName As String = ""
Dim LastName As String = ""

While dr.Read
userFound = True
FirstName = dr("FirstName").ToString
LastName = dr("LastName").ToString
End While

If userFound = True Then
If txtUsername.Text = "admin" And txtPassword.Text = "password" Then
AdminDetails = True
SuccessfulLoginUsername = txtUsername.Text
Else
AdminDetails = False
SuccessfulLoginUsername = txtUsername.Text
End If
frmMenu.Show()
frmMenu.lblTitle.Text = "Welcome " & FirstName & " " & LastName
frmMenu.lblGreeting.Text = "Howdy! " & FirstName & " " & LastName & ". What would you like to do today?"
Else
MsgBox("Sorry, username or password not found", MsgBoxStyle.OkOnly, "Invalid Login")
End If
myConnection.Close()
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Close()
End
End Sub

Private Sub linklblCreateAccount_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles linklblCreateAccount.LinkClicked
frmCreateAccount.Show()
End Sub
End Class

最佳答案

这可能是 DPI 感知的问题。具体来说,您的应用程序未声明为 DPI 感知,并且当您的代码 Access Microsoft.ACE.OLEDB 提供程序时,其进程将设置为 DPI 感知。这是我不久前偶然发现的事情,但我从未见过其他人报告发生过这种情况。

简单的解决方案是让您的应用程序感知 DPI。

  1. 从“项目”菜单中,选择“您的项目名称”-“属性”。
  2. 选择“应用程序”选项卡,然后单击“查看窗口设置”按钮。
  3. 根据您的 VS 版本,文件中可能包含也可能不包含以下内容。
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->

如果找到此 block ,请删除第一行和最后一行(“< !--”和“-->”)。如果不存在,请在文件中最后一个标记之前添加这些行。

  • 重建您的应用程序。
  • 关于vb.net - 单击 "btnLogin"时,我的表单尺寸减小。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48272782/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com