自动检查核对表框中的项目 [英] Automatically check items in checklistbox

查看:96
本文介绍了自动检查核对表框中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有办法在支票清单框中自动检查物品(即12项中的6项)?



目前,我正在尝试编写代码这说明,



当组合框在form1中显示'sweets'时,form2中的checklsitbox会自动检查checklistbox中12个项目中的6个。



我不知道从哪里开始



我尝试了什么:



我已将form1中的组合框设置为公共,不知道从哪里开始

Is there a way have items (i.e. 6 out of 12 items) automatically checked in a checked list box?

Currently, I am trying to write a code which is stating that,

When the combo box says 'sweets' in form1, the checklsitbox in form2 automatically checks 6 out of the 12 items in the checklistbox.

I'm not sure where to start

What I have tried:

I've set the combobox in form1 to public, not sure where to go from there

推荐答案

由于必须检查的组合是第二种形式,最好在Form2中使用一个公共方法来处理逻辑:

Since the combo which has to be checked is in the second form, it would be better to have a public method in Form2 which would handle the logic:
// In form2

public void CheckItems(string param) {
   if (param == "sweets") {
     // Code to check according to your logic
   }
}





您可以从form1调用该方法,提供你在form1中保留了一个有效的实例变量,指向你实际的form2实例。



You could call that method from form1, provided you keep in form1 a valid instance variable pointing to your actual instance of form2.


除了 phil.o [ ^ ],我建议你阅读:

在两种形式之间转移信息,第1部分:父母对儿童 [ ^ ]

在两种表格之间转移信息,第2部分:从孩子到父母 [ ^ ]

在两种表格之间传递信息,第3部分:儿童与儿童 [ ^ ]
In addition to solution#1 by phil.o[^], i'd suggest to read this:
Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]


这篇关于自动检查核对表框中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆