MultiColumn Combobox selects the first entry of the list without any user input

Hi,


I'm using the MultiColumnComboBox control and I have noticed that even though user Input hasn't been processed the control selects whatever value is in the first row on its own by default

What is the cause of this? I have an app to ship in the coming days and this is causing all my productivity to drop

Please assist

Thank you

This is all the relevant code

Configuration

            ItemNameMultiColumnComboBox.DataSource = new aliasNameInfoCollection().AliasNameListDetails;
ItemNameMultiColumnComboBox.ShowColumnHeader = false;
ItemNameMultiColumnComboBox.DisplayMember = "Name";
ItemNameMultiColumnComboBox.ValueMember = "Name";
ItemNameMultiColumnComboBox.MultiColumn = true;
ItemNameMultiColumnComboBox.AllowFiltering = false;
#pragma warning disable CS8622 // Nullability of reference types in type of parameter doesn't match the target delegate (possibly because of nullability attributes).
ItemNameMultiColumnComboBox.TextChanged += ItemNameMultiColumnComboBox_TextChanged;
#pragma warning restore CS8622 // Nullability of reference types in type of parameter doesn't match the target delegate (possibly because of nullability attributes).
ItemNameMultiColumnComboBox.TextBox.Text = String.Empty;
ItemNameMultiColumnComboBox.AutoComplete = false;


Events

        private void ItemNameMultiColumnComboBox_TextChanged(object sender, EventArgs e)
{
int index = 0;


for (int i = 0; i < ItemNameMultiColumnComboBox.Items.Count; i++)
{
if (ItemNameMultiColumnComboBox.ListBox.Grid[i + 1, 1].Text.ToLower().StartsWith(ItemNameMultiColumnComboBox.TextBox.Text.ToLower()))
{
index = i;
ItemNameMultiColumnComboBox.ListBox.SelectedIndex = index;
return;
// ItemNameMultiColumnComboBox.TextBox.Text = ItemNameMultiColumnComboBox.ListBox.Grid[i + 1, 1].Text;
//MessageBox.Show( ItemNameMultiColumnComboBox.ListBox.Grid[i + 1, 1].Text);
}


}
}


private void ItemNameMultiColumnComboBox_Enter(object sender, EventArgs e)
{
ItemNameMultiColumnComboBox.DroppedDown = true;
}


private void ItemNameMultiColumnComboBox_SelectedValueChanged(object sender, EventArgs e)
{
string txt = ItemNameMultiColumnComboBox.ListBox.Grid[ItemNameMultiColumnComboBox.SelectedIndex + 1, 1].Text;
Messenger.DebugMsg.CustomMessage("Added " + txt);
dataGridView1.Rows[currentRow].Cells[0].Value = txt;
ItemNameMultiColumnComboBox.Visible = false;
}



EDIT: BEFORE IT ADDS THE FIRST ENTRY IT ALSO ADDS THE ValueMember or DisplayMember to the textbox in this case "Name"


9 Replies

AM Ammar June 8, 2022 09:29 AM UTC

I would appreciate a reply because I have an app to ship



MS Mahalakshmi Sugumar Syncfusion Team June 8, 2022 09:38 AM UTC

Hi Ammar,

If you set the SelectedItem property to null after the DisplayMember property, you can achieve your requirement. Please refer to the below code for your reference.

Code:

   this.multiColumnComboBox1.DisplayMember = "Name";

    this.multiColumnComboBox1.SelectedItem = null;

Output image:




Please let us know if you need anu further assistance.

Regards,

Mahalakshmi sugumar



AM Ammar replied to Mahalakshmi Sugumar June 9, 2022 09:38 AM UTC

First of all Thank you so much for helping out with the previous issue


Secondly,

I was wondering why does the MultiColumn ComboBox's SelectedValue_Changed event is fired whenever I change the datasource? This is an undesirable situation and messes with the flow of the program please guide me on how to negate this


EDIT:

Another question


Why doesn't the MultiColumn ComboBox accept empty values? Like if I try to press Enter it won't let me move on to the other controls however if I press tab it works 

This is an issue because I am using Enter key to simulate a tab keypress event alongside data entry



MS Mahalakshmi Sugumar Syncfusion Team June 9, 2022 02:02 PM UTC

Hi Ammar,

Currently, we are analyzing your reported query. We will validate and update you with the details on or before 10th june 2022.

Regards,

Mahalakshmi sugumar



MS Mahalakshmi Sugumar Syncfusion Team June 10, 2022 02:09 PM UTC

Hi Ammar,

Case 1: why does the MultiColumn ComboBox's SelectedValue_Changed event is fired
 whenever I change the datasource?

We have confirmed the reported scenario is a defect and logged a report for the reported scenario “MulticolumnCombobox selects first item by default”. Please provide your version details. We will include the fix in our upcoming Weekly NuGet release or through the patch based on your provided version on 1st July 2022(due date).  


You can track the status of this defect using the following feedback link:        
https://www.syncfusion.com/feedback/35592/multicolumncombobox-selects-first-item-by-default

If you have any more specification replication procedures or a scenario to be tested, you can add it as a comment in the portal.

Please let us know if you need any further assistance.



Case 2: This is an issue because I am using Enter key to simulate a tab keypress event alongside data entry


There is no built-in support to change the focus from one control to another control through the enter key.

Using the code below, you can change the focus using the enter key.

Code:
       
      this
.multiColumnComboBox1.KeyDown += MultiColumnComboBox1_KeyDown;


        private void MultiColumnComboBox1_KeyDown(object sender, KeyEventArgs e)

        {

            if(e.KeyData == Keys.Enter)

             this.sfComboBox1.Focus();

        }

Regards,
Mahalakshmi sugumar



AM Ammar replied to Mahalakshmi Sugumar June 11, 2022 07:09 AM UTC

Hi,


First of all thank you for responding and letting me know about the defect

secondly the package version I'm using is 19.4.0.53


and lastly I wasn't talking about changing focus alone

Even if I try to enter null data in combobox (that is move on without selecting any value it won't let me move until I have selected something) that is the only issue for now 

Any idea what could be causing that?



AM Ammar June 13, 2022 06:51 AM UTC

I would appreciate any help regarding this


Even if I try to enter null data in combobox (that is move on without selecting any value it won't let me move until I have selected something) that is the only issue for now 


MS Mahalakshmi Sugumar Syncfusion Team June 13, 2022 12:40 PM UTC

Hi Ammar,

The MultiSelectionComboBox accepts null value also.
To clear the selection (accept null value), please clear text using backspace key and press enter key. We have attached a sample and video for your reference.

Please let us know if you need any further assistance.

Regards,
Mahalakshmi Sugumar


Attachment: MultiSelCBNullValue_6a036ea9.zip


UD UdhayaKumar Duraisamy Syncfusion Team June 27, 2022 01:28 PM UTC

Hi Ammar,


On further analysis, we found that this is the standard behavior for all framework controls with databinding. When framework ListBox is bounded to a collection, the first item will be selected by default. As a workaround, please set SelectedItem to null after data binding is configured. Please refer to the sample for your reference.


Code example:


    this.multiColumnComboBox1.SelectedItem = null;


Regards,
Bagavathi Perumal A


Attachment: MultiColumnComboBox_Sample_36d281b3.zip

Loader.
Up arrow icon