private void ScanResultGridview_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { PortInfo portRow = (PortInfo)portInfoBindingSource[e.RowIndex]; if (portRow != null) { switch (portRow.Open) { case true: e.CellStyle.BackColor = Color.LightGreen; break; case false: e.CellStyle.BackColor = Color.LightCoral; break; } } }
public MainForm() { InitializeComponent(); PortInfo.InitializePortDictionary(); Icon = Resources.PortScannerIcon; notifyIcon.Icon = Resources.PortScannerIcon; _portListForm = new PortListForm(); lbIpAddress.Text = Labels.IpAddress; lbPorts.Text = Labels.Ports; lbTimeout.Text = Labels.Timeout; btnSelectPort.Text = Labels.SelectPortButton; btnScan.Text = Labels.Scan; portGridViewColumn.HeaderText = Labels.PortColumn; descriptionGridViewColumn.HeaderText = Labels.DescriptionColumn; openGridViewColumn.HeaderText = Labels.OpenColumn; }