将新行分配给ComboBox的DataSource列

时间:2018-07-11 22:43:20

标签: c# winforms combobox

我根据从dataSource接收到的数据动态创建ComboBox。所以我有这样的代码:

nav
    width: initial
    border: none
    display: inline-block
    margin-right: 0
    position: absolute
    right: 4em
    &:active
        display: block
        position: static
        width: 100%
    li
        display: block
        line-height: 3.5em
        text-align: center
    li:first-of-type
        margin-right: 1.5em
    a
        border: none
        font-size: 1.125em
        display: list-item

header a
    color: #FFF
    cursor: pointer
    text-decoration: none
    text-transform: uppercase
    -webkit-transition: all 0.5s ease-in-out
    -moz-transition: all 0.5s ease-in-out
    -o-transition: all 0.5s ease-in-out
    transition: all 0.5s ease-in-out
    &:hover
      color: #D8D8D8
    &:focus
      outline: 1px solid #F1F1F1

如您所见,我已经根据收到的 private static ComboBox DoCreateComboBox(DataTable empList, int yPoint, int xComboPoint, DataRow task) { var currentEmpGuid = task["EmpGuid"]; var recalculatedEmpGuid = ""; if (currentEmpGuid.Equals(Guid.Empty)) { recalculatedEmpGuid = "Unassigned"; } else { recalculatedEmpGuid = currentEmpGuid.ToString(); } //Creating ComboBox return new ComboBox() { DisplayMember = "Name", ValueMember = "EmpGuid", BindingContext = new BindingContext(), DataSource = empList, SelectedValue = recalculatedEmpGuid, DropDownStyle = ComboBoxStyle.DropDownList, Location = new Point(xComboPoint, yPoint), Tag = task }; 获得了recalculatedValue。我想知道如何将未分配的值添加到我的Guid以便用作empList上的SelectedValue属性。

为简单起见,我只需要向Combobox列添加值为“ Unassigned”的新行  我该如何实现?问候

0 个答案:

没有答案