winforms 程序,目前我想实现的效果是,当选中 父表的时候,子表全部选中,最后根据 子表带出相应的数据,当我全消子表里面的记录的时候,同时把相应的关联也取消掉,问题是 展开父子表的时候,不选择父表只选择子表时,怎么得到子表值?
代码如下:
StringBuilder stringBuilder = new StringBuilder();
private void fpSpread1_ButtonClicked(object sender, FarPoint.Win.Spread.EditorNotifyEventArgs e)
{
FarPoint.Win.Spread.SheetView sv;
sv = fpSpread1.ActiveSheet.GetChildView(fpSpread1.ActiveSheet.ActiveRowIndex, 0);
if (fpSpread1.Sheets[0].Cells[fpSpread1.ActiveSheet.ActiveRowIndex, 0].Text == "True")
{
for (int i = 0; i < sv.Rows.Count; i++)
{
if (sv.Cells[i, 0].Value.ToString() == "True")
stringBuilder.Append((stringBuilder.Length == 0) ? ("'" + sv.Cells[i, 13].Value + "'") :
(",'" + sv.Cells[i, 13].Value + "'"));
else
stringBuilder.Replace(sv.Cells[i, 13].Value.ToString(), "");
}
}
else
{
for (int i = 0; i < sv.Rows.Count; i++)
{
if (sv.Cells[i, 0].Value.ToString() == "True")
stringBuilder.Append((stringBuilder.Length == 0) ? ("'" + sv.Cells[sv.ActiveRowIndex, 13].Value + "'") :
(",'" + sv.Cells[sv.ActiveRowIndex, 13].Value + "'"));
else
{
//sv.Cells[i, 0].Value = "False";
stringBuilder.Replace(sv.Cells[i, 13].Value.ToString(), "");
}
}
}
//if (sv.Cells[sv.ActiveRowIndex, 0].Value == "False")
// stringBuilder.Replace(sv.Cells[sv.ActiveRowIndex, 13].Value.ToString(), "");
//else
// stringBuilder.Append((stringBuilder.Length == 0) ? ("'" + sv.Cells[sv.ActiveRowIndex, 13].Value + "'") :
// (",'" + sv.Cells[sv.ActiveRowIndex, 13].Value + "'"));
stringBuilder = stringBuilder.Replace(",,", ",").Replace("'',", "");
if (stringBuilder.Length > 0)
{
string text = " and d.autoid in (@id) ";
text = text.Replace("@id", stringBuilder.ToString());
this.getDetailInfo(text, this.GridViews, this.strDetailTitle);
}
else
{
string text = " and 1=2 ";
this.getDetailInfo(text, this.GridViews, this.strDetailTitle);
}
} |
|