private void moveProductPositionButton_Click(object sender, EventArgs e) { int position = 0; Int32.TryParse(productPositionTextButton.Text.Trim(), out position); position--; if (position >= 0 && position < productBindingSource.Count) { productBindingSource.Position = position; } else { MessageBox.Show("Invalid row number. \nEnter a value from 1 to " + productBindingSource.Count); productPositionTextButton.Focus(); productPositionTextButton.SelectAll(); } productPositionLabel.Text = "of " + productBindingSource.Count; try { DataRowView currentDataRowView = (DataRowView)productBindingSource.Current; AdventureWorks2014_DataDataSet.ProductRow currentProductRow = (AdventureWorks2014_DataDataSet.ProductRow)currentDataRowView.Row; int productID = currentProductRow.ProductID; this.productInventoryLocationTableAdapter.FillByProductID( this.adventureWorks2014_DataDataSet.ProductInventoryLocation, productID); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
private void moveFirstButton_Click(object sender, EventArgs e) { productBindingSource.MoveFirst(); productPositionTextButton.Text = (productBindingSource.Position + 1).ToString(); productPositionLabel.Text = "of " + productBindingSource.Count; try { DataRowView currentDataRowView = (DataRowView)productBindingSource.Current; AdventureWorks2014_DataDataSet.ProductRow currentProductRow = (AdventureWorks2014_DataDataSet.ProductRow)currentDataRowView.Row; int productID = currentProductRow.ProductID; this.productInventoryLocationTableAdapter.FillByProductID( this.adventureWorks2014_DataDataSet.ProductInventoryLocation, productID); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }