/// <summary> /// /// </summary> private void UseFilter() { // without this line we will get an exception :/ da fuq! DGV_HTTPRequests.CurrentCell = null; for (int lCounter = 0; lCounter < DGV_HTTPRequests.RowCount; lCounter++) { try { // this.dataGridView1.Columns["CustomerID"].Visible = false; if (TB_Filter.Text.Length <= 0) { DGV_HTTPRequests.Rows[lCounter].Visible = true; } else { try { String lData = DGV_HTTPRequests.Rows[lCounter].Cells["URL"].Value.ToString(); if (!Regex.Match(lData, Regex.Escape(TB_Filter.Text), RegexOptions.IgnoreCase).Success) { DGV_HTTPRequests.Rows[lCounter].Visible = false; } else { DGV_HTTPRequests.Rows[lCounter].Visible = true; } } catch (Exception lEx) { PluginParameters.HostApplication.LogMessage(String.Format("{0}: {1}", Config.PluginName, lEx.Message)); } } } catch (Exception lEx) { PluginParameters.HostApplication.LogMessage(String.Format("{0}: {1}", Config.PluginName, lEx.Message)); } } DGV_HTTPRequests.Refresh(); }
public void update(List <HTTPRequests> pHTTPReqList) { lock (this) { bool lIsLastLine = false; int lLastPosition = -1; int lLastRowIndex = -1; int lSelectedIndex = -1; /* * Remember DGV positions */ if (DGV_HTTPRequests.CurrentRow != null && DGV_HTTPRequests.CurrentRow == DGV_HTTPRequests.Rows[DGV_HTTPRequests.Rows.Count - 1]) { lIsLastLine = true; } lLastPosition = DGV_HTTPRequests.FirstDisplayedScrollingRowIndex; lLastRowIndex = DGV_HTTPRequests.Rows.Count - 1; if (DGV_HTTPRequests.CurrentCell != null) { lSelectedIndex = DGV_HTTPRequests.CurrentCell.RowIndex; } cHTTPRequests.Clear(); foreach (HTTPRequests lTmp in pHTTPReqList) { cHTTPRequests.Add(lTmp); // Filter try { if (!CompareToFilter(DGV_HTTPRequests.Rows[DGV_HTTPRequests.Rows.Count - 1].Cells["URL"].Value.ToString())) { DGV_HTTPRequests.Rows[DGV_HTTPRequests.Rows.Count - 1].Visible = false; } } catch (Exception lEx) { PluginParameters.HostApplication.LogMessage(String.Format("{0}: {1}", Config.PluginName, lEx.Message)); } } // foreach (HT... // Selected cell/row try { if (lSelectedIndex >= 0) { DGV_HTTPRequests.CurrentCell = DGV_HTTPRequests.Rows[lSelectedIndex].Cells[0]; } } catch { } // Reset position try { if (lIsLastLine) { DGV_HTTPRequests.Rows[DGV_HTTPRequests.Rows.Count - 1].Selected = true; DGV_HTTPRequests.FirstDisplayedScrollingRowIndex = lLastPosition + 1; } else { DGV_HTTPRequests.FirstDisplayedScrollingRowIndex = lLastPosition; } } catch { } DGV_HTTPRequests.Refresh(); } }