• <small id='jdDXh'></small><noframes id='jdDXh'>

      1. <tfoot id='jdDXh'></tfoot>

        <i id='jdDXh'><tr id='jdDXh'><dt id='jdDXh'><q id='jdDXh'><span id='jdDXh'><b id='jdDXh'><form id='jdDXh'><ins id='jdDXh'></ins><ul id='jdDXh'></ul><sub id='jdDXh'></sub></form><legend id='jdDXh'></legend><bdo id='jdDXh'><pre id='jdDXh'><center id='jdDXh'></center></pre></bdo></b><th id='jdDXh'></th></span></q></dt></tr></i><div id='jdDXh'><tfoot id='jdDXh'></tfoot><dl id='jdDXh'><fieldset id='jdDXh'></fieldset></dl></div>
          <bdo id='jdDXh'></bdo><ul id='jdDXh'></ul>

      2. <legend id='jdDXh'><style id='jdDXh'><dir id='jdDXh'><q id='jdDXh'></q></dir></style></legend>

        使用 2 DialogForm 删除数据

        时间:2023-09-14
      3. <tfoot id='on6mb'></tfoot>

          1. <legend id='on6mb'><style id='on6mb'><dir id='on6mb'><q id='on6mb'></q></dir></style></legend>

            • <i id='on6mb'><tr id='on6mb'><dt id='on6mb'><q id='on6mb'><span id='on6mb'><b id='on6mb'><form id='on6mb'><ins id='on6mb'></ins><ul id='on6mb'></ul><sub id='on6mb'></sub></form><legend id='on6mb'></legend><bdo id='on6mb'><pre id='on6mb'><center id='on6mb'></center></pre></bdo></b><th id='on6mb'></th></span></q></dt></tr></i><div id='on6mb'><tfoot id='on6mb'></tfoot><dl id='on6mb'><fieldset id='on6mb'></fieldset></dl></div>
                <bdo id='on6mb'></bdo><ul id='on6mb'></ul>
                  <tbody id='on6mb'></tbody>

                <small id='on6mb'></small><noframes id='on6mb'>

                  本文介绍了使用 2 DialogForm 删除数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  您好,我有关于从 2 个表单对话框中删除数据的问题
                  在第一个对话框中,它包含数据列表,在第二个对话框中,它包含数据的详细信息和删除按钮...我已经成功删除了数据库中的数据,但我很困惑如何从列表中删除数据...

                  hi i have question for remove data from 2 forms dialog
                  in first dialogform it's contain list of data, and in second dialogform it's contain detail of data and delete button... i already successfully delete data in database but i confused how to remove data from list...

                  如果只是选择数据并删除,我知道可以使用此代码完成

                  if just select data and delete i know it's can be done with this code

                  quizzes.RemoveAt(listBoxQuizzes.SelectedIndex);
                  

                  但是dialogform1中的问题在这里没有可用的按钮删除,只查看详细数据.所以如果用户想删除数据,他必须打开 dialogform2(详细数据)我已经使用此代码删除了数据库中的数据

                  but problem here in dialogform1 not available button delete, just view details data. so if user want to delete data, he must open dialogform2 (detail data) i already done delete data in database with this code

                  Global.deleteData("DELETE FROM Quiz_Occurrences WHERE ID = " + id);
                  

                  并通过

                  this.Close();
                  

                  并移动到 dialogform1 (listdatabox)这里的问题,我刚刚删除的数据仍然在那里,因为它还没有删除(已经从数据库中删除但没有从列表中删除).需要重启程序才能看到删除数据的效果

                  and move to dialogform1 (listdatabox) the problem in here, data which just i delete still in there because it's still not remove yet (already delete from database but not remove from list). and need to restart program to see effect of delete data

                  更新进度

                  我将数据更改为全局变量,所以从技术上讲,我可以删除 dialogform2 中的数据
                  这是代码(dialogform1 中的修饰符列表框)

                  i changed data to global var, so it's technically i can remove data in dialogform2
                  this is code (modifier listbox in dialogform1)

                   int no = 1;
                   foreach (CQuizOccurrence myQuizOccurrence in Global.quizOccurrences) {
                  
                   }
                  

                  如果我想从 dialogform1 中删除它,我可以使用

                  if i want to delete it from dialogform1, i can use

                  Global.quizOccurrences.removeAT(listBoxQuizzes.SelectedIndex);
                  

                  但是如果我想从 dialogform2 中删除它

                  but if i want to delete it from dialogform2

                  Global.quizOccurrences.removeAT(.........); //still not have idea how can i reference index
                  

                  <小时>

                  更新来自@nitin的解决方案


                  Update solution from @nitin

                  所以我首先在formdialog2中写

                  so first i write in formdialog2

                  public Frmdialog1 frm_dialog { get; set; }
                  

                  然后我在formdialog1中写这个

                  then i write this in formdialog1

                  frmdialog2.frm_dialog=this;
                  

                  然后再回到formdialog1写

                  then back again to formdialog1 to write

                  frm_dialog.quizzes.RemoveAt(frm_dialog.listBoxQuizzes.SelectedIndex);
                  

                  是这样吗,因为我得到了很多错误

                  is that right because i get many error

                  推荐答案

                  在问了很多关于这个话题的不同问题后,我终于可以做我想做的事了
                  首先我尝试将 var 更改为 global,这样我就可以从 dialogform2 中删除列表框 dialogform1 中的数据(我认为这是最简单的方法)

                  i'm finally be able to do as i want after ask many different question about this topic
                  first i try to change var to global, so i can remove data in listbox dialogform1 from dialogform2 (i think it's the easiest way)

                  //in dialog form1 
                  foreach (CQuizOccurrence myQuizOccurrence in Global.quizOccurrences) {
                     //load data from Global.quizOccurences
                  }
                  //call function close to close dialogform1
                  

                  然后在 dialogform2 中,将 Global.quizOccurrences 数据与日期和时间详细数据匹配(使用列表和 foreach)

                  then in dialogform2, match Global.quizOccurrences data with date&time detail data (using list & foreach)

                          List<CQuizOccurrence> matchData = new List<CQuizOccurrence>();
                          foreach (CQuizOccurrence myQuizOccurrence in Global.quizOccurrences) 
                          {
                              DateTime dtDatabase = (DateTime)myQuizOccurrence.occurred;
                              string dt = dtDatabase.ToString();
                              if (dt == dateOccur) {
                                  matchData.Add(myQuizOccurrence);
                              }
                          }
                  
                          foreach (CQuizOccurrence myQuizOccurrence in matchData)
                          {
                              Global.quizOccurrences.Remove(myQuizOccurrence);
                          }
                  
                          //call function show dialog for formdialog1
                  

                  这篇关于使用 2 DialogForm 删除数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:自定义 IInternetSecurityManager 未通过对话框调用 下一篇:WPF:如何设置用户控件显示的对话框的所有者窗口?

                  相关文章

                    <small id='kN8kA'></small><noframes id='kN8kA'>

                    • <bdo id='kN8kA'></bdo><ul id='kN8kA'></ul>
                    <i id='kN8kA'><tr id='kN8kA'><dt id='kN8kA'><q id='kN8kA'><span id='kN8kA'><b id='kN8kA'><form id='kN8kA'><ins id='kN8kA'></ins><ul id='kN8kA'></ul><sub id='kN8kA'></sub></form><legend id='kN8kA'></legend><bdo id='kN8kA'><pre id='kN8kA'><center id='kN8kA'></center></pre></bdo></b><th id='kN8kA'></th></span></q></dt></tr></i><div id='kN8kA'><tfoot id='kN8kA'></tfoot><dl id='kN8kA'><fieldset id='kN8kA'></fieldset></dl></div>
                    <tfoot id='kN8kA'></tfoot>
                  1. <legend id='kN8kA'><style id='kN8kA'><dir id='kN8kA'><q id='kN8kA'></q></dir></style></legend>