소스 검색

DBFind双击单元格赋值能够正确地向容器中的控件赋值

Hcsy 7 년 전
부모
커밋
d7fffabd94
3개의 변경된 파일37개의 추가작업 그리고 6개의 파일을 삭제
  1. 1 0
      .gitignore
  2. 34 5
      UAS-MES/DbFind.cs
  3. 2 1
      UAS-MES/UAS-MES.csproj

+ 1 - 0
.gitignore

@@ -210,3 +210,4 @@ FakesAssemblies/
 GeneratedArtifacts/
 _Pvt_Extensions/
 ModelManifest.xml
+*.rar

+ 34 - 5
UAS-MES/DbFind.cs

@@ -161,21 +161,50 @@ namespace UAS_MES
         {
             try
             {
+                //赋值控件是否被GROUP包含
+                Boolean groupcontains = false;
                 //先判断DataTable里面是否有这个字段,然后从打开的窗口里面去获取到这个Form,从Form中的指定Panel获取到指定字段的控件
                 FormCollection fmCollection = Application.OpenForms;
                 SuccessReturnData = true;
                 for (int i = 0; i < dt.Columns.Count; i++)
                 {
-                    for (int j = 0; j < SetValueField.Length; j++)
+                    ControlCollection controls = (ControlCollection)fmCollection[FormName].Controls;
+                    for (int k = 0; k < controls.Count; k++)
                     {
-                        Control ctl = fmCollection[FormName].Controls[SetValueField[j]];
-                        if (SetValueField[j] == dt.Columns[i].Caption || SetValueField[j] == dt.Columns[i].ColumnName || SetValueField[j].Contains(dt.Columns[i].Caption) || (ctl != null && ctl.Tag != null && ctl.Tag.ToString() == dt.Columns[i].Caption))
-                            fmCollection[FormName].Controls[SetValueField[j]].Text = DbFindGridView.Rows[e.RowIndex].Cells[dt.Columns[i].ColumnName].Value.ToString();
+                        Control ctl = controls[k];
+                        if (ctl.Controls.Count > 0)
+                        {
+                            for (int j = 0; j < SetValueField.Length; j++)
+                            {
+                                Control ct2 = ctl.Controls[SetValueField[j]];
+                                if (SetValueField[j] == dt.Columns[i].Caption || SetValueField[j] == dt.Columns[i].ColumnName || SetValueField[j].Contains(dt.Columns[i].Caption) || (ct2 != null && ct2.Tag != null && ct2.Tag.ToString() == dt.Columns[i].Caption))
+                                    ct2.Text = DbFindGridView.Rows[e.RowIndex].Cells[dt.Columns[i].ColumnName].Value.ToString();
+                            }
+                            groupcontains = true;
+
+                        }
+                        break;
+                    }
+                }
+                if (!groupcontains)
+                {
+                    for (int i = 0; i < dt.Columns.Count; i++)
+                    {
+                        for (int j = 0; j < SetValueField.Length; j++)
+                        {
+                            Control ctl = fmCollection[FormName].Controls[SetValueField[j]];
+                            if (SetValueField[j] == dt.Columns[i].Caption || SetValueField[j] == dt.Columns[i].ColumnName || SetValueField[j].Contains(dt.Columns[i].Caption) || (ctl != null && ctl.Tag != null && ctl.Tag.ToString() == dt.Columns[i].Caption))
+                                fmCollection[FormName].Controls[SetValueField[j]].Text = DbFindGridView.Rows[e.RowIndex].Cells[dt.Columns[i].ColumnName].Value.ToString();
+                        }
                     }
                 }
+
                 fmCollection[FormName].Controls[MainField].Focus();
             }
-            catch (Exception) { SuccessReturnData = false; }
+            catch (Exception exa)
+            {
+                SuccessReturnData = false;
+            }
             Dispose();
             Close();
         }

+ 2 - 1
UAS-MES/UAS-MES.csproj

@@ -83,7 +83,7 @@
     <GenerateManifests>true</GenerateManifests>
   </PropertyGroup>
   <PropertyGroup>
-    <SignManifests>true</SignManifests>
+    <SignManifests>false</SignManifests>
   </PropertyGroup>
   <PropertyGroup>
     <StartupObject>UAS_MES.Program</StartupObject>
@@ -1012,6 +1012,7 @@
       <DependentUpon>Settings.settings</DependentUpon>
       <DesignTimeSharedInput>True</DesignTimeSharedInput>
     </Compile>
+    <None Include="UAS-MES_TemporaryKey.pfx" />
   </ItemGroup>
   <ItemGroup>
     <None Include="App.config">