填充来自不同来源的组合框(Linq) [英] Fill Combobox from different sources (Linq)

查看:65
本文介绍了填充来自不同来源的组合框(Linq)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Okey,我将尝试详细解释我的问题:
首先,让我们说我们有两个Linq to SQL对象:

1.)具有以下属性的人"对象:
FirstName(String)
姓(字符串)
statusID(整数)

2.)第二个对象,称为状态类型",具有以下属性:
statusname(字符串)
id(整数)

人员对象中的statusid链接到状态类型"对象的ID.
Afaik,这是一个非常常见的情况.


现在是我的问题:
网格视图显示所有人员对象.现在,如果我选择一个,则组合框应显示每个值(一个组合框的名字,一个组合框的名字,一个组合框的statusid(甚至更好的是statusname)

因此,让我们以statusid为例.最大的问题是,当您下拉组合框时,它应该为您提供所有可能的状态值(例如:"StatusA","StatusB","StatusC"),并且预先选择的值应该是其中一个我认为,由所选人员对象定义的状态对象(由statusid字段描述的对象)应该是非常常见的情况,但是我还没有找到解决此问题的示例.也许我不正确地理解这些示例.

我的问题是,在所有示例中,它们都将datacontext设置为"person" linq对象.只要您不使用id,就可以.但是,如果这样做,则需要访问其他对象(例如statustypes之类)以获取正确的值.

任何帮助都将非常棒!
最好的问候
Robert

Okey, i''ll try to explain my problem in detail:
First of all, let''s say we have two Linq to SQL Objects:

1.) A ''person'' Object with the following properties:
FirstName(String)
LastName (String)
statusID (Integer)

2.) A second object, called ''statustypes'', with the following properties:
statusname(string)
id (integer)

The statusid in the person object is linked to id''s of the ''statustypes'' object.
Afaik this is a very common scenario.


Now to my problem:
a grid view shows all the person objects. Now, if i choose one, comboboxes should display each value (one combobox firstname, one combobox lastname, one combobox statusid(or even better, statusname)

So let''s take the statusid for example. the big problem is, when you dropdown the combobox, it should give you all the possible values for status (say: ''StatusA'',''StatusB'',''StatusC'') AND the preselected value should be the one defined by the selected person object (the one that is described by the statusid field) Should be a very common scenario i think, but i haven''t found an example that addresses this issue. Or maybe i do not understand the examples the right way.

my problem is that in all examples they set the datacontext to for example ''person'' linq object. This is fine as long as you didn''t work with id''s. But if you do, you need access to other objects (like the statustypes thing) to get the right values.

Any help would be really great!
Best Regards
Robert

推荐答案

据我了解,您需要一个网格来显示您的所有人员,并需要一个组合框来显示您希望能够更新的当前状态. br/>
我不明白您为什么在网格中有一个带有名称和姓氏的组合框.

如果我理解的是正确的,请在人员中填充网格.使用statustypes对象填充组合框,并将显示成员设置为status,将值成员设置为status id.
From what I can understand you need a grid to show all your persons and combo box to show the current status which you want to be able to update.

I do''t understand why you have a combo box with name and surname in your grid.

If what I understand is correct, populate the grid with the persons. Use the statustypes object to populate the combobox and set the display member to status and the value member to status id.


这篇关于填充来自不同来源的组合框(Linq)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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