Home > Software engineering >  C# - DataGridView ComboBoxCol Displaying Ghost Text of other Cells - Windows Form Application
C# - DataGridView ComboBoxCol Displaying Ghost Text of other Cells - Windows Form Application

Time:02-26

As you can see in the image below the combobox col of the datagridview is displaying ghost images of text from higher rows. If you move the cursor over the text several times it goes away. Scrolling up and down sometimes helps as well. Any thoughts on what is causing this issue? Thanks!

enter image description here

        mainDataGridView.DataSource = bindingSourceDataGridView;
        
        mainDataGridView.AutoGenerateColumns = false;

        DataGridViewComboBoxColumn ColComboBox = new DataGridViewComboBoxColumn();
        mainDataGridView.Columns.Add(ColComboBox);
        ColComboBox.HeaderText = "Category";
        ColComboBox.ValueType = typeof(string);
        ColComboBox.DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
        //ColComboBox.DisplayIndex = 0;
        ColComboBox.Width = 175;
        ColComboBox.DataSource = clSQLServer.getTransactionCategory();
        ColComboBox.DisplayMember = "transactionCategory";
        ColComboBox.ValueMember = "transactionCategoryID"; 
        ColComboBox.Name = "transactionCategory"; //Category
        ColComboBox.DataPropertyName = "transactionCategoryID"; //CategoryID

        DataGridViewTextBoxColumn textBoxColumn = new DataGridViewTextBoxColumn();
        mainDataGridView.Columns.Add(textBoxColumn);
        textBoxColumn.HeaderText = "Memo";
        textBoxColumn.DataPropertyName = "Memo";

CodePudding user response:

Changing the displayStyle from DropDown to ComboBox resolves the issue. I don't like the look as much however it is fully functional this way.

If someone else has a better response please chime in. Thanks!

  • Related