datagrid控件的问题?

zxd35 2003-08-23 09:41:09
在datagrid控件中显示列标题,下面显示空白的网格,某些列可以为其他控件,例如combobox控件,在这些空白的网格中可以输入一些内容,可以在某一行下面插入一行,也可以删除一行,输入完成后,把这些网格中的内容写入到文件中去,datagrid控件不和任何数据库相连接,这个问题如何解决??万分感谢!!!
...全文
28 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
雪狼1234567 2003-08-23
  • 打赏
  • 举报
回复
combobox添加代码:
// 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;


zxd35 2003-08-23
  • 打赏
  • 举报
回复
xml如何使用?能给讲解一下吗?
cnhgj 2003-08-23
  • 打赏
  • 举报
回复
如果不和数据库连接的话,那么用xml,然后用DataSet绑定!要保存的时候用
StreamWriter myStreamWriter = new StreamWriter(xmlFilename);
DataSet1.WriteXml(myStreamWriter);

110,532

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧