怎样在DataGrid中加入checkBox 5.11 How can I put a checkbox in a column of my DataGrid? http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q754q 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 参考如下代码:// Step 1. Derive a custom column style from DataGridTextBoxColumn // a) add a ComboBox member // b) track when the combobox has focus in Enter and Leave events // c) override Edit to allow the ComboBox to replace the TextBox // d) override Commit to save the changed data // Step 2 - Use the combo column style // Add 1 col with combo style DataGridComboBoxColumn ComboTextCol = new DataGridComboBoxColumn(); ComboTextCol.MappingName = "custCity"; ComboTextCol.HeaderText = "Customer Address"; ComboTextCol.Width = 100; ts1.GridColumnStyles.Add(ComboTextCol); // Step 3 - Additional setup for Combo style // a) make the row height a little larger to handle minimum combo height ts1.PreferredRowHeight = ComboTextCol.ColumnComboBox.Height + 3; // b) Populate the combobox somehow. It is a normal combobox, so whatever... ComboTextCol.ColumnComboBox.Items.Clear(); ComboTextCol.ColumnComboBox.Items.Add("Chicago"); ComboTextCol.ColumnComboBox.Items.Add("Corvallis"); ComboTextCol.ColumnComboBox.Items.Add("Denver"); ComboTextCol.ColumnComboBox.Items.Add("Great Falls"); ComboTextCol.ColumnComboBox.Items.Add("Kansas City"); ComboTextCol.ColumnComboBox.Items.Add("Los Angeles"); ComboTextCol.ColumnComboBox.Items.Add("Raleigh"); ComboTextCol.ColumnComboBox.Items.Add("Washington"); // c) set the dropdown style of the combo... ComboTextCol.ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDownList; // Step 1. Derive a custom column style from DataGridTextBoxColumn // a) add a ComboBox member // b) track when the combobox has focus in Enter and Leave events // c) override Edit to allow the ComboBox to replace the TextBox // d) override Commit to save the changed data // Step 2 - Use the combo column style // Add 1 col with combo style DataGridComboBoxColumn ComboTextCol = new DataGridComboBoxColumn(); ComboTextCol.MappingName = "custCity"; ComboTextCol.HeaderText = "Customer Address"; ComboTextCol.Width = 100; ts1.GridColumnStyles.Add(ComboTextCol); // Step 3 - Additional setup for Combo style // a) make the row height a little larger to handle minimum combo height ts1.PreferredRowHeight = ComboTextCol.ColumnComboBox.Height + 3; // b) Populate the combobox somehow. It is a normal combobox, so whatever... ComboTextCol.ColumnComboBox.Items.Clear(); ComboTextCol.ColumnComboBox.Items.Add("Chicago"); ComboTextCol.ColumnComboBox.Items.Add("Corvallis"); ComboTextCol.ColumnComboBox.Items.Add("Denver"); ComboTextCol.ColumnComboBox.Items.Add("Great Falls"); ComboTextCol.ColumnComboBox.Items.Add("Kansas City"); ComboTextCol.ColumnComboBox.Items.Add("Los Angeles"); ComboTextCol.ColumnComboBox.Items.Add("Raleigh"); ComboTextCol.ColumnComboBox.Items.Add("Washington"); // c) set the dropdown style of the combo... ComboTextCol.ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDownList; 关于asp服务器控件转最终转化为HTML标签的规律,求帮忙归纳。 C#高级编程看完了之后是那一本?类库方向的,不要asp方向 怎样在textbox输入中,敲入回车时执行某个函数? 请教 跨Appdomain传值 的问题 求助!!! 关于cab的问题,熟悉的人请进来讨论一下,重谢 lumisoft mail 服务器 设置 求VS.2003的下载地址 请问C#中有没有延时函数?????????????? 实现这样的效果怎么做呀 如何使程序支持插件 DataGrid怎样进行选中操作
// Step 1. Derive a custom column style from DataGridTextBoxColumn
// a) add a ComboBox member
// b) track when the combobox has focus in Enter and Leave events
// c) override Edit to allow the ComboBox to replace the TextBox
// d) override Commit to save the changed data
// Step 2 - Use the combo column style
// Add 1 col with combo style
DataGridComboBoxColumn ComboTextCol = new DataGridComboBoxColumn();
ComboTextCol.MappingName = "custCity";
ComboTextCol.HeaderText = "Customer Address";
ComboTextCol.Width = 100;
ts1.GridColumnStyles.Add(ComboTextCol);
// Step 3 - Additional setup for Combo style
// a) make the row height a little larger to handle minimum combo height
ts1.PreferredRowHeight = ComboTextCol.ColumnComboBox.Height + 3;
// b) Populate the combobox somehow. It is a normal combobox, so whatever...
ComboTextCol.ColumnComboBox.Items.Clear();
ComboTextCol.ColumnComboBox.Items.Add("Chicago");
ComboTextCol.ColumnComboBox.Items.Add("Corvallis");
ComboTextCol.ColumnComboBox.Items.Add("Denver");
ComboTextCol.ColumnComboBox.Items.Add("Great Falls");
ComboTextCol.ColumnComboBox.Items.Add("Kansas City");
ComboTextCol.ColumnComboBox.Items.Add("Los Angeles");
ComboTextCol.ColumnComboBox.Items.Add("Raleigh");
ComboTextCol.ColumnComboBox.Items.Add("Washington");
// c) set the dropdown style of the combo...
ComboTextCol.ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
// a) add a ComboBox member
// b) track when the combobox has focus in Enter and Leave events
// c) override Edit to allow the ComboBox to replace the TextBox
// d) override Commit to save the changed data
// Step 2 - Use the combo column style
// Add 1 col with combo style
DataGridComboBoxColumn ComboTextCol = new DataGridComboBoxColumn();
ComboTextCol.MappingName = "custCity";
ComboTextCol.HeaderText = "Customer Address";
ComboTextCol.Width = 100;
ts1.GridColumnStyles.Add(ComboTextCol);
// Step 3 - Additional setup for Combo style
// a) make the row height a little larger to handle minimum combo height
ts1.PreferredRowHeight = ComboTextCol.ColumnComboBox.Height + 3;
// b) Populate the combobox somehow. It is a normal combobox, so whatever...
ComboTextCol.ColumnComboBox.Items.Clear();
ComboTextCol.ColumnComboBox.Items.Add("Chicago");
ComboTextCol.ColumnComboBox.Items.Add("Corvallis");
ComboTextCol.ColumnComboBox.Items.Add("Denver");
ComboTextCol.ColumnComboBox.Items.Add("Great Falls");
ComboTextCol.ColumnComboBox.Items.Add("Kansas City");
ComboTextCol.ColumnComboBox.Items.Add("Los Angeles");
ComboTextCol.ColumnComboBox.Items.Add("Raleigh");
ComboTextCol.ColumnComboBox.Items.Add("Washington");
// c) set the dropdown style of the combo...
ComboTextCol.ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDownList;