c# - 当我运行代码时,Windows 窗体未在 csharp 中显示
问题描述
我正在使用访问创建一个数据库,突然间,当我运行代码时,我的表单没有显示。不久前它还在显示表单,但现在不是了。顺便说一句,我没有接触或弄乱 program.cs 文件。下面是program.cs文件:
namespace P1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
如果有帮助,下面是我的数据库代码。我什至削减了一些代码,但它根本没有显示表单。但是,它表明程序的构建没有错误。
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 P1
{
public partial class Form1 : Form
{
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source =d:\DDBS.mdb");
OleDbDataAdapter adap = new OleDbDataAdapter(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source =d:\DDBS.mdb","select * from Student");
DataTable d2 = new DataTable();
DataSet d1 = new DataSet("Student");
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dDBSDataSet.Student' table. You can move, or remove it, as needed.
//this.studentTableAdapter.Fill(this.dDBSDataSet.Student);
}
private void display_btn_Click(object sender, EventArgs e)
{
adap.Fill(d2);
dataGrid3.DataSource = d2;
}
private void dataGrid1_Navigate(object sender, NavigateEventArgs ne)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
private void form2_btn_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Show();
}
private void button3_Click_1(object sender, EventArgs e)
{
Form3 f3 = new Form3();
f3.Show();
}
private void button4_Click(object sender, EventArgs e)
{
Form4 f4 = new Form4();
f4.Show();
}
private void next_btn_Click(object sender, EventArgs e)
{
}
private void dataGrid2_Navigate(object sender, NavigateEventArgs ne)
{
}
private void dataGrid3_Navigate(object sender, NavigateEventArgs ne)
{
}
}
}
表单的设置输出类型:
解决方案
我认为您的问题是您的设置输出类型是控制台应用程序或类库。您应该更改为申请表。
推荐阅读
- hibernate - OneToOne 单向映射到复合键中的一列
- javascript - 异步函数冻结 ui
- javascript - 您如何通过单击成帧器运动为菜单设置动画?
- json - Flutter:如何使用 GetX 包从 List 生成 json 文件
- php - Laravel - 仅对某些特定值进行分组
- javascript - 反应:无法使用 API 读取未定义的属性“地图”
- java - 启动 Spring Boot/Spring Security 应用程序时,如何修复“无法将 JdbcUserDetailsManagerConfigurer 应用于已构建的对象”错误消息?
- firebase - 我如何专门查询firebase实时数据库中的字段
- php - 路线 [posts.index] 未定义
- node.js - 护照身份验证和重定向遇到问题