Reputation: 129
Destination Vault Member set:
cboDestinationVault.DataSource = Enum.GetValues(typeof(enumVaultType))
.Cast<enumVaultType>()
.Select(x => new {
Value = x, Description = x.ToString().Replace("_", " ")
}).ToList();
cboDestinationVault.DisplayMember = "Description";
cboDestinationVault.ValueMember = "Value";
I want to hide one item from cboDestinationVault.
Upvotes: 2
Views: 1725
Reputation: 43636
Just add a Where
clause to your Linq
statement
cboDestinationVault.DataSource = Enum.GetValues(typeof(enumVaultType))
.Cast<enumVaultType>()
.Where(e => e != enumVaultType.Whatever)
.Select(x => new {
Value = x, Description = x.ToString().Replace("_", " ")
}).ToList();
if there is more than one you could use Except
cboDestinationVault.DataSource = Enum.GetValues(typeof(enumVaultType))
.Cast<enumVaultType>()
.Except(new []{enumVaultType.ThisOne, enumVaultType.ThatOne})
.Select(x => new {
Value = x, Description = x.ToString().Replace("_", " ")
}).ToList();
Upvotes: 2