winform 表格问题。能不用第三方吗

无极限冰红茶 2017-07-11 11:32:27

请问能否实现这样的效果。名称固定的就好了。我这边的话,是用datagridview控件来实现的。但是那个下拉框的时间不会弄。另一个下拉框文字的也有问题。需要点击两三次才反应过来。能否帮我解决下
...全文
447 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
无极限冰红茶 2017-07-14
  • 打赏
  • 举报
回复
很感谢回复。现在基本功能实现了。我还得改改一些东西,会觉得有点bug。我弄好了到时发出来让大家提提意见。我也是刚学两个月,所以很多不懂,向大家多学习请教了~~~
threenewbee 2017-07-12
  • 打赏
  • 举报
回复
引用 7 楼 m0_37688683 的回复:
[quote=引用 4 楼 wang_peng_yl 的回复:] 用PropertyGrid就可以, 但感觉对楼主有难度, DataGrid也可以搞定的,对楼主更有难度 所以比较一下,还是用PropertyGrid吧
请问你说的这两个控件是要钱的吗[/quote] 都是内置的,不要钱。PropertyGrid更符合lz的需要。
wang_peng_yl 2017-07-12
  • 打赏
  • 举报
回复
不建议用 DataGrid 去做,如果你已经做出来,那就用吧
OneCoderr 2017-07-12
  • 打赏
  • 举报
回复
学习了,收藏。
wang_peng_yl 2017-07-11
  • 打赏
  • 举报
回复
用PropertyGrid就可以, 但感觉对楼主有难度, DataGrid也可以搞定的,对楼主更有难度 所以比较一下,还是用PropertyGrid吧
zbdzjx 2017-07-11
  • 打赏
  • 举报
回复
PropertyGrid??
无极限冰红茶 2017-07-11
  • 打赏
  • 举报
回复
引用 1 楼 chuheiqian 的回复:
在表格控件编辑模式下,在你要的单元格里绘制你要的控件就行了
如果按照你的意思的话,那不得一列都是这样了、我这个只是某行某列才这样的
倒退一天 2017-07-11
  • 打赏
  • 举报
回复
在表格控件编辑模式下,在你要的单元格里绘制你要的控件就行了
无极限冰红茶 2017-07-11
  • 打赏
  • 举报
回复
只是添加了三句代码而已。 int i = 0; int j = 0; //定位到哪一行 if (dataGridView1.CurrentCell == dataGridView1.Rows[1].Cells[0]) 希望遇到和我一样问题的人,能解决到。
无极限冰红茶 2017-07-11
  • 打赏
  • 举报
回复
大概示例代码是这样的。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace TreeListtest { public partial class Form1 : Form { public Form1() { InitializeComponent(); dmg.Value = System.DateTime.Now; this.dataGridView1.Controls.Add(dmg); this.dataGridView1.Rows.Add("1", ""); this.dataGridView1.Rows.Add(DateTime.Now, "2"); this.dataGridView1.Rows.Add("3", "4"); this.dataGridView1.Rows.Add("3", "4"); dmg.Visible = true; } private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { try { int i = 0; int j = 0; if (this.dataGridView1.CurrentCell.ColumnIndex.ToString() == "0")//在此指定和哪一列绑定 { //定位到哪一行 if (dataGridView1.CurrentCell == dataGridView1.Rows[1].Cells[0]) { System.Drawing.Rectangle rect = dataGridView1.GetCellDisplayRectangle(dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex, false); dmg.Left = rect.Left; dmg.Top = rect.Top; dmg.Width = rect.Width; dmg.Height = rect.Height; dmg.Visible = true; i = this.dataGridView1.CurrentRow.Index; j = this.dataGridView1.CurrentCell.ColumnIndex; dataGridView1.CurrentCell.Value = dmg.Value; } } else { dmg.Visible = false; } } catch { } } } }
无极限冰红茶 2017-07-11
  • 打赏
  • 举报
回复
引用 8 楼 SomethingJack 的回复:
http://blog.csdn.net/e_zhiwen/article/details/11840203
非常感谢您发这个的帮助,我大概做出来效果的
SomethingJack 2017-07-11
  • 打赏
  • 举报
回复
http://blog.csdn.net/e_zhiwen/article/details/11840203
无极限冰红茶 2017-07-11
  • 打赏
  • 举报
回复
引用 4 楼 wang_peng_yl 的回复:
用PropertyGrid就可以, 但感觉对楼主有难度, DataGrid也可以搞定的,对楼主更有难度 所以比较一下,还是用PropertyGrid吧
请问你说的这两个控件是要钱的吗
无极限冰红茶 2017-07-11
  • 打赏
  • 举报
回复
引用 5 楼 xuzuning 的回复:
用 DataGridViewComboBoxCell 类,一点难度都没有 var gc = new DataGridViewComboBoxCell(); gc.DataSource = new List<string>() { "A", "B", "C" }; dataGridView1.Rows[0].Cells[1] = gc;
版主你说的这个我知道的,但是那个时间控件的下拉框请问你知道怎么弄 吗
xuzuning 2017-07-11
  • 打赏
  • 举报
回复
用 DataGridViewComboBoxCell 类,一点难度都没有
var gc = new DataGridViewComboBoxCell();
gc.DataSource = new List<string>() { "A", "B", "C" };
dataGridView1.Rows[0].Cells[1] = gc;

111,126

社区成员

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

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

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