请教,在DataGrid的一个列中,怎样让它的一列变成有Combobox的效果.

sf8989 2005-07-18 09:34:40
请教,在DataGrid的一个列中,怎样让它的一列变成有Combobox的效果.

就是: DATAGRID1.Columns(0).DropDown= ?

让它等于什么才可以正确运行且有COMBOBOX的效果.

或是能做到相似效果的也行

帮帮忙
...全文
186 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
shilei831115 2005-07-19
  • 打赏
  • 举报
回复
挺难的
因为datagrid是很重要的
sf8989 2005-07-19
  • 打赏
  • 举报
回复
有没有简单点的方法
sf8989 2005-07-19
  • 打赏
  • 举报
回复
唉,惨死了,看了半个钟,还不知道主要技术点在那里,看不太懂
LiloZhu 2005-07-19
  • 打赏
  • 举报
回复
ComboBox,DateTimePicker在DataGrid 中的運用(C#)...
http://blog.csdn.net/zwxrain/archive/2005/01/19/259100.aspx

ComboBox,DateTimePicker在DataGrid 中的運用(VB.NET)...
http://blog.csdn.net/zwxrain/archive/2005/01/19/258998.aspx
miaojx 2005-07-19
  • 打赏
  • 举报
回复
This sample just attempts to replace the TextBox member of DataGridTextBoxColumn with a standard ComboBox member. Only two overrides need to be handled along with 2 events to get a functional implementation.

Here are the notes from the code that list the 3 steps to add a combobox to your 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;

16,553

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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