0
votes

I have created a Windows form in which I have taken a drop down combo box and certain fields. The value of the fields changes accordingly when any value is selected from the drop down. The problem I am facing is that I cannot click anywhere else in the windows form. The focus stays on with the ComboBox drop down. I have used other button like 'PRINT' which provides the facility of printing the information displayed in the win form. but I cannot click on it because of the focus that Is stuck onto the combo box. For the combo box, I have used the following Code:

private void btnPrint_Click(object sender, EventArgs e)
    {
        try
        {
            ExistingAccountScreen existingAcctScreen = new ExistingAccountScreen();
            FillExistingAppForPrinting(existingAcctScreen);
            using (PrintViewer pv=new PrintViewer(existingAcctScreen))
            {
                pv.ShowDialog();
            }
        }
        catch (Exception ex)
        {
            AOTHelper.WriteLog(ex);
        }
    } 

The drop down click event is as below which is creating a problem while selecting value other than the defult selected value

private void cmbAccountNumber_SelectedIndexChanged(object sender, EventArgs e)
    {
        ExistingAccountInfo acctInfo = cmbAccountNumber.SelectedItem as ExistingAccountInfo;
        if (acctInfo == null)
            return;
        existingAccountInfoBindingSource.DataSource = ExistingAccountInfo.Get(acctInfo.AccountNumber);

        accountStatusBindingSource.DataSource = ExistingAccountInfo.GetExistingStatusCodes(acctInfo.AccountNumber);
    }
1
Is there a timer or a background worker that controls the focus? Can you please post a code snippet :) ?Picrofo Software
can you add the code of the "OnChange" handler of your DropDownList?Bazzz
Try to give focus to any control that you want control.Focus = true; (On form Load) ! the control where you want to have focus on form load !Sunny
@Bazz: I have used the SelectedIndex event of the DropDown List and nothing else. It can be done by setting the focus of other controls, but I just wanna know why is this problem occuringRunning Rabbit
@Yash I believe that providing a code snippet would make it easier to detect the problem :)Picrofo Software

1 Answers

1
votes

Simply set the Cause Validation Property of the drop down combo box to False.