且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从文本框中的查询中获取价值

更新时间:2023-02-23 23:13:09

就我个人而言,我认为您的做法是错误的.如果我是您,我将拥有一个返回公共属性的产品类,例如项目代码,单价和结束日期.在此类中,我将具有一个共享函数,该函数返回一个List(产品),或者如果您有很多产品,则将它们分为产品类别并按类别返回产品清单.然后在我的产品管理表单中(可能是在完全不同的项目中引用了我的产品类),我将有一个表单级别的变量,即
Personally, I think you are going about this the wrong way. If i were you I would have a Product Class that returns public properties such as Item Code, Unit Price and Ending Date. In this class I would have a shared function that returns a List(of Product) or if you have a lot of products then I would split them into product categories and return a list of product by category. Then in my products management form (which would likely be in a completely different project that references my Products Class) I would have a form level variable i.e
Private Products As List(of Product)

,其中包含列表(产品).在表单加载中,我将通过调用

that holds a list(of Product). In my form load I would retrieve the products by calling

Products.GetProducts

来检索产品,然后将ComboBox绑定到产品列表,例如

I would then bind the ComboBox to the Prodcuts List like this

ComboBox1.DataSource = Products
ComboBox1.DisplayMember = "Product Name"
ComboBox.ValueMember = "Item Code"



然后在您的



then in your



感谢zim ...但是实际上我必须从MS Access中创建的数据库中的组合框中获取这些值. 实际上我还没有对Vb.net进行过很多详细的研究....但是我必须创建一个项目....实际上,此代码是正确的,正如已经提到的那样,它可以正确运行,但具有静态值. ....
好吧,如果您有任何解决方案可以在运行时比较组合框中的值,请让我知道....
Thanks zim...but actually i have to get those values in the combo box from a database which i have created in MS Access
Actually i haven''t studied Vb.net in a lot of detail....but i have to make a project....actually this code is correct, as have mentioned it that it runs correctly but giving a static value.....
Well, if u have any solution for comparing a value in the combobox at run time, do let me know....