日期:2014-05-18  浏览次数:21132 次

关于两个DataGridview关联的问题
最近在做一个数据表字段录入功能,要用到两个DataGridView,一个编辑字段名称和类型,另一个编辑字段属性。
要实现的功能是点击一个字段,使该字段的属性自动关联到属性DataGridView中,并且可编辑,大家帮我提供下思路

------解决方案--------------------
参考:
//表格离行显示明细表数据
C# code private void dvw_main_RowEnter(object sender, DataGridViewCellEventArgs e)
{
try
{
if (this.dvw_main.SelectedRows.Count > 0)
{
DataSets.RFCardDataRow row = (this.dvw_main.SelectedRows[0].DataBoundItem as DataRowView).Row as DataSets.RFCardDataRow;

m_bf.ReadItemData(row.EmployeeID);


this.dvw_item.DataSource = m_bf.TC_Card_PhoneInfo;
}
else
{
this.dvw_item.DataSource = null;
}
}
catch (Exception ex)
{

}
finally
{
this.handlemode = YC.Common.HandleMode.Browse;
SetHandleMode(this.handlemode);
}
}

------解决方案--------------------
个人认为这种思路不可取,把简单问题复杂化!

完全可以模仿Sql Server的编辑器,做个简单的Form程序就可以实现了。。。
------解决方案--------------------
探讨
个人认为这种思路不可取,把简单问题复杂化!

完全可以模仿Sql Server的编辑器,做个简单的Form程序就可以实现了。。。

------解决方案--------------------
使用DataGridView嵌套方法,,先做个字段的DataGridView1,,然后在DataGridView1中嵌套DataGridView2,
先:在DataGridView1的编辑事件中写获取跟字段的id然后在根据此ID查询出来属性直接绑定DataGridView2。。。这样就可以了。
------解决方案--------------------
你把Form分成两个区域:

上半部分,摆放Label、Button、TextBox、ComboBox等,
用来添加、修改、删除表字段相关信息

下半部分:显示已经添加进去的表字段。

看看Sql Server的表编辑器,你就明白了。。。