0

I have been working on tabcontrol in C#. Where i have added textboxes, labels,datagridviews, panels in all 10 tabs. When i am trying to use autocomplete in textbox it gives me an exception stating "Error Creating Window Handle-Win32 Exception". Below is my code:

    private void textBoxCustomerMNO_Enter(object sender, EventArgs e)
    {

        textBoxCustomerMNO.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
        textBoxCustomerMNO.AutoCompleteSource = AutoCompleteSource.CustomSource;
        AutoCompleteStringCollection CustomerMobileNo = new AutoCompleteStringCollection();

        string Query = "select PATIENT_MNO from MEDICINES_SALE_RECEPIT";
        DataTable CustomerNos = clsConnection.GetDataTable(Query);
        if (CustomerNos.Rows.Count > 0)
        {
            foreach(DataRow row in CustomerNos.Rows)
            {
                CustomerMobileNo.Add(row["PATIENT_MNO"].ToString().Trim());
            }
        }

    }

1. connection class is already created.

Ondrej Janacek
  • 11,896
  • 14
  • 52
  • 87
user3032171
  • 11
  • 1
  • 3

2 Answers2

0

i had a similar problem when i was going to set AutoCompleteMode property of a textbox in GotFocus event. this behaviour is strange but you can resolve it easily by setting AutoCompleteMode property before Enter event or GotFocus event for example in Form_Load event or through the properties window in design mode (of course if your textbox is created & exists in design mode).

//put this in your **Form-Load** event:
textBoxCustomerMNO.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
//.. and remove it from the textBoxCustomerMNO_Enter event!

if you create textBoxCustomerMNO textbox dynamically, then set AutoCompleteMode property also there and before defining the Enter even:

t = new TextBox();
t.AutoCompleteMode = AutoCompleteMode.SuggestAppend; //set this before Enter event! 
t.Enter += new EventHandler(...)
S.Serpooshan
  • 6,368
  • 2
  • 29
  • 53
0

if it greater than 0, Releases all resources used by the Component

        if (this.Handle.ToInt32() > 0)
            {

                if (components != null)
                {
                    components.Dispose();
                }
             }
sam
  • 161
  • 2
  • 4