我看一看 com子不能有多个栏目。 这使我陷入了困境,因为我想要做的是从一张桌上显示一个领域,但从同一桌上的第二个领域,即回来相应的价值。
我愿在 com子中显示客户情况,但当用户选择名字时,客户信息数据库的现场就被退回。 这方面的最佳工作是什么?
我看一看 com子不能有多个栏目。 这使我陷入了困境,因为我想要做的是从一张桌上显示一个领域,但从同一桌上的第二个领域,即回来相应的价值。
我愿在 com子中显示客户情况,但当用户选择名字时,客户信息数据库的现场就被退回。 这方面的最佳工作是什么?
你们不需要多栏执行。
class Member
{
public string Name{get;set;}
public string Address{get;set;}
public int ID{get;set;}
public string Description
{
get
{
return string.Format("{0}, {1}", Name, Address);
}
}
}
var members = new []
{
new Member(){ID = 1, Name = "John", Address = "Addr 1"},
new Member(){ID = 2, Name = "Mary", Address = "Addr 2"}
};
m_ComboBox.DataSource = members;
m_ComboBox.DisplayMember = "Description"
m_ComboBox.ValueMember = "ID";
现在,你可以查阅名贵的身份证。
var selectedID = m_ComboBox.CelectedValue();
最佳方式是使用ComboBoxesDisplayMember
和Value Members
财产
页: 1 ComboBox.Display Members to the property You Hope to show. 欲退还的财产使用<代码>。 然后,您可使用<代码>ComboBox.S selectedValue,以获得目前/当选的<代码>
ComboBoxItem的价值不必与案文相同,因此考虑将该索引作为数值。
您可以通过制定<条码>来实现所期望的行为。 显示成员代码>和 成员编码>ComboBox至
的特性>,“CustomerName”
和“CustomerID”
。
查阅<代码>ValueMember 财产。 你们应当把这一点交给客户信息数据库。 在你对 com子进行约束之后,向用户展示的实际现场将是“客户”,但当你想要获得客户信息的价值时,它将归还客户信息数据库。
当你想获得 com箱的价值时,仅提及<代码>S selectedValue。
If you are adamant about displaying both of these in the combobox, there are some hackish ways of doing this but I would recommend reviewing your requirements again and seeing if it is absolutely necessary.
或者,你可以把钥匙ValuePair物体与您的预定Ids和文字领域联系起来。 他们从小船起到小船。 物品财产是收集物品。 然后,为了检索,使用像样的 cast。
var x = (KeyValuePair)combo.Items[0];
之后是x的关键和价值特性。
你们可以使用ComboBoxItem的Tag财产储存价值。
I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...
I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...
I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?
How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...
I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...
When I m trying to change the default Image of a Control on Windows Forms in Form Designer (no matter where on which control) I get this error: Error message: An item with the same key has ...
I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.