Page 1 of 1

AccessibilityObject

Posted: Fri 26 Jan 2018 07:02
by Woosha
Hi Guys, recent purchaser of dotconnect for MySQL. I am getting an error on the UI ListView control 'ltvTreatments' and assume that's why I am unable to display the listview.
I have followed the tutorial to the letter and the error associated with 'ltvTreatments' when it executes the code below is "AccessibilityObject = 'ltvTreatments.AccessibilityObject' threw an exception of type 'System.InvalidOperationException'".

Code: Select all

       private void dependency_OnChange(object sender, MySqlTableChangeEventArgs e)
        {

            ltvTreatments.Invoke(new NotifyDelegate(AddChangedList), new object[] { e.TableName });

        }

The code does continue to run and when the OnChange event is triggered, 'ltvTreatments' when trying to add to it generates "{ControlAccessibleObject: Owner = System.Windows.Forms.ListView, Items.Count: 6, Items[0]: ListViewItem: {12121}}.
Full Code list below, as descriptive as possible. I am desperate to understand my error so would be extremely grateful for anyone to assist.

Code: Select all

        public void CaseDataChangeEventStart()
        {

            string connectionString = "User Id=xxxxx;Password=xxxxx;Host=localhost;Database=avcasesdb;";

            MySqlConnection connection = new MySqlConnection(connectionString);
            connection.Open();

            MySqlCommand mySqlCommand = new MySqlCommand("select * from casetable", connection);
            MySqlDependency dependency = new MySqlDependency(mySqlCommand, 100);
            dependency.OnChange += new Devart.Data.MySql.OnChangeEventHandler(dependency_OnChange);
            MySqlDependency.Start(connectionString);

            }

        private void dependency_OnChange(object sender, MySqlTableChangeEventArgs e)
        {

            ltvTreatments.Invoke(new NotifyDelegate(AddChangedList), new object[] { e.TableName });

        }


        private void AddChangedList(string tablename)
        {
            CasesRepo casesRepo = new CasesRepo();
            currentCase = casesRepo.GetLastTreatment();

            ListViewItem item1 = new ListViewItem(currentCase[0].CaseNumber.ToString());
            ListViewItem item2 = new ListViewItem(currentCase[0].CaseTime);
            ListViewItem item3 = new ListViewItem(currentCase[0].CaseTreatment);
            try
            {
                ltvTreatments.Items.AddRange(new ListViewItem[] { item1, item2, item3 });
            }
            catch (Exception ex)
            {

            }
        }



Re: AccessibilityObject

Posted: Fri 26 Jan 2018 07:09
by Woosha
One more thing guys, neither of the errors flagged stops program execution nor is flagged in a try/catch. The indication of the error was it does not populate the Listview and subsequent debugging revealed those errors noted.
thank you

Re: AccessibilityObject

Posted: Thu 01 Feb 2018 13:35
by Pinturiccio
Sorry for the late response.

Please create and send us a complete small test project which stably reproduces the issues. Send us also the DDL/DML scripts required for running this project and describe the steps which we should perform for reproducing the issue.