private void SetText2(string text) { RowDetails activeForm = (RowDetails)Form.ActiveForm; TextBox tbx = activeForm.Controls["textBox4"] as TextBox; // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (tbx.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetText2); this.Invoke(d, new object[] { text }); } else { tbx.Text = text; } }
private void regionDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridView thisGrid = (DataGridView)sender; BindingSource thisBindingSource = (BindingSource)thisGrid.DataSource; DataRow ThisDataRow = ((DataRowView)thisBindingSource.Current).Row; //DataTable table = (DataTable)thisGrid.DataSource; //DataRow ThisDataRow = table.Rows[thisGrid.CurrentCell.RowIndex]; //Convert the current selected row in the DataGridView to a DataRow //DataRowView ThisDataRow = (DataRowView)regionDataGridView.CurrentRow.DataBoundItem; //mainDataRow = employee.Select("PLU='" + currentDataRowView[0].ToString() + "'"); //get the primary key id //BindingSource thisBindingSource = (BindingSource)sender; //DataRow ThisDataRow = ((DataRowView)thisBindingSource.Current).Row; if (null != ThisDataRow) { //Izbrishi gi event handler-ite this.SerialEventListener_Pause(); this._listener.RemoveDataReceivedHandler(); using (var productDetails = new RowDetails(this._serialPort)) { productDetails.dataRow = ThisDataRow; productDetails._repository = this._repository; productDetails.Owner = this; productDetails.StartPosition = FormStartPosition.CenterParent; productDetails.ShowDialog(); } //Vrati gi event hadler-ite this._listener = new BarcodeListener(this); this.SerialEventListener_Start(); //form2 = new RowDetails(ThisDataRow); //form2.ShowDialog(); //form2.ShowDataGridViewRow(ThisDataRow); } //do whatever you do in double click }
private void tbAddNewProduct_Click(object sender, EventArgs e) { //DataRow NewDataRow = ((DataTable)this.regionDataGridView.DataSource).NewRow(); //this.articlesBindingSource.DataSource BindingSource thisBindingSource = (BindingSource)this.regionDataGridView.DataSource; DataRow NewDataRow = ((DataTable)thisBindingSource.DataSource).NewRow(); //Izbrishi gi event handler-ite this.SerialEventListener_Pause(); this._listener.RemoveDataReceivedHandler(); using (var productDetails = new RowDetails(this._serialPort)) { productDetails.dataRow = NewDataRow; productDetails._repository = this._repository; productDetails.Owner = this; productDetails.StartPosition = FormStartPosition.CenterParent; productDetails.ShowDialog(); } //Vrati gi event hadler-ite this._listener = new BarcodeListener(this); this.SerialEventListener_Start(); RefreshView(null); //do whatever you do in double click }