我试图创建一个更新按钮,让我将数据插入到gridview中,在创建课程后,按钮什么都不做,我不明白为什么会这样。
private void Basic()
{
// no updates allowed
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.ReadOnly = true;
//UpdateButton is available
UpdateButton.Enabled = true;
//Save and Cancel Unavailable
SaveButton.Visible = false;
CancelButton.Visible = false;
sTableAdapter.Fill(dataSet1.S);
}
这是UpdateButton事件
private void UpdateButton_Click(Object sender, EventArgs e)
{
dataGridView1.AllowUserToAddRows = true;
dataGridView1.AllowUserToDeleteRows = true;
dataGridView1.ReadOnly = false;
UpdateButton.Enabled = false;
SaveButton.Visible = true;
CancelButton.Visible = true;
}
这应该是更新类:
this.UpdateButton.Location = new System.Drawing.Point(12, 63);
this.UpdateButton.Name = "UpdateButton";
this.UpdateButton.Size = new System.Drawing.Size(103, 23);
this.UpdateButton.TabIndex = 0;
this.UpdateButton.Text = "Update";
this.UpdateButton.UseVisualStyleBackColor = true;
使用accdb建立连接。 更新按钮不是点击,我做错了什么?