private void ShowLedOnRow(DataGridViewRow row, OutDoorLed led) { row.Cells["colComport"].Value = led.Commport; row.Cells["colBaud"].Value = led.Baud; row.Cells["colCarAddress"].Value = led.CarLedAddress; row.Cells["colMotorAddress"].Value = led.MotorLedAddress; row.Cells["colBrightness"].Value = led.Brightness; row.Tag = led; }
private void mnu_Add_Click(object sender, EventArgs e) { FrmLEDDetail frm = new FrmLEDDetail(); if (frm.ShowDialog() == DialogResult.OK) { OutDoorLed led = new OutDoorLed() { Commport = frm.Commport, Baud = frm.BaudRate, CarLedAddress = frm.CarAddress, MotorLedAddress = frm.MotorAddress, Brightness = frm.Brightness, }; int row = ledGrid.Rows.Add(); ShowLedOnRow(ledGrid.Rows[row], led); } }
private void mnu_Update_Click(object sender, EventArgs e) { if (ledGrid.SelectedRows.Count == 1) { OutDoorLed led = ledGrid.SelectedRows[0].Tag as OutDoorLed; FrmLEDDetail frm = new FrmLEDDetail(); frm.Commport = led.Commport; frm.BaudRate = led.Baud; frm.CarAddress = led.CarLedAddress; frm.MotorAddress = led.MotorLedAddress; frm.Brightness = led.Brightness; if (frm.ShowDialog() == DialogResult.OK) { led.Commport = frm.Commport; led.Baud = frm.BaudRate; led.CarLedAddress = frm.CarAddress; led.MotorLedAddress = frm.MotorAddress; led.Brightness = frm.Brightness; ShowLedOnRow(ledGrid.SelectedRows[0], led); } } }