private void ModificationList_CellClick(object sender, CellClickEventArgs e) { //点中的是一个有效的单元格 if (e.Row > -1 && e.Column > -1) { Rectangle Rect = ModificationList.GetCellRectangle( ModificationList.GetActiveRowViewportIndex(), ModificationList.GetActiveColumnViewportIndex(), e.Row, e.Column); Point ScreenPoint = ConditionList.PointToScreen(Rect.Location); Point ClientPoint = wizardPage2.PointToClient(ScreenPoint); switch (e.Column) { case 0: Modification_DataItem_Editor.Location = ClientPoint; Modification_DataItem_Editor.Size = Rect.Size; Modification_DataItem_Editor.BringToFront(); Modification_DataItem_Editor.DroppedDown = true; break; case 1: ModificationType_Editor.Location = ClientPoint; ModificationType_Editor.Size = Rect.Size; ModificationType_Editor.BringToFront(); ModificationType_Editor.DroppedDown = true; break; case 2: ModificationValue_Editor.Location = ClientPoint; ModificationValue_Editor.Size = Rect.Size; ModificationValue_Editor.BringToFront(); ModificationValue_Editor.DroppedDown = true; break; } ModificationList.ActiveSheet.SetActiveCell(e.Row, e.Column); } }
/// <summary> /// 初始化写数函数 /// </summary> /// <param name="FunctionInfo"></param> public void InitFunctionInfo(WriteDataFunctionInfo FunctionInfo) { this.FunctionInfo = FunctionInfo; //显示写数函数的名称 TextBox_FunctionName.Text = FunctionInfo.Name; ReadFromTableName = FunctionInfo.ReadOutTableIndex; //显示写数函数的写入数据的数据表 if (!string.IsNullOrEmpty(FunctionInfo.WriteInTableIndex)) { TreeNode[] Nodes = SheetList.Nodes.Find(FunctionInfo.WriteInTableIndex, true); if (Nodes.Length > 0) { SheetList.SelectedNode = Nodes[0]; InitFields(Nodes[0]); } } //显示写数函数的过滤条件 //绑定数据时保证显示第一行,以免报错“System.ArgumentOutOfRangeException: Invalid low bound argument” if (ConditionList.ActiveSheet.Rows.Count > 0) { ConditionList.ShowRow(ConditionList.GetActiveRowViewportIndex(), 0, VerticalPosition.Top); } ConditionList.ActiveSheet.Rows.Count = 0; ConditionList.ActiveSheet.Rows.Count = 600; foreach (ExpressionInfo Info in FunctionInfo.Conditions) { ConditionList.ActiveSheet.Rows.Add(0, 1); ConditionList.ActiveSheet.Rows[0].Tag = Info; foreach (FieldInfo fieldInfo in WriteToTable_DataItem_Editor.Items) { if (fieldInfo.Name == Info.DataItem.Name) { ConditionList.ActiveSheet.Cells[0, 0].Value = fieldInfo; break; } } TreeNode[] dropDownNodes = WriteToTable_Value_Editor.DropDownControl.Nodes.Find(Info.DataValue.Name, true); if (dropDownNodes.Length > 0) { WriteToTable_Value_Editor.DropDownControl.SelectedNode = dropDownNodes[0]; ConditionList.ActiveSheet.Cells[0, 2].Value = dropDownNodes[0].Tag as FieldInfo; } ConditionList.ActiveSheet.Cells[0, 1].Value = Info.Operation; } //显示写数函数的修改数据项 //绑定数据时保证显示第一行,以免报错“System.ArgumentOutOfRangeException: Invalid low bound argument” if (ModificationList.ActiveSheet.Rows.Count > 0) { ModificationList.ShowRow(ModificationList.GetActiveRowViewportIndex(), 0, VerticalPosition.Top); } ModificationList.ActiveSheet.Rows.Count = 0; ModificationList.ActiveSheet.Rows.Count = 600; foreach (ExpressionInfo Info in FunctionInfo.Modifications) { ModificationList.ActiveSheet.Rows.Add(0, 1); ModificationList.ActiveSheet.Rows[0].Tag = Info; foreach (FieldInfo fieldInfo in Modification_DataItem_Editor.Items) { if (fieldInfo.Name == Info.DataItem.Name) { ModificationList.ActiveSheet.Cells[0, 0].Value = fieldInfo; break; } } TreeNode[] dropDownNodes = ModificationValue_Editor.DropDownControl.Nodes.Find(Info.DataValue.Name, true); if (dropDownNodes.Length > 0) { ModificationValue_Editor.DropDownControl.SelectedNode = dropDownNodes[0]; ModificationList.ActiveSheet.Cells[0, 2].Value = dropDownNodes[0].Tag as FieldInfo; } ModificationList.ActiveSheet.Cells[0, 1].Value = Info.Operation; } }