private void SelectedIndexChanged(object sender, EventArgs e) { var listView = (ListView)sender; if (0 < listView.SelectedItems.Count) { var header = listView.SelectedItems[0].Text; buttonEdit.Enabled = buttonRemove.Enabled = HttpHeaderProvider.IsEditable(header); } }
public void SetHttpHeaders(WebHeaderCollection headers) { listViewHeaders.BeginUpdate(); try { listViewHeaders.Items.Clear(); foreach (string header in headers) { var foreColor = Color.FromKnownColor(HttpHeaderProvider.IsEditable(header) ? KnownColor.WindowText : KnownColor.InactiveCaption); var item = new ListViewItem(new[] { header, headers[header] }, -1, foreColor, listViewHeaders.BackColor, null); listViewHeaders.Items.Add(item); } } finally { listViewHeaders.EndUpdate(); } }