private void 属性ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
DatasetVector dataSet = workspace1.Datasources[workspaceControl.WorkspaceTree.SelectedNode.Parent.Name].Datasets[workspaceControl.WorkspaceTree.SelectedNode.Name] as DatasetVector;
FieldInfos fieldInfos = dataSet.FieldInfos;
//填充属性设置表
SetDGV_Field(dataSet, fieldInfos);
}
catch (Exception ex)
{
MessageBox.Show("error:" + ex.Message);
}
}
/// <summary>
/// 填充属性设置表
/// </summary>
/// <param name="fieldInfo"></param>
private void SetDGV_Field(DatasetVector Dt, FieldInfos fieldInfos)
{
try
{
for (int i = 0; i < fieldInfos.Count; i++)
{
if (!fieldInfos[i].IsSystemField)
{
dataGridView2.Rows.Add();
dataGridView2.Rows[j].Cells[0].Value = Dt.Name;
dataGridView2.Rows[j].Cells[1].Value = fieldInfos[i].Caption;
dataGridView2.Rows[j].Cells[2].Value = fieldInfos[i].Type.ToString();
dataGridView2.Rows[j].Cells[3].Value = fieldInfos[i].MaxLength.ToString();
dataGridView2.Rows[j].Cells[4].Value = fieldInfos[i].DefaultValue;
dataGridView2.Rows[j].Cells[5].Value = fieldInfos[i].IsRequired.ToString();
j++;
}
}
}
catch (Exception ex)
{
MessageBox.Show("error:" + ex.Message);
}
}
就是查看属性字段,但是点击下一个的时候不会清楚上一次的,添加清除行列的代码又会提示不能向没有列的表添加行