的OleDb / OleDbConnection的尺寸变换形式(错误?) [英] OleDb / OleDbConnection resizing form (bug?)

查看:182
本文介绍了的OleDb / OleDbConnection的尺寸变换形式(错误?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的人可以用一​​个问题,我似乎无法化解帮助。我创建了两个C#的形式表达VSE2012桌面和VSE2013表达对桌面,在那里我已经离开了表格的默认大小,完全重新添加一个按钮默认值。按钮是编码以打开和关闭一个数据库连接。



当按钮被点击的形式及其内容全部由约25%萎缩,我已经尝试了所有的默认没有快乐的设置。我甚至取代的Access数据库文件的文本文件,它仍然会发生。试过这两个窗口7和8.1



Form1.cs中(所有的代码)

 <上code>使用系统; 
使用System.Collections.Generic;
使用System.ComponentModel;
使用System.Data这;
使用System.Drawing中;
使用System.Linq的;
使用System.Text;使用System.Threading.Tasks
;使用System.Windows.Forms的
;
使用System.Data.OleDb;

命名空间WindowsFormsApplication2
{

公共部分Form1类:表格
{
公共Form1中()
{
的InitializeComponent();
}

的OleDbConnection的myconn =新的OleDbConnection(供应商= Microsoft.ACE.OLEDB.12.0;
+ @数据源=
+ @。 .\..\..\x.accdb);



私人无效的button1_Click(对象发件人,EventArgs五)
{

{

的myconn 。打开();
myConn.Close();
}
赶上(异常前)
{
MessageBox.Show(ex.Message);
}
}
}
}



Uneditted Form1.Designer.cs

  #region Windows窗体设计器生成的代码

///<总结> ;
///设计器支持所需的方法 - 不要修改
///此方法的代码编辑器的内容。
///< /总结>
私人无效的Ini​​tializeComponent()
{
this.button1 =新System.Windows.Forms.Button();
this.SuspendLayout();
//
//按钮1
//
this.button1.Location =新System.Drawing.Point(106,138);
this.button1.Name =Button1的;
this.button1.Size =新System.Drawing.Size(75,23);
this.button1.TabIndex = 0;
this.button1.Text =Button1的;
this.button1.UseVisualStyleBackColor = TRUE;
this.button1.Click + =新System.EventHandler(this.button1_Click);
//
// Form1中
//
this.AutoScaleDimensions =新System.Drawing.SizeF(8F,16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize =新System.Drawing.Size(282,253);
this.Controls.Add(this.button1);
this.Name =Form1的;
this.Text =Form1的;
this.ResumeLayout(假);

}

#endregion


解决方案

这必须是一个的OleDb或.NET的bug。只有在非常高的分辨率的屏幕,并呼吁OleDb.OleDbConnection.Open简单的行为明显导致忽略任何DPI或字体缩放的形式。



我试过。移动电话打开的OleDb到一个单独的类,并以一个单独的DLL,但结果都是一样的。



一个用户在YouTube网站上的例子在这里:< A HREF =htt​​ps://www.youtube.com/watch?v=zdby6gmbX_4相对=nofollow> https://www.youtube.com/watch?v=zdby6gmbX_4



我想我们只是需要将其报告给MS



*****找到一种方法来解决它



如果你卸载Microsoft Access数据库引擎2010可再发行的32位版本,然后安装64位版本。然后,您卸载64位版本,然后重新安装32位版本,它现在的工作。


Can someone help with a problem I can't seem to resolve. I have created a C# form in both VSE2012 express for desktop and VSE2013 express for Desktop, where i have left the form the default size and added one button again totally default. The button is coded to open and close a db connection.

When the button is clicked the form and its contents all shrink by about 25%, i have tried all the default setting with no joy. I even substituted the access db file for a text file and it still happens. Tried this on both window 7 and 8.1

Form1.cs (all the code)

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);
            }
        }
    }
}

Uneditted 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

解决方案

This must be a OleDb or .NET bug. It is only noticeable on very high resolution screens and the simple act of calling OleDb.OleDbConnection.Open causes the form to ignore any DPI or Font scaling.

I've tried moving the call to open the OleDb to a separate class and also to a separate DLL but the results are always the same.

A user posted an example on YouTube here: https://www.youtube.com/watch?v=zdby6gmbX_4

I guess we'll just need to report it to MS

***** Found a way to fix it

If you uninstall the "Microsoft Access Database Engine 2010 Redistributable" 32 bit version and then install the 64 bit version. You then uninstall the 64 bit version and then reinstall the 32 bit version it will now work

这篇关于的OleDb / OleDbConnection的尺寸变换形式(错误?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆