Multiple values in ComboBox.DisplayMember
-
Hope someone can help me. I want to add two values in a combobox. It's for players of a team. Now I have done it as follow with an DataSet:
cbPlayers.DataSource = dsPlayers.Tables["Players"]; cbPlayers.ValueMember = "PlayerID"; cbPlayers.DisplayMember = "FullName";
This gives a combobox filled with only playernames But I also would like to include the team name behind the playername in this combobox. Who can help me out?:confused: -
Hope someone can help me. I want to add two values in a combobox. It's for players of a team. Now I have done it as follow with an DataSet:
cbPlayers.DataSource = dsPlayers.Tables["Players"]; cbPlayers.ValueMember = "PlayerID"; cbPlayers.DisplayMember = "FullName";
This gives a combobox filled with only playernames But I also would like to include the team name behind the playername in this combobox. Who can help me out?:confused:Create a property that returns that. Will probably be in the generated C# file from the XSD. xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
-
Hope someone can help me. I want to add two values in a combobox. It's for players of a team. Now I have done it as follow with an DataSet:
cbPlayers.DataSource = dsPlayers.Tables["Players"]; cbPlayers.ValueMember = "PlayerID"; cbPlayers.DisplayMember = "FullName";
This gives a combobox filled with only playernames But I also would like to include the team name behind the playername in this combobox. Who can help me out?:confused:If You don't find suitable solution you can create custom class that have properties that you want and load combobox by code instead of data binding this way you can control what text will appear in each combobox item MCAD
-
If You don't find suitable solution you can create custom class that have properties that you want and load combobox by code instead of data binding this way you can control what text will appear in each combobox item MCAD
Hi Mohamad, Is there a way to do it through DataView. I could not find a way to merge columns togather. RowFilter is the only thing you can do. Live Life King Size Alomgir Miah
-
Hi Mohamad, Is there a way to do it through DataView. I could not find a way to merge columns togather. RowFilter is the only thing you can do. Live Life King Size Alomgir Miah
Hi Alomgir Sorry i don't understand what you mean can you explain it more? What i want to say that he can create custom class which contain properties like PlayerID,FullName and add it in items collection or use datatable MCAD
-
Hi Alomgir Sorry i don't understand what you mean can you explain it more? What i want to say that he can create custom class which contain properties like PlayerID,FullName and add it in items collection or use datatable MCAD
I understood your solution and I think it will work perfectly. This is just out of curiosity, I was just wondering if we can combine column values using DataView. Live Life King Size Alomgir Miah
-
Hope someone can help me. I want to add two values in a combobox. It's for players of a team. Now I have done it as follow with an DataSet:
cbPlayers.DataSource = dsPlayers.Tables["Players"]; cbPlayers.ValueMember = "PlayerID"; cbPlayers.DisplayMember = "FullName";
This gives a combobox filled with only playernames But I also would like to include the team name behind the playername in this combobox. Who can help me out?:confused:You Can Create Expression Column That do that And bind DisplayMenmber to it somthing like that
DataColumn dc=new DataColumn("Test",typeof(System.String))); dc.Expression="ContactName + (' ')+ CustomerID "; dataSet21.Customers.Columns.Add(dc); comboBox1.DataSource=dataSet21.Customers; comboBox1.DisplayMember=dataSet21.Customers.Columns["test"].Caption; comboBox1.ValueMember=dataSet21.Customers.CustomerIDColumn.Caption;
MCAD
-
You Can Create Expression Column That do that And bind DisplayMenmber to it somthing like that
DataColumn dc=new DataColumn("Test",typeof(System.String))); dc.Expression="ContactName + (' ')+ CustomerID "; dataSet21.Customers.Columns.Add(dc); comboBox1.DataSource=dataSet21.Customers; comboBox1.DisplayMember=dataSet21.Customers.Columns["test"].Caption; comboBox1.ValueMember=dataSet21.Customers.CustomerIDColumn.Caption;
MCAD
Thanx Mohamad. This is the solution for me! But one other thing This works for me:
dc.Expression = "FullName + (' ')+ TeamName";
But I prefer an outcome like: FullName [TeamName] I tried the following but it gives an error:dc.Expression = "FullName + (' [')+ TeamName" + (']');
How can I achieve this the right way? -
Thanx Mohamad. This is the solution for me! But one other thing This works for me:
dc.Expression = "FullName + (' ')+ TeamName";
But I prefer an outcome like: FullName [TeamName] I tried the following but it gives an error:dc.Expression = "FullName + (' [')+ TeamName" + (']');
How can I achieve this the right way? -
You Can Create Expression Column That do that And bind DisplayMenmber to it somthing like that
DataColumn dc=new DataColumn("Test",typeof(System.String))); dc.Expression="ContactName + (' ')+ CustomerID "; dataSet21.Customers.Columns.Add(dc); comboBox1.DataSource=dataSet21.Customers; comboBox1.DisplayMember=dataSet21.Customers.Columns["test"].Caption; comboBox1.ValueMember=dataSet21.Customers.CustomerIDColumn.Caption;
MCAD
Thanks......... Live Life King Size Alomgir Miah