不确定最好的方法。 [英] Not sure of the best way to do this.

查看:83
本文介绍了不确定最好的方法。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对我正在编写的数据库/程序有疑问。数据库服务器是SQL服务器。一个表具有ID(GUID)和名称。 (对于类别)第二个表具有主ID,名称的前一个表的ID上的外键,以及其他一些列。我以这种方式制作了第一张桌子,因为我已经看过如果你不这样做,就有可能以无数种不同的方式将相同的项目放入文本中。



所以现在在我的Windows窗体应用程序中我用C#编写我希望有一个组合框,我想显示名称,所以如果他们想要改变它们就可以。最好的方法是什么?



我尝试过:



目前还没有。只是寻找建议。

I have a question about a database/program I am writing. The database server is SQL server. One table has an ID (GUID) and Name. (for a category) The Second table has the a main ID, a foreign Key on the ID to the previous table for the name, as well as a few other columns. I made the first table this way because I have seen if you don`t do this there is a possibility of having the same item put in as text an infinite number of different ways.

So now in my windows form application I am writing in C# I want to have a combo box which I want to display the name so if they want to change it they can. What is the best way to do this?

What I have tried:

Nothing as of yet. Just looking for suggestions.

推荐答案

将DisplayMember属性设置为Name列,将ValueMember属性设置为ID。

当他们改变时值,处理事件并直接获取GUID值。从那时起你可以用它做你想做的事!
Set the DisplayMember property to the Name column, and the ValueMember property to the ID.
When they change the value, handle the event and fetch the GUID value directly. You can do what you want with it from that point!


这篇关于不确定最好的方法。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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