Verifiquei que há um erro havia o seguinte trecho de código do meu Form.Designer
this.StudentRecordDataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.StudentRecordDataGridView_CellContentClick);
após retirá-lo o meu formulário voltou a aparecer normalmente com o meu design. Agora estou com outro problema! :/
no meu Form1 estou com uma "System.InvalidOperationException: 'Instance failure.'" nesse trecho de código. Não sei mais o que fazer.
Segue o código:
Form1
using System;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
namespace CRUD_Operations
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
GetStudentsRecord();
}
private void GetStudentsRecord()
{
SqlConnection con = new SqlConnection(@"Data Source=LAPTOP-NO8RMH6C\\SQLSERVER2022;Initial Catalog=CrudTest;Integrated Security=True");
SqlCommand cmd = new SqlCommand("Select * from StudentsTb", con);
DataTable dt = new DataTable();
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
dt.Load(sdr);
con.Close();
StudentRecordDataGridView.DataSource = dt;
}
}
}
Parte do trecho que retirei no Form1.Designer
// StudentRecordDataGridView
//
this.StudentRecordDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.StudentRecordDataGridView.Location = new System.Drawing.Point(12, 233);
this.StudentRecordDataGridView.Name = "StudentRecordDataGridView";
this.StudentRecordDataGridView.RowTemplate.Height = 25;
this.StudentRecordDataGridView.Size = new System.Drawing.Size(597, 178);
this.StudentRecordDataGridView.TabIndex = 3;
//this.StudentRecordDataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.StudentRecordDataGridView_CellContentClick);
//