Beispiel #1
0
        private void bindingItem_ListChanged(object sender, ListChangedEventArgs e)
        {
            /* This event will be called several times during form initialization.
             * We don't want to do anything with it until the runtime author
             * list has been passed in. */

            // Exit if no parent
            InvoiceItem parent = (InvoiceItem)bindingInvoice.Current;

            if (parent == null)
            {
                return;
            }

            // Get the item affected
            int      index       = e.NewIndex;
            rotiItem changedItem = null;

            if ((index > -1) && (index < parent.Items.Count))
            {
                changedItem = parent.Items[index];
            }

            // Get the type of change that occured
            ListChangedType changeType = e.ListChangedType;

            /* We only need to respond to two types of changes here; updates
             * and moves. Adds are handled by bindingSourceAuthors_AddingNew(),
             * and deletes are handled by menuItemBooksDelete_Click(). */

            // Dispatch a change handler
            switch (changeType)
            {
            case ListChangedType.ItemChanged:
                if (changedItem.ItemCode != null)
                {
                    CommandUpdateItem updateItem = new CommandUpdateItem(changedItem);
                    m_AppController.ExecuteCommand(updateItem);
                }
                else
                {
                    CommandDeleteItem deleteItem = new CommandDeleteItem(changedItem);
                    m_AppController.ExecuteCommand(deleteItem);
                }

                break;

            case ListChangedType.ItemMoved:
                // Not supported in this app
                break;
            }

            m_Invoices.ResetBindings();
        }
 private void button1_Click(object sender, EventArgs e)
 {
     m_InvoiceList.ResetBindings();
 }