Ejemplo n.º 1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 | e.RowIndex < 0)
            {
                return;
            }

            if (dataGridView1.Columns[e.ColumnIndex].Index == (int)COLUMNNAME.CHANNEL)
            {
                DataGridViewDisableButtonCell buttonCell =
                    (DataGridViewDisableButtonCell)dataGridView1.
                    Rows[e.RowIndex].Cells[(int)COLUMNNAME.CHANNEL];

                if (buttonCell.Enabled)
                {
                    //MessageBox.Show(dataGridView1.Rows[e.RowIndex].
                    //    Cells[e.ColumnIndex].Value.ToString() +
                    //    " is enabled");

                    //刷新地址
                    masterData_.refreshAddr();
                    modbusmasterchannel form = new modbusmasterchannel();
                    DeviceData          data = masterData_.modbusDeviceList.ElementAt(e.RowIndex);
                    form.getDeviceData(ref data, masterStartAddr_, ref masterData_, ref mastermanage, MID, e.RowIndex);
                    form.devicenumber(data.ID);
                    form.devaddr(dataGridView1.Rows[e.RowIndex].Cells["从站地址"].Value.ToString());
                    form.devname(dataGridView1.Rows[e.RowIndex].Cells["名称"].Value.ToString());
                    form.StartPosition = FormStartPosition.CenterScreen;
                    form.ShowDialog();
                }
            }
        }
Ejemplo n.º 2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 | e.RowIndex < 0)
            {
                return;
            }

            if (dataGridView1.Columns[e.ColumnIndex].Index == (int)COLUMNNAME.CHANNEL)
            {
                DataGridViewDisableButtonCell buttonCell =
                    (DataGridViewDisableButtonCell)dataGridView1.
                    Rows[e.RowIndex].Cells[(int)COLUMNNAME.CHANNEL];

                if (buttonCell.Enabled)
                {
                    //MessageBox.Show(dataGridView1.Rows[e.RowIndex].
                    //    Cells[e.ColumnIndex].Value.ToString() +
                    //    " is enabled");

                    modbusmasterchannel form = new modbusmasterchannel();
                    DeviceData          data = data_.modbusDeviceList.ElementAt(e.RowIndex);
                    form.getDeviceData(ref data);
                    form.ShowDialog();
                }
            }
        }