如果我在组合框中选择了一个项目,如何获取某个列的值? [英] How do I grab a certain column's value if I selected an item in a combobox?

查看:115
本文介绍了如果我在组合框中选择了一个项目,如何获取某个列的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿!



我是一个相当新的编码器,如果这是一个非常愚蠢的问题,请原谅我。



我有一个comboBox,并用我的数据库中的表填充它。现在我想让脚本从该表中获取PKey列并将其保存为对象(或其他东西),以便我可以将它重用于另一个表。怎么办呢?



我尝试过:



我尝试了一些我在网上找到的东西,虽然似乎没有一个能帮到我解决我的问题:x

Hey!

I'm a fairly new coder so excuse me if this is a really dumb question.

I have a comboBox and have populated it with a table from my database. Now I want to have the script grab the PKey column from that table and save it as an object (or something) so I can reuse it for another table. What would be the way to do it?

What I have tried:

I've tried a few of the things I found online, though none seemed to help me with my problem :x

推荐答案

 ComboControl.DataTextField = "TextField";
ComboControl.DataValueField = "ValueField";



您可以使用


you can use PKey inplce of

ValueField

的PKey inplce

for

DataValueField 



并使用


and use

ComboControl.SelectedItem.Value

保存在其他地方


这篇关于如果我在组合框中选择了一个项目,如何获取某个列的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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