文档结构
Form_1:
- Panel1:-gridView;
- 面板 2: - 树列表;
- Panel3: - UserControl(取决于所选的树节点);
场景_1:
- 用户。选择网格中的一行。
- 代码。将 gridView 中焦点所在行的“ID”值发送到变量。(由 gridView 事件处理)。
- 代码。默认情况下,焦点放在节点“Node_1”treeList(由 gridView 事件处理)上。
- 用户。在 treeList 中选择一个节点。
- 在 Panel3 中,显示一个 UserControl,它对应于 gridView 中的“ID”行和 treeList 中节点的“ID”(由 treeList 事件处理);
场景_2:
用户。仅在 gridView 中的行之间移动焦点,
而在 treeList 中,焦点始终位于同一节点上。
问题:Panel3 显示用户控件“UserControl_1”,它只匹配 grid_1“row_1”。
如何实现:
- Panel1 --- Panel2 ----- Panel3
- “lines_1” - “Node_1” - “UserControl_1”;
- “lines_2” - “Node_1” - “UserControl_2”;
- “lines_3” - “Node_1” - “UserControl_3”;
问题。
如何解决问题“Scenario_2”?
private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
try
{
idParser = Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID"));
TreeListNode nodeFocus = treeList2.FindNodeByKeyID(20);
treeList2.SetFocusedNode(nodeFocus);
}
catch (Exception)
{
return;
}
}
private void treeList2_AfterFocusNode(object sender, NodeEventArgs e)
{
int idNode = Convert.ToInt32(e.Node.GetValue("ID")); // "ID" вбыранного узла
switch (idNode)
{
case 20:
pathToSettingsMain = maskPath + idParser.ToString() + ".xml";
f01startURLs = new F01StartURLs(pathToSettingsMain);
splitContainer2.Panel2.Controls.Clear();
splitContainer2.Panel2.Controls.Add(f01startURLs);
userControlCurent = f01startURLs;
break;
}