当我在Visual Studio中运行程序时,为什么我的窗口形式会有所不同?

时间:2016-04-11 15:28:53

标签: c# winforms

我的window.cs [设计]看起来很好,我希望它看起来如何但是,一旦我运行我的程序,它看起来透明,模糊,模糊,太可怕了!我所有的其他窗户看起来都很棒,看起来就像是他们想要的样子。我在Windows 10上运行。我不知道这是计算机问题还是Visual Studio问题。我也使用Visual Studio 2012

这是我的设计窗口假设的样子

Design view

这是我执行程序后的样子

After executing

注意我的文本框变得透明,文本变得模糊/模糊。这是我使用的背景图片吗?这是我的设置吗?

我没有发布任何代码,因为这只是一个设计问题。

这是我的窗口代码:

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.SqlClient;

namespace LOGINPAGE
{
    public partial class Room : Form
    {
        public Room()
        {
            InitializeComponent();
            PassText.PasswordChar = '*';
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
            FloorSelection ss = new FloorSelection();
            ss.Show();

        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {

        }


        private void EXIT_Click(object sender, EventArgs e)
        {
            this.Close();
            Application.Exit();
        }

        private void xButton1_Click(object sender, EventArgs e)
        {



            SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Mohamed\Documents\UserData.mdf;Integrated Security=True;Connect Timeout=30");
            SqlDataAdapter sda = new SqlDataAdapter("Select Count (*) From dbo.[LOGIN] where username='" + UserText.Text + "' and Password ='" + PassText.Text + "'", con);
            FloorSelection ss = new FloorSelection();
            DataTable dt = new DataTable();
            sda.Fill(dt);
            if (dt.Rows[0][0].ToString() == "1")
            {
                SqlDataAdapter sda1 = new SqlDataAdapter("Select TYPE From dbo.[LOGIN] where username='" + UserText.Text + "' and Password ='" + PassText.Text + "'", con);
                FloorSelection ss1 = new FloorSelection();
                DataTable dt1 = new DataTable();


                sda1.Fill(dt1);
                if (dt1.Rows[0][0].ToString() == "FACULTY")
                {
                    this.Hide();
                    FACULTY ff = new FACULTY();
                    ff.Show();
                }

                if (dt1.Rows[0][0].ToString() == "JANITOR")
                {
                    this.Hide();
                    JANITOR jt = new JANITOR();
                    jt.Show();

                    if (dt1.Rows[0][0].ToString() == "ADMINISTRATOR")
                    {
                        this.Hide();
                        ADMINISTRATOR Admin = new ADMINISTRATOR();
                        Admin.Show();
                    }
                     else
                    {
                        MessageBox.Show("PLEASE CHECK YOUR USERNAME AND PASSWORD");
                    }

                }
            }
        }
        private void label3_Click(object sender, EventArgs e)
        {
            label3.BackColor = Color.Empty;
        }

        private void UserText_TextChanged(object sender, EventArgs e)
        {

        }

        private void PassText_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

1 个答案:

答案 0 :(得分:3)

看起来您的表单的TransparencyKey属性设置为白色。这意味着表单中的每个白色像素都将变为透明。这似乎与您所看到的视觉效果相匹配。

要关闭透明度,请将TransparencyKey设置为Color.Empty或在Visual Studio属性窗口中选择属性,然后按删除。