如何将ComboBox链接到SQL数据源

编程入门 行业动态 更新时间:2024-10-28 17:21:11
本文介绍了如何将ComboBox链接到SQL数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨大家好, 我正在使用visual studio 2008创建一个基于Windows窗体的应用程序。 我正在慢慢掌握所有数据集,绑定源,表适配器的东西。 我正在尝试在我的表单中添加一个组合框并从查找表中填充它。 然后将选定的ID保存回数据表,这让我感到疯狂。 我在数据绑定模式属性对话框中尝试了我能想到的所有组合,但它仍然无法正常工作。 为简化起见,我创建了一个表单项目,并将数据源树(数据集)中的事务记录ID字段拖到表单上。 接下来,我将数据源树(数据集)中的下拉列表(相同的事务表)的ID字段拖到表单上。 逻辑上我现在需要告诉组合框根据当前选择的查找表显示提交的描述交易记录中的ID。 到目前为止我找到的所有示例都有直接编辑代码的说明。这似乎是一个简单的GUI操作。 组合框对话框有4个字段。 数据源 显示会员 超值会员 选择价值 我假设我只需要正确设置这四个它的工作原理。我尝试过每一个我能想到的组合。当表单上显示有效记录并且下拉列表中的正确文本描述或下拉列表中显示的ID而不是文本时,我要么没有初始值。 它似乎也似乎如果我尝试在下拉菜单中更改/设置一个值,那就挂起。 我出错的任何想法和/或有没有人知道一个不错的解释如何正确使用这个? 在此先感谢 David

解决方案

从这里开始: stackoverflow/questions/17960283/how-to-get-data-from-sql-database-to-store-in-combo-box-c-sharp [ ^ ]

Hi Guys, I'm creating a Windows Forms based application using visual studio 2008. I'm slowly getting the hang of all the Dataset, Binding Source, Table Adapter stuff. I'm trying to add a Combo box to my form and populate it from a lookup table. Then save the selected ID back to the data table and it is driving me insane. I have tried every combination I can think of in the "Data Binding Mode" properties dialog and it still doesn't work properly. To simplify things I have created a one form project and dragged Transaction Record ID field from the Data Sources tree (Dataset) onto the form. Next I dragged the ID Field of the drop down list (same transaction table) from the Data Sources tree (Dataset) onto the form. Logically I now need to tell the combo box to display the description filed from the look up table based on the currently selected ID in the transaction record. All of the examples I have found so far have descriptions for editing the code directly. This seems like a simple GUI thing to do. The Combo box dialog has 4 fields. Data Source Display Member Value Member Selected Value I assume I just need to set these four correctly for it to work. I have tried every combination I can think of. I either get no initial value when a valid record is shown on the form and the correct text description is in the drop down or the ID is shown in the Drop Down and not the text. It also seems to hang if I try and change / set a value in the drop down. Any ideas where I'm going wrong and / or does anyone know of a decent explanation of how to use this properly? Thanks in Advance David

解决方案

Start here : stackoverflow/questions/17960283/how-to-get-data-from-sql-database-to-store-in-combo-box-c-sharp[^]

更多推荐

如何将ComboBox链接到SQL数据源

本文发布于:2023-11-12 23:22:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582790.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据源   如何将   链接   ComboBox   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!