Ejemplo n.º 1
0
        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)
            {
                using (var f = new RowDetails {
                    dataRow = ThisDataRow, Owner = this
                })
                {
                    Program._serialPort.DataReceived -= new SerialDataReceivedEventHandler(DataReceivedHandler);
                    f.ShowDialog();
                }

                //form2 = new RowDetails(ThisDataRow);
                //form2.ShowDialog();

                //form2.ShowDataGridViewRow(ThisDataRow);
            }
            //do whatever you do in double click
        }
Ejemplo n.º 2
0
        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;
            }
        }