如何在DataGridView中添加控件?使用按鈕事件。例如,我想在DataGridView中創建一個新的行和列,這個我想通過按鈕控件來實現。我該怎麼做? 我使用C#.net和MS-Access。在Datagridview中添加控件
-1
A
回答
0
下面是一段用於將控件添加到gridview的代碼。
私人無效addNewRowButton_Click(對象發件人,EventArgs的) {
this.DataGridViewIssue.Rows.Add();//This line will add a new button contol into the grid
}
private void deleteRowButton_Click(object sender, EventArgs e)
{
if (this.DataGridViewIssue.SelectedRows.Count > 0 &&
this.DataGridViewIssue.SelectedRows[0].Index !=
this.DataGridViewIssue.Rows.Count - 1)
{
this.DataGridViewIssue.Rows.RemoveAt(
this.DataGridViewIssue.SelectedRows[0].Index);
}
}
private void SetupLayout()
{
this.Size = new Size(1055, 800);
addNewRowButton.Text = "Add Row";
addNewRowButton.Location = new Point(10, 10);
addNewRowButton.Click += new EventHandler(addNewRowButton_Click);
deleteRowButton.Text = "Delete Row";
deleteRowButton.Location = new Point(100, 10);
deleteRowButton.Click += new EventHandler(deleteRowButton_Click);
buttonPanel.Controls.Add(addNewRowButton);
buttonPanel.Controls.Add(deleteRowButton);
buttonPanel.Height = 50;
buttonPanel.Dock = DockStyle.Bottom;
this.Controls.Add(this.buttonPanel);
}
1
相關問題
- 1. 如何使用VS2015添加DataGridView控件?
- 2. 在datagridview c中添加值#
- 3. C#在DataGridView中添加行
- 4. 如何在面板vb.net上添加DatagridView控件數組?
- 5. datagridview添加行
- 6. 如何在Windows C#中的DataGridView中添加遮罩文本框控件?
- 7. 如何從用戶控件添加行到dataGridView
- 8. DataGridView控件處於虛擬模式時無法添加行?
- 9. 將列添加到屬於自定義用戶控件的DataGridView
- 10. 在Datagridview中添加一個下拉框
- 11. 基於numericupdown在DataGridView中添加行
- 12. WinForm/C# - 在DataGridView中添加數據
- 13. 在Vb.net添加記錄中的DataGridView行
- 14. 添加行到datagridview
- 15. 向DataGridView添加行
- 16. Tab控件+ WinForms中的DataGridView
- 17. 在datagridView中添加按鈕現在工作onClick事件
- 18. 在C#中動態添加控件
- 19. 在ASP.NET Repeater中動態添加控件
- 20. 動態地在gridview中添加控件
- 21. 在Silverlight Datagrid中添加一行控件
- 22. 添加控件在回發中丟失
- 23. 如何在vb.net中添加控件?
- 24. 在ItemsControl中添加不同的控件
- 25. 在RadGridview控件中添加行
- 26. ASP.NET在回發中添加控件
- 27. 在ServerControl標籤中添加子控件?
- 28. 添加文本CheckBox控件在JQuery中
- 29. 在循環中添加控件(Picturebox)
- 30. 添加UITabBar控件!
添加控制並不一定意味着簡單地增加一個行/列。 – 2015-06-29 06:13:15