设置索引DataGridViewComboBoxColumn

时间:2018-10-05 10:09:10

标签: c# datagridview combobox selectedindex

我正在寻找一种将组合框值设置为索引1而不是[0]的解决方案

当数据网格打开时,组合框显示为空,并且在单击下拉菜单时,这些项目可见。我想看看何时打开数据网格 A0指标是默认值。

这是我将值添加到组合框的部分:

        TitleBlockName = new DataGridViewComboBoxColumn();
        TitleBlockName.HeaderText = "Title Block";
        TitleBlockName.Width = 200;
        TitleBlockName.DataSource = new ArrayList(m_filterSheets.FoundSheets);  
        TitleBlockName.DisplayMember = "Title";
        TitleBlockName.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox;            
        dataGridView1.Columns.AddRange(new DataGridViewColumn[] { TitleBlockName, SheetName, SheetNumber, SheetDrawnBy, SheetId });

        bindingSource1.DataSource = typeof(SheetResource);
        dataGridView1.AutoGenerateColumns = false;
        dataGridView1.DataSource = bindingSource1;            

        TitleBlockName.DataPropertyName = "Title";
        SheetName.DataPropertyName = "Name";
        SheetNumber.DataPropertyName = "Number";
        SheetDrawnBy.DataPropertyName = "Drawn";
        SheetId.DataPropertyName = "Id";
        bindingSource1.DataSource = m_filterSheets.FoundViews;

enter image description here

enter image description here

0 个答案:

没有答案