有人可以帮助解决我似乎无法解决的问题吗?我在适用于桌面的 VSE2012 Express 和适用于桌面的 VSE2013 Express 中创建了一个 C# 表单,其中我将表单保留为默认大小,并再次完全默认添加了一个按钮。该按钮被编码为打开和关闭数据库连接。
当单击按钮时,表单及其内容全部缩小约 25%,我尝试了所有默认设置,但没有任何乐趣。我什至将访问数据库文件替换为文本文件,但这种情况仍然发生。在窗口 7 和 8.1 上都尝试过此操作
Form1.cs(所有代码)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection myConn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;"
+ @"Data Source="
+ @"..\..\..\x.accdb");
private void button1_Click(object sender, EventArgs e)
{
try
{
myConn.Open();
myConn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
未编辑的 Form1.Designer.cs
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(106, 138);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(282, 253);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
这一定是 OleDb 或 .NET 错误。它仅在非常高分辨率的屏幕上才明显,并且调用 OleDb.OleDbConnection.Open 的简单操作会导致表单忽略任何 DPI 或字体缩放。
我尝试将打开 OleDb 的调用移至单独的类和单独的 DLL,但结果始终相同。
一位用户在 YouTube 上发布了一个示例:https://www.youtube.com/watch?v=zdby6gmbX_4
我想我们只需要向 MS 报告即可
***** 找到了修复的方法
如果卸载“Microsoft Access Database Engine 2010 Redistributable”32 位版本,然后安装 64 位版本。然后卸载 64 位版本,然后重新安装 32 位版本,现在就可以使用了
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)