用于存储单选按钮,复选框和组合框中的项目的对象数组 [英] Object array to store items from radio buttons, check boxes and a combo box

查看:72
本文介绍了用于存储单选按钮,复选框和组合框中的项目的对象数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,上面有三列。第一列有三个复选框,第二列有三个单选按钮,第三列有一个组合框,其中存储有三个值。如何使用对象数组来存储上面列表中所选项目的值?

I have a form and on it I have three columns. The first column has three check boxes, the second has three radio buttons and the third has a combo box with three value stored in it. How can I use an object array to store the value of each item selected in the above lists?

推荐答案

为什么?

这是一个穷人想法,因为数据类型都是不同的 - 这意味着你必须记住在你再次使用数据之前,什么项目在哪里以及它是什么类型。



就个人而言,我创建一个类来保存信息而不是数组,以便您可以直接将其作为正确键入的值作为属性进行访问。更简单,更清洁,更易于维护。
Why?
It's a poor idea, because the data types are all different - which means you have to "remember" what item is where and what type it is before you can use the data again.

Personally, I'd create a class to hold the info instead of an array, so that you access it as correctly typed values directly as properties. Easier, cleaner, and much more maintainable.


这篇关于用于存储单选按钮,复选框和组合框中的项目的对象数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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