这是与前一个问题相关的问题。
基本上我有两种形式,我想从第一种形式跳到第二种形式。第一种形式的代码。
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Edit_Metric Edit_Metric = new Edit_Metric();
Edit_Metric.Show();
}
}
第二种形式:
public partial class Edit_Metric : Form
{
BindingSource bsource = new BindingSource();
DataSet ds = new DataSet();
private SqlDataAdapter da;
public Edit_Metric()
{
InitializeComponent();
}
private string connString = ConfigurationManager.ConnectionStrings["QISConnectionString"].ConnectionString;
private void Edit_Metric_Load(object sender, EventArgs e)
{
dgv.EditMode = DataGridViewEditMode.EditOnKeystroke;
DataGridViewButtonColumn EditColumn = new DataGridViewButtonColumn();
EditColumn.Text = "Edit";
EditColumn.Name = "Edit";
EditColumn.DataPropertyName = "Edit";
EditColumn.DisplayIndex = 0;
EditColumn.UseColumnTextForButtonValue = true;
DataGridViewButtonColumn DelColumn = new DataGridViewButtonColumn();
DelColumn.Text = "Delete";
DelColumn.Name = "Delete";
DelColumn.DataPropertyName = "Delete";
DelColumn.DisplayIndex = 1;
DelColumn.UseColumnTextForButtonValue = true;
dgv.Columns.Add(EditColumn);
dgv.Columns.Add(DelColumn);
using (SqlConnection conn = new SqlConnection("connString"))
{
conn.Open();
// data query, display data in a datagridview.
}
我的问题是:当代码到达
using (SqlConnection conn = new SqlConnection("connString"))
下一步代码立即转到第一个表单
Edit_Metric.Show();
它永远不会进入第二种形式的代码
conn.Open();
谢谢