Пример #1
0
        private void btncreatedata_Click(object sender, RoutedEventArgs e)
        {
            CreateCustomer createCustomer = new CreateCustomer();

            createCustomer.type = "Create";
            createCustomer.SubmitButton.Content = createCustomer.type;
            createCustomer.Show();
        }
Пример #2
0
        private void DataGrid_MouseRightButtonUp(object sender,
                                                 MouseButtonEventArgs e)
        {
            DependencyObject dep = (DependencyObject)e.OriginalSource;

            // iteratively traverse the visual tree
            while ((dep != null) &&
                   !(dep is DataGridCell) &&
                   !(dep is DataGridColumnHeader))
            {
                dep = VisualTreeHelper.GetParent(dep);
            }

            if (dep == null)
            {
                return;
            }

            if (dep is DataGridColumnHeader)
            {
                DataGridColumnHeader columnHeader = dep as DataGridColumnHeader;
                // do something
            }

            if (dep is DataGridCell)
            {
                DataGridCell cell = dep as DataGridCell;

                // navigate further up the tree
                while ((dep != null) && !(dep is DataGridRow))
                {
                    dep = VisualTreeHelper.GetParent(dep);
                }

                DataGridRow    row            = dep as DataGridRow;
                var            rowIndex       = this.FindRowIndex(row);
                CreateCustomer createCustomer = new CreateCustomer();
                createCustomer.Title = "Update Customer";
                createCustomer.type  = "Update";
                createCustomer.SubmitButton.Content     = createCustomer.type;
                createCustomer.CompanyNameTextBox.Text  = ds.Tables[0].Rows[rowIndex]["CompanyName"].ToString();
                createCustomer.ContactTitleTextBox.Text = ds.Tables[0].Rows[rowIndex]["ContactTitle"].ToString();
                createCustomer.AddressTextBox.Text      = ds.Tables[0].Rows[rowIndex]["Address"].ToString();
                createCustomer.ContactNoTextBox.Text    = ds.Tables[0].Rows[rowIndex]["ContactNo"].ToString();
                createCustomer.customerId = ds.Tables[0].Rows[rowIndex]["CustomerID"].ToString();
                createCustomer.Show();
            }
        }