├── AdvancedDataGridView ├── AdvancedDataGridView.cs ├── AdvancedDataGridView.csproj ├── AdvancedDataGridView.nuspec ├── AdvancedDataGridViewSearchToolBar.cs ├── AdvancedDataGridViewSearchToolBar.designer.cs ├── AdvancedDataGridViewSearchToolBar.resx ├── ColumnHeaderCell.cs ├── FormCustomFilter.Designer.cs ├── FormCustomFilter.cs ├── FormCustomFilter.resx ├── MenuStrip.cs ├── MenuStrip.designer.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Resources │ └── Images │ │ ├── AdvancedDataGridView_logo.png │ │ ├── ColumnHeader_Filtered.png │ │ ├── ColumnHeader_FilteredAndOrderedASC.png │ │ ├── ColumnHeader_FilteredAndOrderedDESC.png │ │ ├── ColumnHeader_OrderedASC.png │ │ ├── ColumnHeader_OrderedDESC.png │ │ ├── ColumnHeader_SavedFilters.png │ │ ├── ColumnHeader_UnFiltered.png │ │ ├── MenuStrip_OrderASCbool.png │ │ ├── MenuStrip_OrderASCnum.png │ │ ├── MenuStrip_OrderASCtxt.png │ │ ├── MenuStrip_OrderDESCbool.png │ │ ├── MenuStrip_OrderDESCnum.png │ │ ├── MenuStrip_OrderDESCtxt.png │ │ ├── MenuStrip_ResizeGrip.png │ │ ├── SearchToolBar_ButtonCaseSensitive.png │ │ ├── SearchToolBar_ButtonClose.png │ │ ├── SearchToolBar_ButtonFromBegin.png │ │ ├── SearchToolBar_ButtonSearch.png │ │ └── SearchToolBar_ButtonWholeWord.png ├── TreeNodeItemSelector.cs └── bin │ └── Debug │ ├── AdvancedDataGridView.dll │ └── AdvancedDataGridView.pdb ├── AdvancedDataGridViewDataModel.sln ├── AdvancedDataGridViewDataModel ├── AdvancedDataGridViewDataModel.csproj ├── App.config ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Model │ └── DataModel.cs ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── bin │ └── Debug │ │ ├── AdvancedDataGridView.dll │ │ ├── AdvancedDataGridView.pdb │ │ ├── AdvancedDataGridViewDataTable.exe │ │ ├── AdvancedDataGridViewDataTable.exe.config │ │ ├── AdvancedDataGridViewDataTable.pdb │ │ └── System.Linq.Dynamic.dll └── packages.config ├── README.md ├── ScreenShot.png └── packages └── System.Linq.Dynamic.1.0.7 ├── NuGet.exe ├── System.Linq.Dynamic.1.0.7.nupkg └── lib └── net40 └── System.Linq.Dynamic.dll /AdvancedDataGridView/AdvancedDataGridView.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {6EBA0A55-B390-4479-A564-58D46094998D} 9 | Library 10 | Properties 11 | Zuby 12 | AdvancedDataGridView 13 | v4.0 14 | 512 15 | SAK 16 | SAK 17 | SAK 18 | SAK 19 | 20 | 21 | 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | 32 | 33 | pdbonly 34 | true 35 | bin\Release\ 36 | TRACE 37 | prompt 38 | 4 39 | 40 | 41 | false 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | MenuStrip.cs 60 | 61 | 62 | 63 | True 64 | True 65 | Resources.resx 66 | 67 | 68 | 69 | AdvancedDataGridViewSearchToolBar.cs 70 | 71 | 72 | Form 73 | 74 | 75 | FormCustomFilter.cs 76 | 77 | 78 | 79 | 80 | 81 | AdvancedDataGridViewSearchToolBar.cs 82 | 83 | 84 | ResXFileCodeGenerator 85 | Designer 86 | Resources.Designer.cs 87 | 88 | 89 | FormCustomFilter.cs 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 125 | -------------------------------------------------------------------------------- /AdvancedDataGridView/AdvancedDataGridView.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DG.AdvancedDataGridView 5 | $version$ 6 | Advanced DataGridView 7 | $author$ 8 | $author$ 9 | https://opensource.org/licenses/MS-PL 10 | https://github.com/davidegironi/advanceddatagridview 11 | https://github.com/davidegironi/advanceddatagridview/raw/master/AdvancedDataGridView/Resources/Images/AdvancedDataGridView_logo.png 12 | false 13 | $description$ 14 | $copyright$ 15 | DataGridView, WinForm, Advanced, Enhanced, Table, Grid, Filter, Sort 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /AdvancedDataGridView/AdvancedDataGridViewSearchToolBar.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // Advanced DataGridView 3 | // 4 | // Copyright (c), 2014 Davide Gironi 5 | // Original work Copyright (c), 2013 Zuby 6 | // 7 | // Please refer to LICENSE file for licensing information. 8 | #endregion 9 | 10 | using System; 11 | using System.Collections; 12 | using System.Drawing; 13 | using System.Linq; 14 | using System.Windows.Forms; 15 | 16 | namespace Zuby.ADGV 17 | { 18 | 19 | [System.ComponentModel.DesignerCategory("")] 20 | public partial class AdvancedDataGridViewSearchToolBar : ToolStrip 21 | { 22 | 23 | #region public events 24 | 25 | public event AdvancedDataGridViewSearchToolBarSearchEventHandler Search; 26 | 27 | #endregion 28 | 29 | 30 | #region class properties 31 | 32 | private DataGridViewColumnCollection _columnsList = null; 33 | 34 | private const bool ButtonCloseEnabled = false; 35 | private Hashtable _textStrings = new Hashtable(); 36 | 37 | #endregion 38 | 39 | 40 | #region constructor 41 | 42 | /// 43 | /// AdvancedDataGridViewSearchToolBar constructor 44 | /// 45 | public AdvancedDataGridViewSearchToolBar() 46 | { 47 | //set localization strings 48 | _textStrings.Add("LABELSEARCH", "Search:"); 49 | _textStrings.Add("BUTTONFROMBEGINTOOLTIP", "From Begin"); 50 | _textStrings.Add("BUTTONCASESENSITIVETOOLTIP", "Case Sensitivity"); 51 | _textStrings.Add("BUTTONSEARCHTOOLTIP", "Find Next"); 52 | _textStrings.Add("BUTTONCLOSETOOLTIP", "Hide"); 53 | _textStrings.Add("BUTTONWHOLEWORDTOOLTIP", "Search only Whole Word"); 54 | _textStrings.Add("COMBOBOXCOLUMNSALL", "(All Columns)"); 55 | _textStrings.Add("TEXTBOXSEARCHTOOLTIP", "Value for Search"); 56 | 57 | //initialize components 58 | InitializeComponent(); 59 | 60 | this.comboBox_columns.Items.AddRange(new object[] { _textStrings["COMBOBOXCOLUMNSALL"].ToString() }); 61 | this.button_close.ToolTipText = _textStrings["BUTTONCLOSETOOLTIP"].ToString(); 62 | this.label_search.Text = _textStrings["LABELSEARCH"].ToString(); 63 | this.textBox_search.ToolTipText = _textStrings["TEXTBOXSEARCHTOOLTIP"].ToString(); 64 | this.button_frombegin.ToolTipText = _textStrings["BUTTONFROMBEGINTOOLTIP"].ToString(); 65 | this.button_casesensitive.ToolTipText = _textStrings["BUTTONCASESENSITIVETOOLTIP"].ToString(); 66 | this.button_search.ToolTipText = _textStrings["BUTTONSEARCHTOOLTIP"].ToString(); 67 | this.button_wholeword.ToolTipText = _textStrings["BUTTONWHOLEWORDTOOLTIP"].ToString(); 68 | 69 | //set default values 70 | if (!ButtonCloseEnabled) 71 | this.Items.RemoveAt(0); 72 | textBox_search.Text = textBox_search.ToolTipText; 73 | comboBox_columns.SelectedIndex = 0; 74 | } 75 | 76 | #endregion 77 | 78 | 79 | #region button events 80 | 81 | /// 82 | /// button Search Click event 83 | /// 84 | /// 85 | /// 86 | void button_search_Click(object sender, System.EventArgs e) 87 | { 88 | if (textBox_search.TextLength > 0 && textBox_search.Text != textBox_search.ToolTipText && Search != null) 89 | { 90 | DataGridViewColumn c = null; 91 | if (comboBox_columns.SelectedIndex > 0 && _columnsList != null && _columnsList.GetColumnCount(DataGridViewElementStates.Visible) > 0) 92 | { 93 | DataGridViewColumn[] cols = _columnsList.Cast().Where(col => col.Visible).ToArray(); 94 | 95 | if (cols.Length == comboBox_columns.Items.Count - 1) 96 | { 97 | if (cols[comboBox_columns.SelectedIndex - 1].HeaderText == comboBox_columns.SelectedItem.ToString()) 98 | c = cols[comboBox_columns.SelectedIndex - 1]; 99 | } 100 | } 101 | 102 | AdvancedDataGridViewSearchToolBarSearchEventArgs args = new AdvancedDataGridViewSearchToolBarSearchEventArgs( 103 | textBox_search.Text, 104 | c, 105 | button_casesensitive.Checked, 106 | button_wholeword.Checked, 107 | button_frombegin.Checked 108 | ); 109 | Search(this, args); 110 | } 111 | } 112 | 113 | /// 114 | /// button Close Click event 115 | /// 116 | /// 117 | /// 118 | void button_close_Click(object sender, System.EventArgs e) 119 | { 120 | Hide(); 121 | } 122 | 123 | #endregion 124 | 125 | 126 | #region textbox search events 127 | 128 | /// 129 | /// textBox Search TextChanged event 130 | /// 131 | /// 132 | /// 133 | void textBox_search_TextChanged(object sender, System.EventArgs e) 134 | { 135 | button_search.Enabled = textBox_search.TextLength > 0 && textBox_search.Text != textBox_search.ToolTipText; 136 | } 137 | 138 | 139 | /// 140 | /// textBox Search Enter event 141 | /// 142 | /// 143 | /// 144 | void textBox_search_Enter(object sender, System.EventArgs e) 145 | { 146 | if (textBox_search.Text == textBox_search.ToolTipText && textBox_search.ForeColor == System.Drawing.Color.LightGray) 147 | textBox_search.Text = ""; 148 | else 149 | textBox_search.SelectAll(); 150 | 151 | textBox_search.ForeColor = SystemColors.WindowText; 152 | } 153 | 154 | /// 155 | /// textBox Search Leave event 156 | /// 157 | /// 158 | /// 159 | void textBox_search_Leave(object sender, System.EventArgs e) 160 | { 161 | if (textBox_search.Text.Trim() == "") 162 | { 163 | textBox_search.Text = textBox_search.ToolTipText; 164 | textBox_search.ForeColor = System.Drawing.Color.LightGray; 165 | } 166 | } 167 | 168 | 169 | /// 170 | /// textBox Search KeyDown event 171 | /// 172 | /// 173 | /// 174 | void textBox_search_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) 175 | { 176 | if (textBox_search.TextLength > 0 && textBox_search.Text != textBox_search.ToolTipText && e.KeyData == Keys.Enter) 177 | { 178 | button_search_Click(button_search, new EventArgs()); 179 | e.SuppressKeyPress = true; 180 | e.Handled = true; 181 | } 182 | } 183 | 184 | #endregion 185 | 186 | 187 | #region public methods 188 | 189 | /// 190 | /// Set Columns to search in 191 | /// 192 | /// 193 | public void SetColumns(DataGridViewColumnCollection columns) 194 | { 195 | _columnsList = columns; 196 | comboBox_columns.BeginUpdate(); 197 | comboBox_columns.Items.Clear(); 198 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AdvancedDataGridViewSearchToolBar)); 199 | comboBox_columns.Items.AddRange(new object[] { "(All columns)" }); 200 | if (_columnsList != null) 201 | foreach (DataGridViewColumn c in _columnsList) 202 | if (c.Visible) 203 | comboBox_columns.Items.Add(c.HeaderText); 204 | comboBox_columns.SelectedIndex = 0; 205 | comboBox_columns.EndUpdate(); 206 | } 207 | 208 | #endregion 209 | 210 | 211 | #region resize events 212 | 213 | /// 214 | /// Resize event 215 | /// 216 | /// 217 | /// 218 | private void ResizeMe(object sender, System.EventArgs e) 219 | { 220 | SuspendLayout(); 221 | int w1 = 150; 222 | int w2 = 150; 223 | int oldW = comboBox_columns.Width + textBox_search.Width; 224 | foreach (System.Windows.Forms.ToolStripItem c in Items) 225 | { 226 | c.Overflow = ToolStripItemOverflow.Never; 227 | c.Visible = true; 228 | } 229 | 230 | int width = PreferredSize.Width - oldW + w1 + w2; 231 | if (Width < width) 232 | { 233 | label_search.Visible = false; 234 | GetResizeBoxSize(PreferredSize.Width - oldW + w1 + w2, ref w1, ref w2); 235 | width = PreferredSize.Width - oldW + w1 + w2; 236 | 237 | if (Width < width) 238 | { 239 | button_casesensitive.Overflow = ToolStripItemOverflow.Always; 240 | GetResizeBoxSize(PreferredSize.Width - oldW + w1 + w2, ref w1, ref w2); 241 | width = PreferredSize.Width - oldW + w1 + w2; 242 | } 243 | 244 | if (Width < width) 245 | { 246 | button_wholeword.Overflow = ToolStripItemOverflow.Always; 247 | GetResizeBoxSize(PreferredSize.Width - oldW + w1 + w2, ref w1, ref w2); 248 | width = PreferredSize.Width - oldW + w1 + w2; 249 | } 250 | 251 | if (Width < width) 252 | { 253 | button_frombegin.Overflow = ToolStripItemOverflow.Always; 254 | separator_search.Visible = false; 255 | GetResizeBoxSize(PreferredSize.Width - oldW + w1 + w2, ref w1, ref w2); 256 | width = PreferredSize.Width - oldW + w1 + w2; 257 | } 258 | 259 | if (Width < width) 260 | { 261 | comboBox_columns.Overflow = ToolStripItemOverflow.Always; 262 | textBox_search.Overflow = ToolStripItemOverflow.Always; 263 | w1 = 150; 264 | w2 = Math.Max(Width - PreferredSize.Width - textBox_search.Margin.Left - textBox_search.Margin.Right, 75); 265 | textBox_search.Overflow = ToolStripItemOverflow.Never; 266 | width = PreferredSize.Width - textBox_search.Width + w2; 267 | } 268 | if (Width < width) 269 | { 270 | button_search.Overflow = ToolStripItemOverflow.Always; 271 | w2 = Math.Max(Width - PreferredSize.Width + textBox_search.Width, 75); 272 | width = PreferredSize.Width - textBox_search.Width + w2; 273 | } 274 | if (Width < width) 275 | { 276 | button_close.Overflow = ToolStripItemOverflow.Always; 277 | textBox_search.Margin = new System.Windows.Forms.Padding(8, 2, 8, 2); 278 | w2 = Math.Max(Width - PreferredSize.Width + textBox_search.Width, 75); 279 | width = PreferredSize.Width - textBox_search.Width + w2; 280 | } 281 | 282 | if (Width < width) 283 | { 284 | w2 = Math.Max(Width - PreferredSize.Width + textBox_search.Width, 20); 285 | width = PreferredSize.Width - textBox_search.Width + w2; 286 | } 287 | if (width > Width) 288 | { 289 | textBox_search.Overflow = ToolStripItemOverflow.Always; 290 | textBox_search.Margin = new System.Windows.Forms.Padding(0, 2, 8, 2); 291 | w2 = 150; 292 | } 293 | } 294 | else 295 | { 296 | GetResizeBoxSize(width, ref w1, ref w2); 297 | } 298 | 299 | if (comboBox_columns.Width != w1) 300 | comboBox_columns.Width = w1; 301 | if (textBox_search.Width != w2) 302 | textBox_search.Width = w2; 303 | 304 | ResumeLayout(); 305 | } 306 | 307 | 308 | 309 | /// 310 | /// Get a Resize Size for a box 311 | /// 312 | /// 313 | /// 314 | /// 315 | private void GetResizeBoxSize(int width, ref int w1, ref int w2) 316 | { 317 | int dif = (int)Math.Round((width - Width) / 2.0, 0, MidpointRounding.AwayFromZero); 318 | 319 | int oldW1 = w1; 320 | int oldW2 = w2; 321 | if (Width < width) 322 | { 323 | w1 = Math.Max(w1 - dif, 75); 324 | w2 = Math.Max(w2 - dif, 75); 325 | } 326 | else 327 | { 328 | w1 = Math.Min(w1 - dif, 150); 329 | w2 += Width - width + oldW1 - w1; 330 | } 331 | } 332 | 333 | #endregion 334 | 335 | } 336 | 337 | public delegate void AdvancedDataGridViewSearchToolBarSearchEventHandler(object sender, AdvancedDataGridViewSearchToolBarSearchEventArgs e); 338 | public class AdvancedDataGridViewSearchToolBarSearchEventArgs : EventArgs 339 | { 340 | public string ValueToSearch { get; private set; } 341 | public DataGridViewColumn ColumnToSearch { get; private set; } 342 | public bool CaseSensitive { get; private set; } 343 | public bool WholeWord { get; private set; } 344 | public bool FromBegin { get; private set; } 345 | 346 | public AdvancedDataGridViewSearchToolBarSearchEventArgs(string Value, DataGridViewColumn Column, bool Case, bool Whole, bool fromBegin) 347 | { 348 | ValueToSearch = Value; 349 | ColumnToSearch = Column; 350 | CaseSensitive = Case; 351 | WholeWord = Whole; 352 | FromBegin = fromBegin; 353 | } 354 | } 355 | } 356 | -------------------------------------------------------------------------------- /AdvancedDataGridView/AdvancedDataGridViewSearchToolBar.designer.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace Zuby.ADGV 3 | { 4 | partial class AdvancedDataGridViewSearchToolBar 5 | { 6 | /// 7 | /// Required designer variable. 8 | /// 9 | private System.ComponentModel.IContainer components = null; 10 | 11 | /// 12 | /// Clean up any resources being used. 13 | /// 14 | /// true if managed resources should be disposed; otherwise, false. 15 | protected override void Dispose(bool disposing) 16 | { 17 | if (disposing && (components != null)) 18 | { 19 | components.Dispose(); 20 | } 21 | base.Dispose(disposing); 22 | } 23 | 24 | #region Windows Form Designer generated code 25 | 26 | /// 27 | /// Required method for Designer support - do not modify 28 | /// the contents of this method with the code editor. 29 | /// 30 | private void InitializeComponent() 31 | { 32 | this.button_close = new System.Windows.Forms.ToolStripButton(); 33 | this.label_search = new System.Windows.Forms.ToolStripLabel(); 34 | this.comboBox_columns = new System.Windows.Forms.ToolStripComboBox(); 35 | this.textBox_search = new System.Windows.Forms.ToolStripTextBox(); 36 | this.button_frombegin = new System.Windows.Forms.ToolStripButton(); 37 | this.button_casesensitive = new System.Windows.Forms.ToolStripButton(); 38 | this.button_search = new System.Windows.Forms.ToolStripButton(); 39 | this.button_wholeword = new System.Windows.Forms.ToolStripButton(); 40 | this.separator_search = new System.Windows.Forms.ToolStripSeparator(); 41 | this.SuspendLayout(); 42 | // 43 | // button_close 44 | // 45 | this.button_close.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; 46 | this.button_close.Image = global::Zuby.Properties.Resources.SearchToolBar_ButtonCaseSensitive; 47 | this.button_close.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; 48 | this.button_close.ImageTransparentColor = System.Drawing.Color.Magenta; 49 | this.button_close.Name = "button_close"; 50 | this.button_close.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; 51 | this.button_close.Size = new System.Drawing.Size(23, 24); 52 | this.button_close.Click += new System.EventHandler(this.button_close_Click); 53 | // 54 | // label_search 55 | // 56 | this.label_search.Name = "label_search"; 57 | this.label_search.Size = new System.Drawing.Size(45, 15); 58 | 59 | // 60 | // comboBox_columns 61 | // 62 | this.comboBox_columns.AutoSize = false; 63 | this.comboBox_columns.AutoToolTip = true; 64 | this.comboBox_columns.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 65 | this.comboBox_columns.FlatStyle = System.Windows.Forms.FlatStyle.Standard; 66 | this.comboBox_columns.IntegralHeight = false; 67 | this.comboBox_columns.Margin = new System.Windows.Forms.Padding(0, 2, 8, 2); 68 | this.comboBox_columns.MaxDropDownItems = 12; 69 | this.comboBox_columns.Name = "comboBox_columns"; 70 | this.comboBox_columns.Size = new System.Drawing.Size(150, 23); 71 | // 72 | // textBox_search 73 | // 74 | this.textBox_search.AutoSize = false; 75 | this.textBox_search.ForeColor = System.Drawing.Color.LightGray; 76 | this.textBox_search.Margin = new System.Windows.Forms.Padding(0, 2, 8, 2); 77 | this.textBox_search.Name = "textBox_search"; 78 | this.textBox_search.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; 79 | this.textBox_search.Size = new System.Drawing.Size(100, 23); 80 | this.textBox_search.Enter += new System.EventHandler(this.textBox_search_Enter); 81 | this.textBox_search.Leave += new System.EventHandler(this.textBox_search_Leave); 82 | this.textBox_search.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox_search_KeyDown); 83 | this.textBox_search.TextChanged += new System.EventHandler(this.textBox_search_TextChanged); 84 | // 85 | // button_frombegin 86 | // 87 | this.button_frombegin.CheckOnClick = true; 88 | this.button_frombegin.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; 89 | this.button_frombegin.Image = global::Zuby.Properties.Resources.SearchToolBar_ButtonFromBegin; 90 | this.button_frombegin.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; 91 | this.button_frombegin.ImageTransparentColor = System.Drawing.Color.Magenta; 92 | this.button_frombegin.Name = "button_frombegin"; 93 | this.button_frombegin.Size = new System.Drawing.Size(23, 20); 94 | // 95 | // button_casesensitive 96 | // 97 | this.button_casesensitive.CheckOnClick = true; 98 | this.button_casesensitive.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; 99 | this.button_casesensitive.Image = global::Zuby.Properties.Resources.SearchToolBar_ButtonCaseSensitive; 100 | this.button_casesensitive.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; 101 | this.button_casesensitive.ImageTransparentColor = System.Drawing.Color.Magenta; 102 | this.button_casesensitive.Name = "button_casesensitive"; 103 | this.button_casesensitive.Size = new System.Drawing.Size(23, 20); 104 | // 105 | // button_search 106 | // 107 | this.button_search.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; 108 | this.button_search.Image = global::Zuby.Properties.Resources.SearchToolBar_ButtonSearch; 109 | this.button_search.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; 110 | this.button_search.ImageTransparentColor = System.Drawing.Color.Magenta; 111 | this.button_search.Name = "button_search"; 112 | this.button_search.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; 113 | this.button_search.Size = new System.Drawing.Size(23, 24); 114 | this.button_search.Click += new System.EventHandler(this.button_search_Click); 115 | // 116 | // button_wholeword 117 | // 118 | this.button_wholeword.CheckOnClick = true; 119 | this.button_wholeword.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; 120 | this.button_wholeword.Image = global::Zuby.Properties.Resources.SearchToolBar_ButtonWholeWord; 121 | this.button_wholeword.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; 122 | this.button_wholeword.ImageTransparentColor = System.Drawing.Color.Magenta; 123 | this.button_wholeword.Margin = new System.Windows.Forms.Padding(1, 1, 1, 2); 124 | this.button_wholeword.Name = "button_wholeword"; 125 | this.button_wholeword.Size = new System.Drawing.Size(23, 20); 126 | // 127 | // separator_search 128 | // 129 | this.separator_search.AutoSize = false; 130 | this.separator_search.Name = "separator_search"; 131 | this.separator_search.Size = new System.Drawing.Size(10, 25); 132 | // 133 | // AdvancedDataGridViewSearchToolBar 134 | // 135 | this.AllowMerge = false; 136 | this.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; 137 | this.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 138 | this.button_close, 139 | this.label_search, 140 | this.comboBox_columns, 141 | this.textBox_search, 142 | this.button_frombegin, 143 | this.button_wholeword, 144 | this.button_casesensitive, 145 | this.separator_search, 146 | this.button_search}); 147 | this.MaximumSize = new System.Drawing.Size(0, 27); 148 | this.MinimumSize = new System.Drawing.Size(0, 27); 149 | this.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; 150 | this.Size = new System.Drawing.Size(0, 27); 151 | this.Resize += new System.EventHandler(this.ResizeMe); 152 | this.ResumeLayout(false); 153 | this.PerformLayout(); 154 | 155 | } 156 | 157 | #endregion 158 | 159 | private System.Windows.Forms.ToolStripButton button_close; 160 | private System.Windows.Forms.ToolStripLabel label_search; 161 | private System.Windows.Forms.ToolStripComboBox comboBox_columns; 162 | private System.Windows.Forms.ToolStripTextBox textBox_search; 163 | private System.Windows.Forms.ToolStripButton button_frombegin; 164 | private System.Windows.Forms.ToolStripButton button_casesensitive; 165 | private System.Windows.Forms.ToolStripButton button_search; 166 | private System.Windows.Forms.ToolStripButton button_wholeword; 167 | private System.Windows.Forms.ToolStripSeparator separator_search; 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /AdvancedDataGridView/AdvancedDataGridViewSearchToolBar.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | False 122 | 123 | -------------------------------------------------------------------------------- /AdvancedDataGridView/ColumnHeaderCell.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // Advanced DataGridView 3 | // 4 | // Original work Copyright (c), 2013 Zuby 5 | // Modified work Copyright (c), 2014 Davide Gironi 6 | // 7 | // Please refer to LICENSE file for licensing information. 8 | #endregion 9 | 10 | using System; 11 | using System.Drawing; 12 | using System.Windows.Forms; 13 | 14 | namespace Zuby.ADGV 15 | { 16 | 17 | [System.ComponentModel.DesignerCategory("")] 18 | internal class ColumnHeaderCell : DataGridViewColumnHeaderCell 19 | { 20 | 21 | #region public events 22 | 23 | public event ColumnHeaderCellEventHandler FilterPopup; 24 | public event ColumnHeaderCellEventHandler SortChanged; 25 | public event ColumnHeaderCellEventHandler FilterChanged; 26 | 27 | #endregion 28 | 29 | 30 | #region class properties 31 | 32 | private Image _filterImage = Properties.Resources.ColumnHeader_UnFiltered; 33 | private Size _filterButtonImageSize = new Size(16, 16); 34 | private bool _filterButtonPressed = false; 35 | private bool _filterButtonOver = false; 36 | private Rectangle _filterButtonOffsetBounds = Rectangle.Empty; 37 | private Rectangle _filterButtonImageBounds = Rectangle.Empty; 38 | private Padding _filterButtonMargin = new Padding(3, 4, 3, 4); 39 | private bool _filterEnabled = false; 40 | 41 | private const bool FilterDateAndTimeDefaultEnabled = false; 42 | 43 | #endregion 44 | 45 | 46 | #region constructors 47 | 48 | /// 49 | /// ColumnHeaderCell constructor 50 | /// 51 | /// 52 | /// 53 | public ColumnHeaderCell(DataGridViewColumnHeaderCell oldCell, bool filterEnabled) 54 | { 55 | Tag = oldCell.Tag; 56 | ErrorText = oldCell.ErrorText; 57 | ToolTipText = oldCell.ToolTipText; 58 | Value = oldCell.Value; 59 | ValueType = oldCell.ValueType; 60 | ContextMenuStrip = oldCell.ContextMenuStrip; 61 | Style = oldCell.Style; 62 | _filterEnabled = filterEnabled; 63 | 64 | ColumnHeaderCell oldCellt = oldCell as ColumnHeaderCell; 65 | if (oldCellt != null && oldCellt.MenuStrip != null) 66 | { 67 | MenuStrip = oldCellt.MenuStrip; 68 | _filterImage = oldCellt._filterImage; 69 | _filterButtonPressed = oldCellt._filterButtonPressed; 70 | _filterButtonOver = oldCellt._filterButtonOver; 71 | _filterButtonOffsetBounds = oldCellt._filterButtonOffsetBounds; 72 | _filterButtonImageBounds = oldCellt._filterButtonImageBounds; 73 | MenuStrip.FilterChanged += new EventHandler(MenuStrip_FilterChanged); 74 | MenuStrip.SortChanged += new EventHandler(MenuStrip_SortChanged); 75 | } 76 | else 77 | { 78 | MenuStrip = new MenuStrip(oldCell.OwningColumn.ValueType); 79 | MenuStrip.FilterChanged += new EventHandler(MenuStrip_FilterChanged); 80 | MenuStrip.SortChanged += new EventHandler(MenuStrip_SortChanged); 81 | } 82 | 83 | IsFilterDateAndTimeEnabled = FilterDateAndTimeDefaultEnabled; 84 | IsSortEnabled = true; 85 | IsFilterEnabled = true; 86 | IsFilterChecklistEnabled = true; 87 | } 88 | ~ColumnHeaderCell() 89 | { 90 | if (MenuStrip != null) 91 | { 92 | MenuStrip.FilterChanged -= MenuStrip_FilterChanged; 93 | MenuStrip.SortChanged -= MenuStrip_SortChanged; 94 | } 95 | } 96 | 97 | #endregion 98 | 99 | 100 | #region public clone 101 | 102 | /// 103 | /// Clone the ColumnHeaderCell 104 | /// 105 | /// 106 | public override object Clone() 107 | { 108 | return new ColumnHeaderCell(this, FilterAndSortEnabled); 109 | } 110 | 111 | #endregion 112 | 113 | 114 | #region public methods 115 | 116 | /// 117 | /// Get or Set the Filter and Sort enabled status 118 | /// 119 | public bool FilterAndSortEnabled 120 | { 121 | get 122 | { 123 | return _filterEnabled; 124 | } 125 | set 126 | { 127 | if (!value) 128 | { 129 | _filterButtonPressed = false; 130 | _filterButtonOver = false; 131 | } 132 | 133 | if (value != _filterEnabled) 134 | { 135 | _filterEnabled = value; 136 | bool refreshed = false; 137 | if (MenuStrip.FilterString.Length > 0) 138 | { 139 | MenuStrip_FilterChanged(this, new EventArgs()); 140 | refreshed = true; 141 | } 142 | if (MenuStrip.SortString.Length > 0) 143 | { 144 | MenuStrip_SortChanged(this, new EventArgs()); 145 | refreshed = true; 146 | } 147 | if (!refreshed) 148 | RepaintCell(); 149 | } 150 | } 151 | } 152 | 153 | /// 154 | /// Set or Unset the Filter and Sort to Loaded mode 155 | /// 156 | /// 157 | public void SetLoadedMode(bool enabled) 158 | { 159 | MenuStrip.SetLoadedMode(enabled); 160 | RefreshImage(); 161 | RepaintCell(); 162 | } 163 | 164 | /// 165 | /// Clean Sort 166 | /// 167 | public void CleanSort() 168 | { 169 | if (MenuStrip != null && FilterAndSortEnabled) 170 | { 171 | MenuStrip.CleanSort(); 172 | RefreshImage(); 173 | RepaintCell(); 174 | } 175 | } 176 | 177 | /// 178 | /// Clean Filter 179 | /// 180 | public void CleanFilter() 181 | { 182 | if (MenuStrip != null && FilterAndSortEnabled) 183 | { 184 | MenuStrip.CleanFilter(); 185 | RefreshImage(); 186 | RepaintCell(); 187 | } 188 | } 189 | 190 | /// 191 | /// Sort ASC 192 | /// 193 | public void SortASC() 194 | { 195 | if (MenuStrip != null && FilterAndSortEnabled) 196 | { 197 | MenuStrip.SortASC(); 198 | } 199 | } 200 | 201 | /// 202 | /// Sort DESC 203 | /// 204 | public void SortDESC() 205 | { 206 | if (MenuStrip != null && FilterAndSortEnabled) 207 | { 208 | MenuStrip.SortDESC(); 209 | } 210 | } 211 | 212 | /// 213 | /// Get the MenuStrip for this ColumnHeaderCell 214 | /// 215 | public MenuStrip MenuStrip { get; private set; } 216 | 217 | /// 218 | /// Get the MenuStrip SortType 219 | /// 220 | public MenuStrip.SortType ActiveSortType 221 | { 222 | get 223 | { 224 | if (MenuStrip != null && FilterAndSortEnabled) 225 | return MenuStrip.ActiveSortType; 226 | else 227 | return MenuStrip.SortType.None; 228 | } 229 | } 230 | 231 | /// 232 | /// Get the MenuStrip FilterType 233 | /// 234 | public MenuStrip.FilterType ActiveFilterType 235 | { 236 | get 237 | { 238 | if (MenuStrip != null && FilterAndSortEnabled) 239 | return MenuStrip.ActiveFilterType; 240 | else 241 | return MenuStrip.FilterType.None; 242 | } 243 | } 244 | 245 | /// 246 | /// Get the Sort string 247 | /// 248 | public string SortString 249 | { 250 | get 251 | { 252 | if (MenuStrip != null && FilterAndSortEnabled) 253 | return MenuStrip.SortString; 254 | else 255 | return ""; 256 | } 257 | } 258 | 259 | /// 260 | /// Get the Filter string 261 | /// 262 | public string FilterString 263 | { 264 | get 265 | { 266 | if (MenuStrip != null && FilterAndSortEnabled) 267 | return MenuStrip.FilterString; 268 | else 269 | return ""; 270 | } 271 | } 272 | 273 | /// 274 | /// Get the Minimum size 275 | /// 276 | public Size MinimumSize 277 | { 278 | get 279 | { 280 | return new Size(_filterButtonImageSize.Width + _filterButtonMargin.Left + _filterButtonMargin.Right, 281 | _filterButtonImageSize.Height + _filterButtonMargin.Bottom + _filterButtonMargin.Top); 282 | } 283 | } 284 | 285 | /// 286 | /// Get or Set the Sort enabled status 287 | /// 288 | public bool IsSortEnabled 289 | { 290 | get 291 | { 292 | return MenuStrip.IsSortEnabled; 293 | } 294 | set 295 | { 296 | MenuStrip.IsSortEnabled = value; 297 | } 298 | } 299 | 300 | /// 301 | /// Get or Set the Filter enabled status 302 | /// 303 | public bool IsFilterEnabled 304 | { 305 | get 306 | { 307 | return MenuStrip.IsFilterEnabled; 308 | } 309 | set 310 | { 311 | MenuStrip.IsFilterEnabled = value; 312 | } 313 | } 314 | 315 | /// 316 | /// Get or Set the Filter enabled status 317 | /// 318 | public bool IsFilterChecklistEnabled 319 | { 320 | get 321 | { 322 | return MenuStrip.IsFilterChecklistEnabled; 323 | } 324 | set 325 | { 326 | MenuStrip.IsFilterChecklistEnabled = value; 327 | } 328 | } 329 | 330 | /// 331 | /// Get or Set the FilterDateAndTime enabled status 332 | /// 333 | public bool IsFilterDateAndTimeEnabled 334 | { 335 | get 336 | { 337 | return MenuStrip.IsFilterDateAndTimeEnabled; 338 | } 339 | set 340 | { 341 | MenuStrip.IsFilterDateAndTimeEnabled = value; 342 | } 343 | } 344 | 345 | /// 346 | /// Get or Set the NOT IN logic for Filter 347 | /// 348 | public bool IsMenuStripFilterNOTINLogicEnabled 349 | { 350 | get 351 | { 352 | return MenuStrip.IsFilterNOTINLogicEnabled; 353 | } 354 | set 355 | { 356 | MenuStrip.IsFilterNOTINLogicEnabled = value; 357 | } 358 | } 359 | 360 | /// 361 | /// Set the text filter search nodes behaviour 362 | /// 363 | public bool DoesTextFilterRemoveNodesOnSearch 364 | { 365 | get 366 | { 367 | return MenuStrip.DoesTextFilterRemoveNodesOnSearch; 368 | } 369 | set 370 | { 371 | MenuStrip.DoesTextFilterRemoveNodesOnSearch = value; 372 | } 373 | } 374 | 375 | /// 376 | /// Enabled or disable Sort capabilities 377 | /// 378 | /// 379 | public void SetSortEnabled(bool enabled) 380 | { 381 | if (MenuStrip != null) 382 | { 383 | MenuStrip.IsSortEnabled = enabled; 384 | MenuStrip.SetSortEnabled(enabled); 385 | } 386 | } 387 | 388 | /// 389 | /// Enable or disable Filter capabilities 390 | /// 391 | /// 392 | public void SetFilterEnabled(bool enabled) 393 | { 394 | if (MenuStrip != null) 395 | { 396 | MenuStrip.IsFilterEnabled = enabled; 397 | MenuStrip.SetFilterEnabled(enabled); 398 | } 399 | } 400 | 401 | /// 402 | /// Enable or disable Filter checklist capabilities 403 | /// 404 | /// 405 | public void SetFilterChecklistEnabled(bool enabled) 406 | { 407 | if (MenuStrip != null) 408 | { 409 | MenuStrip.IsFilterChecklistEnabled = enabled; 410 | MenuStrip.SetFilterChecklistEnabled(enabled); 411 | } 412 | } 413 | 414 | /// 415 | /// Enable or disable Text filter on checklist remove node mode 416 | /// 417 | /// 418 | public void SetChecklistTextFilterRemoveNodesOnSearchMode(bool enabled) 419 | { 420 | if (MenuStrip != null) 421 | { 422 | MenuStrip.SetChecklistTextFilterRemoveNodesOnSearchMode(enabled); 423 | } 424 | } 425 | 426 | #endregion 427 | 428 | 429 | #region menustrip events 430 | 431 | /// 432 | /// OnFilterChanged event 433 | /// 434 | /// 435 | /// 436 | private void MenuStrip_FilterChanged(object sender, EventArgs e) 437 | { 438 | RefreshImage(); 439 | RepaintCell(); 440 | if (FilterAndSortEnabled && FilterChanged != null) 441 | FilterChanged(this, new ColumnHeaderCellEventArgs(MenuStrip, OwningColumn)); 442 | } 443 | 444 | /// 445 | /// OnSortChanged event 446 | /// 447 | /// 448 | /// 449 | private void MenuStrip_SortChanged(object sender, EventArgs e) 450 | { 451 | RefreshImage(); 452 | RepaintCell(); 453 | if (FilterAndSortEnabled && SortChanged != null) 454 | SortChanged(this, new ColumnHeaderCellEventArgs(MenuStrip, OwningColumn)); 455 | } 456 | 457 | #endregion 458 | 459 | 460 | #region paint methods 461 | 462 | /// 463 | /// Repaint the Cell 464 | /// 465 | private void RepaintCell() 466 | { 467 | if (Displayed && DataGridView != null) 468 | DataGridView.InvalidateCell(this); 469 | } 470 | 471 | /// 472 | /// Refrash the Cell image 473 | /// 474 | private void RefreshImage() 475 | { 476 | if (ActiveFilterType == MenuStrip.FilterType.Loaded) 477 | { 478 | _filterImage = Properties.Resources.ColumnHeader_SavedFilters; 479 | } 480 | else 481 | { 482 | if (ActiveFilterType == MenuStrip.FilterType.None) 483 | { 484 | if (ActiveSortType == MenuStrip.SortType.None) 485 | _filterImage = Properties.Resources.ColumnHeader_UnFiltered; 486 | else if (ActiveSortType == MenuStrip.SortType.ASC) 487 | _filterImage = Properties.Resources.ColumnHeader_OrderedASC; 488 | else 489 | _filterImage = Properties.Resources.ColumnHeader_OrderedDESC; 490 | } 491 | else 492 | { 493 | if (ActiveSortType == MenuStrip.SortType.None) 494 | _filterImage = Properties.Resources.ColumnHeader_Filtered; 495 | else if (ActiveSortType == MenuStrip.SortType.ASC) 496 | _filterImage = Properties.Resources.ColumnHeader_FilteredAndOrderedASC; 497 | else 498 | _filterImage = Properties.Resources.ColumnHeader_FilteredAndOrderedDESC; 499 | } 500 | } 501 | } 502 | 503 | /// 504 | /// Pain method 505 | /// 506 | /// 507 | /// 508 | /// 509 | /// 510 | /// 511 | /// 512 | /// 513 | /// 514 | /// 515 | /// 516 | /// 517 | protected override void Paint( 518 | Graphics graphics, 519 | Rectangle clipBounds, 520 | Rectangle cellBounds, 521 | int rowIndex, 522 | DataGridViewElementStates cellState, 523 | object value, 524 | object formattedValue, 525 | string errorText, 526 | DataGridViewCellStyle cellStyle, 527 | DataGridViewAdvancedBorderStyle advancedBorderStyle, 528 | DataGridViewPaintParts paintParts) 529 | { 530 | if (SortGlyphDirection != SortOrder.None) 531 | SortGlyphDirection = SortOrder.None; 532 | 533 | base.Paint(graphics, clipBounds, cellBounds, rowIndex, 534 | cellState, value, formattedValue, 535 | errorText, cellStyle, advancedBorderStyle, paintParts); 536 | 537 | // Don't display a dropdown for Image columns 538 | if (this.OwningColumn.ValueType == typeof(System.Drawing.Bitmap)) 539 | return; 540 | 541 | if (FilterAndSortEnabled && paintParts.HasFlag(DataGridViewPaintParts.ContentBackground)) 542 | { 543 | _filterButtonOffsetBounds = GetFilterBounds(true); 544 | _filterButtonImageBounds = GetFilterBounds(false); 545 | Rectangle buttonBounds = _filterButtonOffsetBounds; 546 | if (buttonBounds != null && clipBounds.IntersectsWith(buttonBounds)) 547 | { 548 | ControlPaint.DrawBorder(graphics, buttonBounds, Color.Gray, ButtonBorderStyle.Solid); 549 | buttonBounds.Inflate(-1, -1); 550 | using (Brush b = new SolidBrush(_filterButtonOver ? Color.WhiteSmoke : Color.White)) 551 | graphics.FillRectangle(b, buttonBounds); 552 | graphics.DrawImage(_filterImage, buttonBounds); 553 | } 554 | } 555 | } 556 | 557 | /// 558 | /// Get the ColumnHeaderCell Bounds 559 | /// 560 | /// 561 | /// 562 | private Rectangle GetFilterBounds(bool withOffset = true) 563 | { 564 | Rectangle cell = DataGridView.GetCellDisplayRectangle(ColumnIndex, -1, false); 565 | 566 | Point p = new Point( 567 | (withOffset ? cell.Right : cell.Width) - _filterButtonImageSize.Width - _filterButtonMargin.Right, 568 | (withOffset ? cell.Bottom : cell.Height) - _filterButtonImageSize.Height - _filterButtonMargin.Bottom); 569 | 570 | return new Rectangle(p, _filterButtonImageSize); 571 | } 572 | 573 | #endregion 574 | 575 | 576 | #region mouse events 577 | 578 | /// 579 | /// OnMouseMove event 580 | /// 581 | /// 582 | protected override void OnMouseMove(DataGridViewCellMouseEventArgs e) 583 | { 584 | if (FilterAndSortEnabled) 585 | { 586 | if (_filterButtonImageBounds.Contains(e.X, e.Y) && !_filterButtonOver) 587 | { 588 | _filterButtonOver = true; 589 | RepaintCell(); 590 | } 591 | else if (!_filterButtonImageBounds.Contains(e.X, e.Y) && _filterButtonOver) 592 | { 593 | _filterButtonOver = false; 594 | RepaintCell(); 595 | } 596 | } 597 | base.OnMouseMove(e); 598 | } 599 | 600 | /// 601 | /// OnMouseDown event 602 | /// 603 | /// 604 | protected override void OnMouseDown(DataGridViewCellMouseEventArgs e) 605 | { 606 | if (FilterAndSortEnabled && _filterButtonImageBounds.Contains(e.X, e.Y)) 607 | { 608 | if (e.Button == MouseButtons.Left && !_filterButtonPressed) 609 | { 610 | _filterButtonPressed = true; 611 | _filterButtonOver = true; 612 | RepaintCell(); 613 | } 614 | } 615 | else 616 | base.OnMouseDown(e); 617 | } 618 | 619 | /// 620 | /// OnMouseUp event 621 | /// 622 | /// 623 | protected override void OnMouseUp(DataGridViewCellMouseEventArgs e) 624 | { 625 | if (FilterAndSortEnabled && e.Button == MouseButtons.Left && _filterButtonPressed) 626 | { 627 | _filterButtonPressed = false; 628 | _filterButtonOver = false; 629 | RepaintCell(); 630 | if (_filterButtonImageBounds.Contains(e.X, e.Y) && FilterPopup != null) 631 | { 632 | FilterPopup(this, new ColumnHeaderCellEventArgs(MenuStrip, OwningColumn)); 633 | } 634 | } 635 | base.OnMouseUp(e); 636 | } 637 | 638 | /// 639 | /// OnMouseLeave event 640 | /// 641 | /// 642 | protected override void OnMouseLeave(int rowIndex) 643 | { 644 | if (FilterAndSortEnabled && _filterButtonOver) 645 | { 646 | _filterButtonOver = false; 647 | RepaintCell(); 648 | } 649 | 650 | base.OnMouseLeave(rowIndex); 651 | } 652 | 653 | #endregion 654 | 655 | } 656 | 657 | internal delegate void ColumnHeaderCellEventHandler(object sender, ColumnHeaderCellEventArgs e); 658 | internal class ColumnHeaderCellEventArgs : EventArgs 659 | { 660 | public MenuStrip FilterMenu { get; private set; } 661 | 662 | public DataGridViewColumn Column { get; private set; } 663 | 664 | public ColumnHeaderCellEventArgs(MenuStrip filterMenu, DataGridViewColumn column) 665 | { 666 | FilterMenu = filterMenu; 667 | Column = column; 668 | } 669 | } 670 | 671 | } -------------------------------------------------------------------------------- /AdvancedDataGridView/FormCustomFilter.Designer.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace Zuby.ADGV 3 | { 4 | partial class FormCustomFilter 5 | { 6 | /// 7 | /// Required designer variable. 8 | /// 9 | private System.ComponentModel.IContainer components = null; 10 | 11 | /// 12 | /// Clean up any resources being used. 13 | /// 14 | /// true if managed resources should be disposed; otherwise, false. 15 | protected override void Dispose(bool disposing) 16 | { 17 | if (disposing && (components != null)) 18 | { 19 | components.Dispose(); 20 | } 21 | base.Dispose(disposing); 22 | } 23 | 24 | #region Windows Form Designer generated code 25 | 26 | /// 27 | /// Required method for Designer support - do not modify 28 | /// the contents of this method with the code editor. 29 | /// 30 | private void InitializeComponent() 31 | { 32 | this.components = new System.ComponentModel.Container(); 33 | this.button_ok = new System.Windows.Forms.Button(); 34 | this.button_cancel = new System.Windows.Forms.Button(); 35 | this.label_columnName = new System.Windows.Forms.Label(); 36 | this.comboBox_filterType = new System.Windows.Forms.ComboBox(); 37 | this.label_and = new System.Windows.Forms.Label(); 38 | this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 39 | ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 40 | this.SuspendLayout(); 41 | // 42 | // button_ok 43 | // 44 | this.button_ok.DialogResult = System.Windows.Forms.DialogResult.OK; 45 | this.button_ok.Location = new System.Drawing.Point(40, 139); 46 | this.button_ok.Name = "button_ok"; 47 | this.button_ok.Size = new System.Drawing.Size(75, 23); 48 | this.button_ok.TabIndex = 0; 49 | this.button_ok.Text = "OK"; 50 | this.button_ok.UseVisualStyleBackColor = true; 51 | this.button_ok.Click += new System.EventHandler(this.button_ok_Click); 52 | // 53 | // button_cancel 54 | // 55 | this.button_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; 56 | this.button_cancel.Location = new System.Drawing.Point(121, 139); 57 | this.button_cancel.Name = "button_cancel"; 58 | this.button_cancel.Size = new System.Drawing.Size(75, 23); 59 | this.button_cancel.TabIndex = 1; 60 | this.button_cancel.Text = "Cancel"; 61 | this.button_cancel.UseVisualStyleBackColor = true; 62 | this.button_cancel.Click += new System.EventHandler(this.button_cancel_Click); 63 | // 64 | // label_columnName 65 | // 66 | this.label_columnName.AutoSize = true; 67 | this.label_columnName.Location = new System.Drawing.Point(4, 9); 68 | this.label_columnName.Name = "label_columnName"; 69 | this.label_columnName.Size = new System.Drawing.Size(120, 13); 70 | this.label_columnName.TabIndex = 2; 71 | this.label_columnName.Text = "Show rows where value"; 72 | // 73 | // comboBox_filterType 74 | // 75 | this.comboBox_filterType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 76 | this.comboBox_filterType.FormattingEnabled = true; 77 | this.comboBox_filterType.Location = new System.Drawing.Point(7, 25); 78 | this.comboBox_filterType.Name = "comboBox_filterType"; 79 | this.comboBox_filterType.Size = new System.Drawing.Size(189, 21); 80 | this.comboBox_filterType.TabIndex = 3; 81 | this.comboBox_filterType.SelectedIndexChanged += new System.EventHandler(this.comboBox_filterType_SelectedIndexChanged); 82 | // 83 | // label_and 84 | // 85 | this.label_and.AutoSize = true; 86 | this.label_and.Location = new System.Drawing.Point(7, 89); 87 | this.label_and.Name = "label_and"; 88 | this.label_and.Size = new System.Drawing.Size(26, 13); 89 | this.label_and.TabIndex = 6; 90 | this.label_and.Text = "And"; 91 | this.label_and.Visible = false; 92 | // 93 | // errorProvider 94 | // 95 | this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink; 96 | this.errorProvider.ContainerControl = this; 97 | // 98 | // FormCustomFilter 99 | // 100 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 101 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 102 | this.CancelButton = this.button_cancel; 103 | this.ClientSize = new System.Drawing.Size(205, 169); 104 | this.Controls.Add(this.label_and); 105 | this.Controls.Add(this.label_columnName); 106 | this.Controls.Add(this.comboBox_filterType); 107 | this.Controls.Add(this.button_cancel); 108 | this.Controls.Add(this.button_ok); 109 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 110 | this.MaximizeBox = false; 111 | this.MinimizeBox = false; 112 | this.Name = "FormCustomFilter"; 113 | this.ShowIcon = false; 114 | this.ShowInTaskbar = false; 115 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 116 | this.Text = "Custom Filter"; 117 | this.TopMost = true; 118 | this.Load += new System.EventHandler(this.FormCustomFilter_Load); 119 | ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 120 | this.ResumeLayout(false); 121 | this.PerformLayout(); 122 | 123 | } 124 | 125 | #endregion 126 | 127 | private System.Windows.Forms.Button button_ok; 128 | private System.Windows.Forms.Button button_cancel; 129 | private System.Windows.Forms.Label label_columnName; 130 | private System.Windows.Forms.ComboBox comboBox_filterType; 131 | private System.Windows.Forms.Label label_and; 132 | private System.Windows.Forms.ErrorProvider errorProvider; 133 | } 134 | } -------------------------------------------------------------------------------- /AdvancedDataGridView/FormCustomFilter.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // Advanced DataGridView 3 | // 4 | // Copyright (c), 2014 Davide Gironi 5 | // Original work Copyright (c), 2013 Zuby 6 | // 7 | // Please refer to LICENSE file for licensing information. 8 | #endregion 9 | 10 | using System; 11 | using System.Collections; 12 | using System.Globalization; 13 | using System.Linq; 14 | using System.Threading; 15 | using System.Windows.Forms; 16 | 17 | namespace Zuby.ADGV 18 | { 19 | internal partial class FormCustomFilter : Form 20 | { 21 | 22 | #region class properties 23 | 24 | private enum FilterType 25 | { 26 | Unknown, 27 | DateTime, 28 | TimeSpan, 29 | String, 30 | Float, 31 | Integer 32 | } 33 | 34 | private FilterType _filterType = FilterType.Unknown; 35 | private Control _valControl1 = null; 36 | private Control _valControl2 = null; 37 | 38 | private bool _filterDateAndTimeEnabled = true; 39 | 40 | private string _filterString = null; 41 | private string _filterStringDescription = null; 42 | 43 | private Hashtable _textStrings = new Hashtable(); 44 | 45 | #endregion 46 | 47 | 48 | #region constructors 49 | 50 | /// 51 | /// Main constructor 52 | /// 53 | private FormCustomFilter() 54 | { 55 | InitializeComponent(); 56 | } 57 | 58 | /// 59 | /// Form constructor 60 | /// 61 | /// 62 | /// 63 | public FormCustomFilter(Type dataType, bool filterDateAndTimeEnabled) 64 | : this() 65 | { 66 | //set localization strings 67 | _textStrings.Add("EQUALS", "equals"); 68 | _textStrings.Add("DOES_NOT_EQUAL", "does not equal"); 69 | _textStrings.Add("EARLIER_THAN", "earlier than"); 70 | _textStrings.Add("EARLIER_THAN_OR_EQUAL_TO", "earlier than or equal to"); 71 | _textStrings.Add("LATER_THAN", "later than"); 72 | _textStrings.Add("LATER_THAN_OR_EQUAL_TO", "later than or equal to"); 73 | _textStrings.Add("BETWEEN", "between"); 74 | _textStrings.Add("GREATER_THAN", "greater than"); 75 | _textStrings.Add("GREATER_THAN_OR_EQUAL_TO", "greater than or equal to"); 76 | _textStrings.Add("LESS_THAN", "less than"); 77 | _textStrings.Add("LESS_THAN_OR_EQUAL_TO", "less than or equal to"); 78 | _textStrings.Add("BEGINS_WITH", "begins with"); 79 | _textStrings.Add("DOES_NOT_BEGIN_WITH", "does not begin with"); 80 | _textStrings.Add("ENDS_WITH", "ends with"); 81 | _textStrings.Add("DOES_NOT_END_WITH", "does not end with"); 82 | _textStrings.Add("CONTAINS", "contains"); 83 | _textStrings.Add("DOES_NOT_CONTAIN", "does not contain"); 84 | _textStrings.Add("INVALID_VALUE", "Invalid Value"); 85 | _textStrings.Add("FILTER_STRING_DESCRIPTION", "Show rows where value {0} \"{1}\""); 86 | _textStrings.Add("FORM_TITLE", "Custom Filter"); 87 | _textStrings.Add("LABEL_COLUMNNAMETEXT", "Show rows where value"); 88 | _textStrings.Add("LABEL_AND", "And"); 89 | _textStrings.Add("BUTTON_OK", "OK"); 90 | _textStrings.Add("BUTTON_CANCEL", "Cancel"); 91 | 92 | 93 | this.Text = _textStrings["FORM_TITLE"].ToString(); 94 | label_columnName.Text = _textStrings["LABEL_COLUMNNAMETEXT"].ToString(); 95 | label_and.Text = _textStrings["LABEL_AND"].ToString(); 96 | button_ok.Text = _textStrings["BUTTON_OK"].ToString(); 97 | button_cancel.Text = _textStrings["BUTTON_CANCEL"].ToString(); 98 | 99 | if (dataType == typeof(DateTime)) 100 | _filterType = FilterType.DateTime; 101 | else if (dataType == typeof(TimeSpan)) 102 | _filterType = FilterType.TimeSpan; 103 | else if (dataType == typeof(Int32) || dataType == typeof(Int64) || dataType == typeof(Int16) || 104 | dataType == typeof(UInt32) || dataType == typeof(UInt64) || dataType == typeof(UInt16) || 105 | dataType == typeof(Byte) || dataType == typeof(SByte)) 106 | _filterType = FilterType.Integer; 107 | else if (dataType == typeof(Single) || dataType == typeof(Double) || dataType == typeof(Decimal)) 108 | _filterType = FilterType.Float; 109 | else if (dataType == typeof(String)) 110 | _filterType = FilterType.String; 111 | else 112 | _filterType = FilterType.Unknown; 113 | 114 | _filterDateAndTimeEnabled = filterDateAndTimeEnabled; 115 | 116 | switch (_filterType) 117 | { 118 | case FilterType.DateTime: 119 | _valControl1 = new DateTimePicker(); 120 | _valControl2 = new DateTimePicker(); 121 | if (_filterDateAndTimeEnabled) 122 | { 123 | DateTimeFormatInfo dt = Thread.CurrentThread.CurrentCulture.DateTimeFormat; 124 | 125 | (_valControl1 as DateTimePicker).CustomFormat = dt.ShortDatePattern + " " + "HH:mm"; 126 | (_valControl2 as DateTimePicker).CustomFormat = dt.ShortDatePattern + " " + "HH:mm"; 127 | (_valControl1 as DateTimePicker).Format = DateTimePickerFormat.Custom; 128 | (_valControl2 as DateTimePicker).Format = DateTimePickerFormat.Custom; 129 | } 130 | else 131 | { 132 | (_valControl1 as DateTimePicker).Format = DateTimePickerFormat.Short; 133 | (_valControl2 as DateTimePicker).Format = DateTimePickerFormat.Short; 134 | } 135 | 136 | comboBox_filterType.Items.AddRange(new string[] { 137 | _textStrings["EQUALS"].ToString(), 138 | _textStrings["DOES_NOT_EQUAL"].ToString(), 139 | _textStrings["EARLIER_THAN"].ToString(), 140 | _textStrings["EARLIER_THAN_OR_EQUAL_TO"].ToString(), 141 | _textStrings["LATER_THAN"].ToString(), 142 | _textStrings["LATER_THAN_OR_EQUAL_TO"].ToString(), 143 | _textStrings["BETWEEN"].ToString() 144 | }); 145 | break; 146 | 147 | case FilterType.TimeSpan: 148 | _valControl1 = new TextBox(); 149 | _valControl2 = new TextBox(); 150 | comboBox_filterType.Items.AddRange(new string[] { 151 | _textStrings["CONTAINS"].ToString(), 152 | _textStrings["DOES_NOT_CONTAIN"].ToString() 153 | }); 154 | break; 155 | 156 | case FilterType.Integer: 157 | case FilterType.Float: 158 | _valControl1 = new TextBox(); 159 | _valControl2 = new TextBox(); 160 | _valControl1.TextChanged += valControl_TextChanged; 161 | _valControl2.TextChanged += valControl_TextChanged; 162 | comboBox_filterType.Items.AddRange(new string[] { 163 | _textStrings["EQUALS"].ToString(), 164 | _textStrings["DOES_NOT_EQUAL"].ToString(), 165 | _textStrings["GREATER_THAN"].ToString(), 166 | _textStrings["GREATER_THAN_OR_EQUAL_TO"].ToString(), 167 | _textStrings["LESS_THAN"].ToString(), 168 | _textStrings["LESS_THAN_OR_EQUAL_TO"].ToString(), 169 | _textStrings["BETWEEN"].ToString() 170 | }); 171 | _valControl1.Tag = true; 172 | _valControl2.Tag = true; 173 | button_ok.Enabled = false; 174 | break; 175 | 176 | default: 177 | _valControl1 = new TextBox(); 178 | _valControl2 = new TextBox(); 179 | comboBox_filterType.Items.AddRange(new string[] { 180 | _textStrings["EQUALS"].ToString(), 181 | _textStrings["DOES_NOT_EQUAL"].ToString(), 182 | _textStrings["BEGINS_WITH"].ToString(), 183 | _textStrings["DOES_NOT_BEGIN_WITH"].ToString(), 184 | _textStrings["ENDS_WITH"].ToString(), 185 | _textStrings["DOES_NOT_END_WITH"].ToString(), 186 | _textStrings["CONTAINS"].ToString(), 187 | _textStrings["DOES_NOT_CONTAIN"].ToString() 188 | }); 189 | break; 190 | } 191 | comboBox_filterType.SelectedIndex = 0; 192 | 193 | _valControl1.Name = "valControl1"; 194 | _valControl1.Location = new System.Drawing.Point(30, 66); 195 | _valControl1.Size = new System.Drawing.Size(166, 20); 196 | _valControl1.TabIndex = 4; 197 | _valControl1.Visible = true; 198 | _valControl1.KeyDown += valControl_KeyDown; 199 | 200 | _valControl2.Name = "valControl2"; 201 | _valControl2.Location = new System.Drawing.Point(30, 108); 202 | _valControl2.Size = new System.Drawing.Size(166, 20); 203 | _valControl2.TabIndex = 5; 204 | _valControl2.Visible = false; 205 | _valControl2.VisibleChanged += new EventHandler(valControl2_VisibleChanged); 206 | _valControl2.KeyDown += valControl_KeyDown; 207 | 208 | Controls.Add(_valControl1); 209 | Controls.Add(_valControl2); 210 | 211 | errorProvider.SetIconAlignment(_valControl1, ErrorIconAlignment.MiddleRight); 212 | errorProvider.SetIconPadding(_valControl1, -18); 213 | errorProvider.SetIconAlignment(_valControl2, ErrorIconAlignment.MiddleRight); 214 | errorProvider.SetIconPadding(_valControl2, -18); 215 | } 216 | 217 | /// 218 | /// Form loaders 219 | /// 220 | /// 221 | /// 222 | private void FormCustomFilter_Load(object sender, EventArgs e) 223 | { } 224 | 225 | #endregion 226 | 227 | 228 | #region public filter methods 229 | 230 | /// 231 | /// Get the Filter string 232 | /// 233 | public string FilterString 234 | { 235 | get 236 | { 237 | return _filterString; 238 | } 239 | } 240 | 241 | /// 242 | /// Get the Filter string description 243 | /// 244 | public string FilterStringDescription 245 | { 246 | get 247 | { 248 | return _filterStringDescription; 249 | } 250 | } 251 | 252 | #endregion 253 | 254 | 255 | #region filter builder 256 | 257 | /// 258 | /// Build a Filter string 259 | /// 260 | /// 261 | /// 262 | /// 263 | /// 264 | /// 265 | /// 266 | private string BuildCustomFilter(FilterType filterType, bool filterDateAndTimeEnabled, string filterTypeConditionText, Control control1, Control control2) 267 | { 268 | string filterString = ""; 269 | 270 | string column = "[{0}] "; 271 | 272 | if (filterType == FilterType.Unknown) 273 | column = "Convert([{0}], 'System.String') "; 274 | 275 | filterString = column; 276 | 277 | switch (filterType) 278 | { 279 | case FilterType.DateTime: 280 | DateTime dt = ((DateTimePicker)control1).Value; 281 | dt = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, 0); 282 | 283 | if (filterTypeConditionText == _textStrings["EQUALS"].ToString()) 284 | filterString = "Convert([{0}], 'System.String') LIKE '%" + Convert.ToString((filterDateAndTimeEnabled ? dt : dt.Date), CultureInfo.CurrentCulture) + "%'"; 285 | else if (filterTypeConditionText == _textStrings["EARLIER_THAN"].ToString()) 286 | filterString += "< '" + Convert.ToString((filterDateAndTimeEnabled ? dt : dt.Date), CultureInfo.CurrentCulture) + "'"; 287 | else if (filterTypeConditionText == _textStrings["EARLIER_THAN_OR_EQUAL_TO"].ToString()) 288 | filterString += "<= '" + Convert.ToString((filterDateAndTimeEnabled ? dt : dt.Date), CultureInfo.CurrentCulture) + "'"; 289 | else if (filterTypeConditionText == _textStrings["LATER_THAN"].ToString()) 290 | filterString += "> '" + Convert.ToString((filterDateAndTimeEnabled ? dt : dt.Date), CultureInfo.CurrentCulture) + "'"; 291 | else if (filterTypeConditionText == _textStrings["LATER_THAN_OR_EQUAL_TO"].ToString()) 292 | filterString += ">= '" + Convert.ToString((filterDateAndTimeEnabled ? dt : dt.Date), CultureInfo.CurrentCulture) + "'"; 293 | else if (filterTypeConditionText == _textStrings["BETWEEN"].ToString()) 294 | { 295 | DateTime dt1 = ((DateTimePicker)control2).Value; 296 | dt1 = new DateTime(dt1.Year, dt1.Month, dt1.Day, dt1.Hour, dt1.Minute, 0); 297 | filterString += ">= '" + Convert.ToString((filterDateAndTimeEnabled ? dt : dt.Date), CultureInfo.CurrentCulture) + "'"; 298 | filterString += " AND " + column + "<= '" + Convert.ToString((filterDateAndTimeEnabled ? dt1 : dt1.Date), CultureInfo.CurrentCulture) + "'"; 299 | } 300 | else if (filterTypeConditionText == _textStrings["DOES_NOT_EQUAL"].ToString()) 301 | filterString = "Convert([{0}], 'System.String') NOT LIKE '%" + Convert.ToString((filterDateAndTimeEnabled ? dt : dt.Date), CultureInfo.CurrentCulture) + "%'"; 302 | break; 303 | 304 | case FilterType.TimeSpan: 305 | try 306 | { 307 | TimeSpan ts = TimeSpan.Parse(control1.Text); 308 | 309 | if (filterTypeConditionText == _textStrings["CONTAINS"].ToString()) 310 | { 311 | filterString = "(Convert([{0}], 'System.String') LIKE '%P" + ((int)ts.Days > 0 ? (int)ts.Days + "D" : "") + (ts.TotalHours > 0 ? "T" : "") + ((int)ts.Hours > 0 ? (int)ts.Hours + "H" : "") + ((int)ts.Minutes > 0 ? (int)ts.Minutes + "M" : "") + ((int)ts.Seconds > 0 ? (int)ts.Seconds + "S" : "") + "%')"; 312 | } 313 | else if (filterTypeConditionText == _textStrings["DOES_NOT_CONTAIN"].ToString()) 314 | { 315 | filterString = "(Convert([{0}], 'System.String') NOT LIKE '%P" + ((int)ts.Days > 0 ? (int)ts.Days + "D" : "") + (ts.TotalHours > 0 ? "T" : "") + ((int)ts.Hours > 0 ? (int)ts.Hours + "H" : "") + ((int)ts.Minutes > 0 ? (int)ts.Minutes + "M" : "") + ((int)ts.Seconds > 0 ? (int)ts.Seconds + "S" : "") + "%')"; 316 | } 317 | } 318 | catch (FormatException) 319 | { 320 | filterString = null; 321 | } 322 | break; 323 | 324 | case FilterType.Integer: 325 | case FilterType.Float: 326 | 327 | string num = control1.Text; 328 | 329 | if (filterType == FilterType.Float) 330 | num = num.Replace(",", "."); 331 | 332 | if (filterTypeConditionText == _textStrings["EQUALS"].ToString()) 333 | filterString += "= " + num; 334 | else if (filterTypeConditionText == _textStrings["BETWEEN"].ToString()) 335 | filterString += ">= " + num + " AND " + column + "<= " + (filterType == FilterType.Float ? control2.Text.Replace(",", ".") : control2.Text); 336 | else if (filterTypeConditionText == _textStrings["DOES_NOT_EQUAL"].ToString()) 337 | filterString += "<> " + num; 338 | else if (filterTypeConditionText == _textStrings["GREATER_THAN"].ToString()) 339 | filterString += "> " + num; 340 | else if (filterTypeConditionText == _textStrings["GREATER_THAN_OR_EQUAL_TO"].ToString()) 341 | filterString += ">= " + num; 342 | else if (filterTypeConditionText == _textStrings["LESS_THAN"].ToString()) 343 | filterString += "< " + num; 344 | else if (filterTypeConditionText == _textStrings["LESS_THAN_OR_EQUAL_TO"].ToString()) 345 | filterString += "<= " + num; 346 | break; 347 | 348 | default: 349 | string txt = FormatFilterString(control1.Text); 350 | if (filterTypeConditionText == _textStrings["EQUALS"].ToString()) 351 | filterString += "LIKE '" + txt + "'"; 352 | else if (filterTypeConditionText == _textStrings["DOES_NOT_EQUAL"].ToString()) 353 | filterString += "NOT LIKE '" + txt + "'"; 354 | else if (filterTypeConditionText == _textStrings["BEGINS_WITH"].ToString()) 355 | filterString += "LIKE '" + txt + "%'"; 356 | else if (filterTypeConditionText == _textStrings["ENDS_WITH"].ToString()) 357 | filterString += "LIKE '%" + txt + "'"; 358 | else if (filterTypeConditionText == _textStrings["DOES_NOT_BEGIN_WITH"].ToString()) 359 | filterString += "NOT LIKE '" + txt + "%'"; 360 | else if (filterTypeConditionText == _textStrings["DOES_NOT_END_WITH"].ToString()) 361 | filterString += "NOT LIKE '%" + txt + "'"; 362 | else if (filterTypeConditionText == _textStrings["CONTAINS"].ToString()) 363 | filterString += "LIKE '%" + txt + "%'"; 364 | else if (filterTypeConditionText == _textStrings["DOES_NOT_CONTAIN"].ToString()) 365 | filterString += "NOT LIKE '%" + txt + "%'"; 366 | break; 367 | } 368 | 369 | return filterString; 370 | } 371 | 372 | /// 373 | /// Format a text Filter string 374 | /// 375 | /// 376 | /// 377 | private string FormatFilterString(string text) 378 | { 379 | string result = ""; 380 | string s; 381 | string[] replace = { "%", "[", "]", "*", "\"", "\\" }; 382 | 383 | for (int i = 0; i < text.Length; i++) 384 | { 385 | s = text[i].ToString(); 386 | if (replace.Contains(s)) 387 | result += "[" + s + "]"; 388 | else 389 | result += s; 390 | } 391 | 392 | return result.Replace("'", "''"); 393 | } 394 | 395 | 396 | #endregion 397 | 398 | 399 | #region buttons events 400 | 401 | /// 402 | /// Button Cancel Clieck 403 | /// 404 | /// 405 | /// 406 | private void button_cancel_Click(object sender, EventArgs e) 407 | { 408 | _filterStringDescription = null; 409 | _filterString = null; 410 | Close(); 411 | } 412 | 413 | /// 414 | /// Button OK Click 415 | /// 416 | /// 417 | /// 418 | private void button_ok_Click(object sender, EventArgs e) 419 | { 420 | if ((_valControl1.Visible && _valControl1.Tag != null && ((bool)_valControl1.Tag)) || 421 | (_valControl2.Visible && _valControl2.Tag != null && ((bool)_valControl2.Tag))) 422 | { 423 | button_ok.Enabled = false; 424 | return; 425 | } 426 | 427 | string filterString = BuildCustomFilter(_filterType, _filterDateAndTimeEnabled, comboBox_filterType.Text, _valControl1, _valControl2); 428 | 429 | if (!String.IsNullOrEmpty(filterString)) 430 | { 431 | _filterString = filterString; 432 | _filterStringDescription = String.Format(_textStrings["FILTER_STRING_DESCRIPTION"].ToString(), comboBox_filterType.Text, _valControl1.Text); 433 | if (_valControl2.Visible) 434 | _filterStringDescription += " " + label_and.Text + " \"" + _valControl2.Text + "\""; 435 | DialogResult = System.Windows.Forms.DialogResult.OK; 436 | } 437 | else 438 | { 439 | _filterString = null; 440 | _filterStringDescription = null; 441 | DialogResult = System.Windows.Forms.DialogResult.Cancel; 442 | } 443 | 444 | Close(); 445 | } 446 | 447 | #endregion 448 | 449 | 450 | #region changed status events 451 | 452 | /// 453 | /// Changed condition type 454 | /// 455 | /// 456 | /// 457 | private void comboBox_filterType_SelectedIndexChanged(object sender, EventArgs e) 458 | { 459 | _valControl2.Visible = comboBox_filterType.Text == _textStrings["BETWEEN"].ToString(); 460 | button_ok.Enabled = !(_valControl1.Visible && _valControl1.Tag != null && ((bool)_valControl1.Tag)) || 461 | (_valControl2.Visible && _valControl2.Tag != null && ((bool)_valControl2.Tag)); 462 | } 463 | 464 | /// 465 | /// Changed control2 visibility 466 | /// 467 | /// 468 | /// 469 | private void valControl2_VisibleChanged(object sender, EventArgs e) 470 | { 471 | label_and.Visible = _valControl2.Visible; 472 | } 473 | 474 | /// 475 | /// Changed a control Text 476 | /// 477 | /// 478 | /// 479 | private void valControl_TextChanged(object sender, EventArgs e) 480 | { 481 | bool hasErrors = false; 482 | switch (_filterType) 483 | { 484 | case FilterType.Integer: 485 | Int64 val; 486 | hasErrors = !(Int64.TryParse((sender as TextBox).Text, out val)); 487 | break; 488 | 489 | case FilterType.Float: 490 | Double val1; 491 | hasErrors = !(Double.TryParse((sender as TextBox).Text, out val1)); 492 | break; 493 | } 494 | 495 | (sender as Control).Tag = hasErrors || (sender as TextBox).Text.Length == 0; 496 | 497 | if (hasErrors && (sender as TextBox).Text.Length > 0) 498 | errorProvider.SetError((sender as Control), _textStrings["INVALID_VALUE"].ToString()); 499 | else 500 | errorProvider.SetError((sender as Control), ""); 501 | 502 | button_ok.Enabled = !(_valControl1.Visible && _valControl1.Tag != null && ((bool)_valControl1.Tag)) || 503 | (_valControl2.Visible && _valControl2.Tag != null && ((bool)_valControl2.Tag)); 504 | } 505 | 506 | /// 507 | /// KeyDown on a control 508 | /// 509 | /// 510 | /// 511 | private void valControl_KeyDown(object sender, KeyEventArgs e) 512 | { 513 | if (e.KeyData == Keys.Enter) 514 | { 515 | if (sender == _valControl1) 516 | { 517 | if (_valControl2.Visible) 518 | _valControl2.Focus(); 519 | else 520 | button_ok_Click(button_ok, new EventArgs()); 521 | } 522 | else 523 | { 524 | button_ok_Click(button_ok, new EventArgs()); 525 | } 526 | 527 | e.SuppressKeyPress = false; 528 | e.Handled = true; 529 | } 530 | } 531 | 532 | #endregion 533 | 534 | } 535 | } -------------------------------------------------------------------------------- /AdvancedDataGridView/FormCustomFilter.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /AdvancedDataGridView/MenuStrip.designer.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace Zuby.ADGV 3 | { 4 | partial class MenuStrip 5 | { 6 | /// 7 | /// Required designer variable. 8 | /// 9 | private System.ComponentModel.IContainer components = null; 10 | 11 | /// 12 | /// Clean up any resources being used. 13 | /// 14 | /// true if managed resources should be disposed; otherwise, false. 15 | protected override void Dispose(bool disposing) 16 | { 17 | if (disposing && (components != null)) 18 | { 19 | components.Dispose(); 20 | } 21 | base.Dispose(disposing); 22 | } 23 | 24 | #region Windows Form Designer generated code 25 | 26 | /// 27 | /// Required method for Designer support - do not modify 28 | /// the contents of this method with the code editor. 29 | /// 30 | private void InitializeComponent() 31 | { 32 | this.components = new System.ComponentModel.Container(); 33 | this.sortASCMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 34 | this.sortDESCMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 35 | this.cancelSortMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 36 | this.toolStripSeparator1MenuItem = new System.Windows.Forms.ToolStripSeparator(); 37 | this.cancelFilterMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 38 | this.customFilterLastFiltersListMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 39 | this.customFilterMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 40 | this.toolStripSeparator2MenuItem = new System.Windows.Forms.ToolStripSeparator(); 41 | this.customFilterLastFilter1MenuItem = new System.Windows.Forms.ToolStripMenuItem(); 42 | this.customFilterLastFilter2MenuItem = new System.Windows.Forms.ToolStripMenuItem(); 43 | this.customFilterLastFilter3MenuItem = new System.Windows.Forms.ToolStripMenuItem(); 44 | this.customFilterLastFilter4MenuItem = new System.Windows.Forms.ToolStripMenuItem(); 45 | this.customFilterLastFilter5MenuItem = new System.Windows.Forms.ToolStripMenuItem(); 46 | this.toolStripSeparator3MenuItem = new System.Windows.Forms.ToolStripSeparator(); 47 | this.checkList = new System.Windows.Forms.TreeView(); 48 | this.button_ok = new System.Windows.Forms.Button(); 49 | this.button_cancel = new System.Windows.Forms.Button(); 50 | this.checkFilterListPanel = new System.Windows.Forms.Panel(); 51 | this.checkFilterListButtonsPanel = new System.Windows.Forms.Panel(); 52 | this.checkFilterListButtonsControlHost = new System.Windows.Forms.ToolStripControlHost(checkFilterListButtonsPanel); 53 | this.checkFilterListControlHost = new System.Windows.Forms.ToolStripControlHost(checkFilterListPanel); 54 | this.checkTextFilter = new System.Windows.Forms.TextBox(); 55 | this.checkTextFilterControlHost = new System.Windows.Forms.ToolStripControlHost(checkTextFilter); 56 | this.resizeBoxControlHost = new System.Windows.Forms.ToolStripControlHost(new System.Windows.Forms.Control()); 57 | this.SuspendLayout(); 58 | // 59 | // MenuStrip 60 | // 61 | this.BackColor = System.Drawing.SystemColors.ControlLightLight; 62 | this.AutoSize = false; 63 | this.Padding = new System.Windows.Forms.Padding(0); 64 | this.Margin = new System.Windows.Forms.Padding(0); 65 | this.Size = new System.Drawing.Size(287, 370); 66 | this.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(MenuStrip_Closed); 67 | this.LostFocus += new System.EventHandler(MenuStrip_LostFocus); 68 | this.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 69 | sortASCMenuItem, 70 | sortDESCMenuItem, 71 | cancelSortMenuItem, 72 | toolStripSeparator1MenuItem, 73 | cancelFilterMenuItem, 74 | customFilterLastFiltersListMenuItem, 75 | toolStripSeparator3MenuItem, 76 | checkTextFilterControlHost, 77 | checkFilterListControlHost, 78 | checkFilterListButtonsControlHost, 79 | resizeBoxControlHost}); 80 | // 81 | // sortASCMenuItem 82 | // 83 | this.sortASCMenuItem.Name = "sortASCMenuItem"; 84 | this.sortASCMenuItem.AutoSize = false; 85 | this.sortASCMenuItem.Size = new System.Drawing.Size(Width - 1, 22); 86 | this.sortASCMenuItem.Click += new System.EventHandler(SortASCMenuItem_Click); 87 | this.sortASCMenuItem.MouseEnter += new System.EventHandler(SortASCMenuItem_MouseEnter); 88 | this.sortASCMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; 89 | // 90 | // sortDESCMenuItem 91 | // 92 | this.sortDESCMenuItem.Name = "sortDESCMenuItem"; 93 | this.sortDESCMenuItem.AutoSize = false; 94 | this.sortDESCMenuItem.Size = new System.Drawing.Size(Width - 1, 22); 95 | this.sortDESCMenuItem.Click += new System.EventHandler(SortDESCMenuItem_Click); 96 | this.sortDESCMenuItem.MouseEnter += new System.EventHandler(SortDESCMenuItem_MouseEnter); 97 | this.sortDESCMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; 98 | // 99 | // cancelSortMenuItem 100 | // 101 | this.cancelSortMenuItem.Name = "cancelSortMenuItem"; 102 | this.cancelSortMenuItem.Enabled = false; 103 | this.cancelSortMenuItem.AutoSize = false; 104 | this.cancelSortMenuItem.Size = new System.Drawing.Size(Width - 1, 22); 105 | this.cancelSortMenuItem.Text = _textStrings["CLEARSORT"].ToString(); 106 | this.cancelSortMenuItem.Click += new System.EventHandler(CancelSortMenuItem_Click); 107 | this.cancelSortMenuItem.MouseEnter += new System.EventHandler(CancelSortMenuItem_MouseEnter); 108 | // 109 | // toolStripSeparator1MenuItem 110 | // 111 | this.toolStripSeparator1MenuItem.Name = "toolStripSeparator1MenuItem"; 112 | this.toolStripSeparator1MenuItem.Size = new System.Drawing.Size(Width - 4, 6); 113 | // 114 | // cancelFilterMenuItem 115 | // 116 | this.cancelFilterMenuItem.Name = "cancelFilterMenuItem"; 117 | this.cancelFilterMenuItem.Enabled = false; 118 | this.cancelFilterMenuItem.AutoSize = false; 119 | this.cancelFilterMenuItem.Size = new System.Drawing.Size(Width - 1, 22); 120 | this.cancelFilterMenuItem.Text = _textStrings["CLEARFILTER"].ToString(); 121 | this.cancelFilterMenuItem.Click += new System.EventHandler(CancelFilterMenuItem_Click); 122 | this.cancelFilterMenuItem.MouseEnter += new System.EventHandler(CancelFilterMenuItem_MouseEnter); 123 | // 124 | // toolStripMenuItem2 125 | // 126 | this.toolStripSeparator2MenuItem.Name = "toolStripSeparator2MenuItem"; 127 | this.toolStripSeparator2MenuItem.Size = new System.Drawing.Size(149, 6); 128 | this.toolStripSeparator2MenuItem.Visible = false; 129 | // 130 | // customFilterMenuItem 131 | // 132 | this.customFilterMenuItem.Name = "customFilterMenuItem"; 133 | this.customFilterMenuItem.Size = new System.Drawing.Size(152, 22); 134 | this.customFilterMenuItem.Text = _textStrings["ADDCUSTOMFILTER"].ToString(); 135 | this.customFilterMenuItem.Click += new System.EventHandler(CustomFilterMenuItem_Click); 136 | // 137 | // customFilterLastFilter1MenuItem 138 | // 139 | this.customFilterLastFilter1MenuItem.Name = "customFilterLastFilter1MenuItem"; 140 | this.customFilterLastFilter1MenuItem.Size = new System.Drawing.Size(152, 22); 141 | this.customFilterLastFilter1MenuItem.Tag = "0"; 142 | this.customFilterLastFilter1MenuItem.Text = null; 143 | this.customFilterLastFilter1MenuItem.Visible = false; 144 | this.customFilterLastFilter1MenuItem.VisibleChanged += new System.EventHandler(CustomFilterLastFilter1MenuItem_VisibleChanged); 145 | this.customFilterLastFilter1MenuItem.Click += new System.EventHandler(CustomFilterLastFilterMenuItem_Click); 146 | this.customFilterLastFilter1MenuItem.TextChanged += new System.EventHandler(CustomFilterLastFilterMenuItem_TextChanged); 147 | // 148 | // customFilterLastFilter2MenuItem 149 | // 150 | this.customFilterLastFilter2MenuItem.Name = "customFilterLastFilter2MenuItem"; 151 | this.customFilterLastFilter2MenuItem.Size = new System.Drawing.Size(152, 22); 152 | this.customFilterLastFilter2MenuItem.Tag = "1"; 153 | this.customFilterLastFilter2MenuItem.Text = null; 154 | this.customFilterLastFilter2MenuItem.Visible = false; 155 | this.customFilterLastFilter2MenuItem.Click += new System.EventHandler(CustomFilterLastFilterMenuItem_Click); 156 | this.customFilterLastFilter2MenuItem.TextChanged += new System.EventHandler(CustomFilterLastFilterMenuItem_TextChanged); 157 | // 158 | // customFilterLastFilter3MenuItem 159 | // 160 | this.customFilterLastFilter3MenuItem.Name = "customFilterLastFilter3MenuItem"; 161 | this.customFilterLastFilter3MenuItem.Size = new System.Drawing.Size(152, 22); 162 | this.customFilterLastFilter3MenuItem.Tag = "2"; 163 | this.customFilterLastFilter3MenuItem.Text = null; 164 | this.customFilterLastFilter3MenuItem.Visible = false; 165 | this.customFilterLastFilter3MenuItem.Click += new System.EventHandler(CustomFilterLastFilterMenuItem_Click); 166 | this.customFilterLastFilter3MenuItem.TextChanged += new System.EventHandler(CustomFilterLastFilterMenuItem_TextChanged); 167 | // 168 | // customFilterLastFilter3MenuItem 169 | // 170 | this.customFilterLastFilter4MenuItem.Name = "lastfilter4MenuItem"; 171 | this.customFilterLastFilter4MenuItem.Size = new System.Drawing.Size(152, 22); 172 | this.customFilterLastFilter4MenuItem.Tag = "3"; 173 | this.customFilterLastFilter4MenuItem.Text = null; 174 | this.customFilterLastFilter4MenuItem.Visible = false; 175 | this.customFilterLastFilter4MenuItem.Click += new System.EventHandler(CustomFilterLastFilterMenuItem_Click); 176 | this.customFilterLastFilter4MenuItem.TextChanged += new System.EventHandler(CustomFilterLastFilterMenuItem_TextChanged); 177 | // 178 | // customFilterLastFilter5MenuItem 179 | // 180 | this.customFilterLastFilter5MenuItem.Name = "customFilterLastFilter5MenuItem"; 181 | this.customFilterLastFilter5MenuItem.Size = new System.Drawing.Size(152, 22); 182 | this.customFilterLastFilter5MenuItem.Tag = "4"; 183 | this.customFilterLastFilter5MenuItem.Text = null; 184 | this.customFilterLastFilter5MenuItem.Visible = false; 185 | this.customFilterLastFilter5MenuItem.Click += new System.EventHandler(CustomFilterLastFilterMenuItem_Click); 186 | this.customFilterLastFilter5MenuItem.TextChanged += new System.EventHandler(CustomFilterLastFilterMenuItem_TextChanged); 187 | // 188 | // customFilterLastFiltersListMenuItem 189 | // 190 | this.customFilterLastFiltersListMenuItem.Name = "customFilterLastFiltersListMenuItem"; 191 | this.customFilterLastFiltersListMenuItem.AutoSize = false; 192 | this.customFilterLastFiltersListMenuItem.Size = new System.Drawing.Size(Width - 1, 22); 193 | this.customFilterLastFiltersListMenuItem.Image = Properties.Resources.ColumnHeader_Filtered; 194 | this.customFilterLastFiltersListMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; 195 | this.customFilterLastFiltersListMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 196 | customFilterMenuItem, 197 | toolStripSeparator2MenuItem, 198 | customFilterLastFilter1MenuItem, 199 | customFilterLastFilter2MenuItem, 200 | customFilterLastFilter3MenuItem, 201 | customFilterLastFilter4MenuItem, 202 | customFilterLastFilter5MenuItem}); 203 | this.customFilterLastFiltersListMenuItem.MouseEnter += new System.EventHandler(CustomFilterLastFiltersListMenuItem_MouseEnter); 204 | this.customFilterLastFiltersListMenuItem.Paint += new System.Windows.Forms.PaintEventHandler(CustomFilterLastFiltersListMenuItem_Paint); 205 | // 206 | // toolStripMenuItem3 207 | // 208 | this.toolStripSeparator3MenuItem.Name = "toolStripSeparator3MenuItem"; 209 | this.toolStripSeparator3MenuItem.Size = new System.Drawing.Size(Width - 4, 6); 210 | // 211 | // button_ok 212 | // 213 | this.button_ok.Name = "button_ok"; 214 | this.button_ok.BackColor = System.Windows.Forms.Button.DefaultBackColor; 215 | this.button_ok.UseVisualStyleBackColor = true; 216 | this.button_ok.Margin = new System.Windows.Forms.Padding(0); 217 | this.button_ok.Size = new System.Drawing.Size(75, 23); 218 | this.button_ok.Text = _textStrings["BUTTONOK"].ToString(); 219 | this.button_ok.Click += new System.EventHandler(Button_ok_Click); 220 | this.button_ok.Location = new System.Drawing.Point(this.checkFilterListButtonsPanel.Width - 164, 0); 221 | // 222 | // button_cancel 223 | // 224 | this.button_cancel.Name = "button_cancel"; 225 | this.button_cancel.BackColor = System.Windows.Forms.Button.DefaultBackColor; 226 | this.button_cancel.UseVisualStyleBackColor = true; 227 | this.button_cancel.Margin = new System.Windows.Forms.Padding(0); 228 | this.button_cancel.Size = new System.Drawing.Size(75, 23); 229 | this.button_cancel.Text = _textStrings["BUTTONCANCEL"].ToString(); 230 | this.button_cancel.Click += new System.EventHandler(Button_cancel_Click); 231 | this.button_cancel.Location = new System.Drawing.Point(this.checkFilterListButtonsPanel.Width - 79, 0); 232 | // 233 | // resizeBoxControlHost 234 | // 235 | this.resizeBoxControlHost.Name = "resizeBoxControlHost"; 236 | this.resizeBoxControlHost.Control.Cursor = System.Windows.Forms.Cursors.SizeNWSE; 237 | this.resizeBoxControlHost.AutoSize = false; 238 | this.resizeBoxControlHost.Padding = new System.Windows.Forms.Padding(0); 239 | this.resizeBoxControlHost.Margin = new System.Windows.Forms.Padding(Width - 45, 0, 0, 0); 240 | this.resizeBoxControlHost.Size = new System.Drawing.Size(10, 10); 241 | this.resizeBoxControlHost.Paint += new System.Windows.Forms.PaintEventHandler(ResizeBoxControlHost_Paint); 242 | this.resizeBoxControlHost.MouseDown += new System.Windows.Forms.MouseEventHandler(ResizeBoxControlHost_MouseDown); 243 | this.resizeBoxControlHost.MouseUp += new System.Windows.Forms.MouseEventHandler(ResizeBoxControlHost_MouseUp); 244 | this.resizeBoxControlHost.MouseMove += new System.Windows.Forms.MouseEventHandler(ResizeBoxControlHost_MouseMove); 245 | // 246 | // checkFilterListControlHost 247 | // 248 | this.checkFilterListControlHost.Name = "checkFilterListControlHost"; 249 | this.checkFilterListControlHost.AutoSize = false; 250 | this.checkFilterListControlHost.Size = new System.Drawing.Size(Width - 35, 194); 251 | this.checkFilterListControlHost.Padding = new System.Windows.Forms.Padding(0); 252 | this.checkFilterListControlHost.Margin = new System.Windows.Forms.Padding(0); 253 | // 254 | // checkTextFilterControlHost 255 | // 256 | this.checkTextFilterControlHost.Name = "checkTextFilterControlHost"; 257 | this.checkTextFilterControlHost.AutoSize = false; 258 | this.checkTextFilterControlHost.Size = new System.Drawing.Size(Width - 35, 20); 259 | this.checkTextFilterControlHost.Padding = new System.Windows.Forms.Padding(4, 0, 4, 0); 260 | this.checkTextFilterControlHost.Margin = new System.Windows.Forms.Padding(0); 261 | // 262 | // checkFilterListButtonsControlHost 263 | // 264 | this.checkFilterListButtonsControlHost.Name = "checkFilterListButtonsControlHost"; 265 | this.checkFilterListButtonsControlHost.AutoSize = false; 266 | this.checkFilterListButtonsControlHost.Size = new System.Drawing.Size(Width - 35, 24); 267 | this.checkFilterListButtonsControlHost.Padding = new System.Windows.Forms.Padding(0); 268 | this.checkFilterListButtonsControlHost.Margin = new System.Windows.Forms.Padding(0); 269 | // 270 | // checkFilterListPanel 271 | // 272 | this.checkFilterListPanel.Name = "checkFilterListPanel"; 273 | this.checkFilterListPanel.AutoSize = false; 274 | this.checkFilterListPanel.Size = checkFilterListControlHost.Size; 275 | this.checkFilterListPanel.Padding = new System.Windows.Forms.Padding(0); 276 | this.checkFilterListPanel.Margin = new System.Windows.Forms.Padding(0); 277 | this.checkFilterListPanel.BackColor = BackColor; 278 | this.checkFilterListPanel.BorderStyle = System.Windows.Forms.BorderStyle.None; 279 | this.checkFilterListPanel.Controls.Add(checkList); 280 | // 281 | // checkList 282 | // 283 | this.checkList.Name = "checkList"; 284 | this.checkList.AutoSize = false; 285 | this.checkList.Padding = new System.Windows.Forms.Padding(0); 286 | this.checkList.Margin = new System.Windows.Forms.Padding(0); 287 | this.checkList.Bounds = new System.Drawing.Rectangle(4, 4, this.checkFilterListPanel.Width - 8, this.checkFilterListPanel.Height - 8); 288 | this.checkList.StateImageList = GetCheckListStateImages(); 289 | this.checkList.CheckBoxes = false; 290 | this.checkList.MouseLeave += new System.EventHandler(CheckList_MouseLeave); 291 | this.checkList.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(CheckList_NodeMouseClick); 292 | this.checkList.KeyDown += new System.Windows.Forms.KeyEventHandler(CheckList_KeyDown); 293 | this.checkList.MouseEnter += CheckList_MouseEnter; 294 | this.checkList.NodeMouseDoubleClick += CheckList_NodeMouseDoubleClick; 295 | // 296 | // checkTextFilter 297 | // 298 | this.checkTextFilter.Name = "checkTextFilter"; 299 | this.checkTextFilter.Padding = new System.Windows.Forms.Padding(0); 300 | this.checkTextFilter.Margin = new System.Windows.Forms.Padding(0); 301 | this.checkTextFilter.Size = checkTextFilterControlHost.Size; 302 | this.checkTextFilter.Dock = System.Windows.Forms.DockStyle.Fill; 303 | this.checkTextFilter.TextChanged += new System.EventHandler(CheckTextFilter_TextChanged); 304 | // 305 | // checkFilterListButtonsPanel 306 | // 307 | this.checkFilterListButtonsPanel.Name = "checkFilterListButtonsPanel"; 308 | this.checkFilterListButtonsPanel.AutoSize = false; 309 | this.checkFilterListButtonsPanel.Size = checkFilterListButtonsControlHost.Size; 310 | this.checkFilterListButtonsPanel.Padding = new System.Windows.Forms.Padding(0); 311 | this.checkFilterListButtonsPanel.Margin = new System.Windows.Forms.Padding(0); 312 | this.checkFilterListButtonsPanel.BackColor = BackColor; 313 | this.checkFilterListButtonsPanel.BorderStyle = System.Windows.Forms.BorderStyle.None; 314 | this.checkFilterListButtonsPanel.Controls.AddRange(new System.Windows.Forms.Control[] { 315 | button_ok, 316 | button_cancel 317 | }); 318 | this.ResumeLayout(false); 319 | this.PerformLayout(); 320 | 321 | } 322 | 323 | #endregion 324 | 325 | private System.Windows.Forms.ToolStripMenuItem sortASCMenuItem; 326 | private System.Windows.Forms.ToolStripMenuItem sortDESCMenuItem; 327 | private System.Windows.Forms.ToolStripMenuItem cancelSortMenuItem; 328 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator1MenuItem; 329 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator2MenuItem; 330 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator3MenuItem; 331 | private System.Windows.Forms.ToolStripMenuItem cancelFilterMenuItem; 332 | private System.Windows.Forms.ToolStripMenuItem customFilterLastFiltersListMenuItem; 333 | private System.Windows.Forms.ToolStripMenuItem customFilterMenuItem; 334 | private System.Windows.Forms.ToolStripMenuItem customFilterLastFilter1MenuItem; 335 | private System.Windows.Forms.ToolStripMenuItem customFilterLastFilter2MenuItem; 336 | private System.Windows.Forms.ToolStripMenuItem customFilterLastFilter3MenuItem; 337 | private System.Windows.Forms.ToolStripMenuItem customFilterLastFilter4MenuItem; 338 | private System.Windows.Forms.ToolStripMenuItem customFilterLastFilter5MenuItem; 339 | private System.Windows.Forms.TreeView checkList; 340 | private System.Windows.Forms.Button button_ok; 341 | private System.Windows.Forms.Button button_cancel; 342 | private System.Windows.Forms.ToolStripControlHost checkFilterListControlHost; 343 | private System.Windows.Forms.ToolStripControlHost checkFilterListButtonsControlHost; 344 | private System.Windows.Forms.ToolStripControlHost resizeBoxControlHost; 345 | private System.Windows.Forms.Panel checkFilterListPanel; 346 | private System.Windows.Forms.Panel checkFilterListButtonsPanel; 347 | private System.Windows.Forms.TextBox checkTextFilter; 348 | private System.Windows.Forms.ToolStripControlHost checkTextFilterControlHost; 349 | } 350 | } 351 | -------------------------------------------------------------------------------- /AdvancedDataGridView/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Properties/AssemblyInfo.cs -------------------------------------------------------------------------------- /AdvancedDataGridView/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Zuby.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Zuby.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap ColumnHeader_Filtered { 67 | get { 68 | object obj = ResourceManager.GetObject("ColumnHeader_Filtered", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Looks up a localized resource of type System.Drawing.Bitmap. 75 | /// 76 | internal static System.Drawing.Bitmap ColumnHeader_FilteredAndOrderedASC { 77 | get { 78 | object obj = ResourceManager.GetObject("ColumnHeader_FilteredAndOrderedASC", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// Looks up a localized resource of type System.Drawing.Bitmap. 85 | /// 86 | internal static System.Drawing.Bitmap ColumnHeader_FilteredAndOrderedDESC { 87 | get { 88 | object obj = ResourceManager.GetObject("ColumnHeader_FilteredAndOrderedDESC", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | 93 | /// 94 | /// Looks up a localized resource of type System.Drawing.Bitmap. 95 | /// 96 | internal static System.Drawing.Bitmap ColumnHeader_OrderedASC { 97 | get { 98 | object obj = ResourceManager.GetObject("ColumnHeader_OrderedASC", resourceCulture); 99 | return ((System.Drawing.Bitmap)(obj)); 100 | } 101 | } 102 | 103 | /// 104 | /// Looks up a localized resource of type System.Drawing.Bitmap. 105 | /// 106 | internal static System.Drawing.Bitmap ColumnHeader_OrderedDESC { 107 | get { 108 | object obj = ResourceManager.GetObject("ColumnHeader_OrderedDESC", resourceCulture); 109 | return ((System.Drawing.Bitmap)(obj)); 110 | } 111 | } 112 | 113 | /// 114 | /// Looks up a localized resource of type System.Drawing.Bitmap. 115 | /// 116 | internal static System.Drawing.Bitmap ColumnHeader_SavedFilters { 117 | get { 118 | object obj = ResourceManager.GetObject("ColumnHeader_SavedFilters", resourceCulture); 119 | return ((System.Drawing.Bitmap)(obj)); 120 | } 121 | } 122 | 123 | /// 124 | /// Looks up a localized resource of type System.Drawing.Bitmap. 125 | /// 126 | internal static System.Drawing.Bitmap ColumnHeader_UnFiltered { 127 | get { 128 | object obj = ResourceManager.GetObject("ColumnHeader_UnFiltered", resourceCulture); 129 | return ((System.Drawing.Bitmap)(obj)); 130 | } 131 | } 132 | 133 | /// 134 | /// Looks up a localized resource of type System.Drawing.Bitmap. 135 | /// 136 | internal static System.Drawing.Bitmap MenuStrip_OrderASCbool { 137 | get { 138 | object obj = ResourceManager.GetObject("MenuStrip_OrderASCbool", resourceCulture); 139 | return ((System.Drawing.Bitmap)(obj)); 140 | } 141 | } 142 | 143 | /// 144 | /// Looks up a localized resource of type System.Drawing.Bitmap. 145 | /// 146 | internal static System.Drawing.Bitmap MenuStrip_OrderASCnum { 147 | get { 148 | object obj = ResourceManager.GetObject("MenuStrip_OrderASCnum", resourceCulture); 149 | return ((System.Drawing.Bitmap)(obj)); 150 | } 151 | } 152 | 153 | /// 154 | /// Looks up a localized resource of type System.Drawing.Bitmap. 155 | /// 156 | internal static System.Drawing.Bitmap MenuStrip_OrderASCtxt { 157 | get { 158 | object obj = ResourceManager.GetObject("MenuStrip_OrderASCtxt", resourceCulture); 159 | return ((System.Drawing.Bitmap)(obj)); 160 | } 161 | } 162 | 163 | /// 164 | /// Looks up a localized resource of type System.Drawing.Bitmap. 165 | /// 166 | internal static System.Drawing.Bitmap MenuStrip_OrderDESCbool { 167 | get { 168 | object obj = ResourceManager.GetObject("MenuStrip_OrderDESCbool", resourceCulture); 169 | return ((System.Drawing.Bitmap)(obj)); 170 | } 171 | } 172 | 173 | /// 174 | /// Looks up a localized resource of type System.Drawing.Bitmap. 175 | /// 176 | internal static System.Drawing.Bitmap MenuStrip_OrderDESCnum { 177 | get { 178 | object obj = ResourceManager.GetObject("MenuStrip_OrderDESCnum", resourceCulture); 179 | return ((System.Drawing.Bitmap)(obj)); 180 | } 181 | } 182 | 183 | /// 184 | /// Looks up a localized resource of type System.Drawing.Bitmap. 185 | /// 186 | internal static System.Drawing.Bitmap MenuStrip_OrderDESCtxt { 187 | get { 188 | object obj = ResourceManager.GetObject("MenuStrip_OrderDESCtxt", resourceCulture); 189 | return ((System.Drawing.Bitmap)(obj)); 190 | } 191 | } 192 | 193 | /// 194 | /// Looks up a localized resource of type System.Drawing.Bitmap. 195 | /// 196 | internal static System.Drawing.Bitmap MenuStrip_ResizeGrip { 197 | get { 198 | object obj = ResourceManager.GetObject("MenuStrip_ResizeGrip", resourceCulture); 199 | return ((System.Drawing.Bitmap)(obj)); 200 | } 201 | } 202 | 203 | /// 204 | /// Looks up a localized resource of type System.Drawing.Bitmap. 205 | /// 206 | internal static System.Drawing.Bitmap SearchToolBar_ButtonCaseSensitive { 207 | get { 208 | object obj = ResourceManager.GetObject("SearchToolBar_ButtonCaseSensitive", resourceCulture); 209 | return ((System.Drawing.Bitmap)(obj)); 210 | } 211 | } 212 | 213 | /// 214 | /// Looks up a localized resource of type System.Drawing.Bitmap. 215 | /// 216 | internal static System.Drawing.Bitmap SearchToolBar_ButtonClose { 217 | get { 218 | object obj = ResourceManager.GetObject("SearchToolBar_ButtonClose", resourceCulture); 219 | return ((System.Drawing.Bitmap)(obj)); 220 | } 221 | } 222 | 223 | /// 224 | /// Looks up a localized resource of type System.Drawing.Bitmap. 225 | /// 226 | internal static System.Drawing.Bitmap SearchToolBar_ButtonFromBegin { 227 | get { 228 | object obj = ResourceManager.GetObject("SearchToolBar_ButtonFromBegin", resourceCulture); 229 | return ((System.Drawing.Bitmap)(obj)); 230 | } 231 | } 232 | 233 | /// 234 | /// Looks up a localized resource of type System.Drawing.Bitmap. 235 | /// 236 | internal static System.Drawing.Bitmap SearchToolBar_ButtonSearch { 237 | get { 238 | object obj = ResourceManager.GetObject("SearchToolBar_ButtonSearch", resourceCulture); 239 | return ((System.Drawing.Bitmap)(obj)); 240 | } 241 | } 242 | 243 | /// 244 | /// Looks up a localized resource of type System.Drawing.Bitmap. 245 | /// 246 | internal static System.Drawing.Bitmap SearchToolBar_ButtonWholeWord { 247 | get { 248 | object obj = ResourceManager.GetObject("SearchToolBar_ButtonWholeWord", resourceCulture); 249 | return ((System.Drawing.Bitmap)(obj)); 250 | } 251 | } 252 | } 253 | } 254 | -------------------------------------------------------------------------------- /AdvancedDataGridView/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\Images\MenuStrip_ResizeGrip.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | 125 | ..\Resources\Images\ColumnHeader_UnFiltered.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 126 | 127 | 128 | ..\Resources\Images\ColumnHeader_Filtered.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 129 | 130 | 131 | ..\Resources\Images\ColumnHeader_FilteredAndOrderedDESC.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 132 | 133 | 134 | ..\Resources\Images\ColumnHeader_FilteredAndOrderedASC.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 135 | 136 | 137 | ..\Resources\Images\ColumnHeader_OrderedDESC.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 138 | 139 | 140 | ..\Resources\Images\MenuStrip_OrderASCbool.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 141 | 142 | 143 | ..\Resources\Images\MenuStrip_OrderASCnum.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 144 | 145 | 146 | ..\Resources\Images\MenuStrip_OrderASCtxt.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 147 | 148 | 149 | ..\Resources\Images\ColumnHeader_OrderedASC.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 150 | 151 | 152 | ..\Resources\Images\MenuStrip_OrderDESCbool.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 153 | 154 | 155 | ..\Resources\Images\MenuStrip_OrderDESCnum.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 156 | 157 | 158 | ..\Resources\Images\MenuStrip_OrderDESCtxt.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 159 | 160 | 161 | ..\Resources\Images\ColumnHeader_SavedFilters.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 162 | 163 | 164 | ..\Resources\Images\SearchToolBar_ButtonCaseSensitive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 165 | 166 | 167 | ..\Resources\Images\SearchToolBar_ButtonClose.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 168 | 169 | 170 | ..\Resources\Images\SearchToolBar_ButtonFromBegin.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 171 | 172 | 173 | ..\Resources\Images\SearchToolBar_ButtonSearch.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 174 | 175 | 176 | ..\Resources\Images\SearchToolBar_ButtonWholeWord.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 177 | 178 | -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/AdvancedDataGridView_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/AdvancedDataGridView_logo.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/ColumnHeader_Filtered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/ColumnHeader_Filtered.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/ColumnHeader_FilteredAndOrderedASC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/ColumnHeader_FilteredAndOrderedASC.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/ColumnHeader_FilteredAndOrderedDESC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/ColumnHeader_FilteredAndOrderedDESC.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/ColumnHeader_OrderedASC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/ColumnHeader_OrderedASC.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/ColumnHeader_OrderedDESC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/ColumnHeader_OrderedDESC.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/ColumnHeader_SavedFilters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/ColumnHeader_SavedFilters.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/ColumnHeader_UnFiltered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/ColumnHeader_UnFiltered.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/MenuStrip_OrderASCbool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/MenuStrip_OrderASCbool.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/MenuStrip_OrderASCnum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/MenuStrip_OrderASCnum.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/MenuStrip_OrderASCtxt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/MenuStrip_OrderASCtxt.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/MenuStrip_OrderDESCbool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/MenuStrip_OrderDESCbool.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/MenuStrip_OrderDESCnum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/MenuStrip_OrderDESCnum.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/MenuStrip_OrderDESCtxt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/MenuStrip_OrderDESCtxt.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/MenuStrip_ResizeGrip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/MenuStrip_ResizeGrip.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/SearchToolBar_ButtonCaseSensitive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/SearchToolBar_ButtonCaseSensitive.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/SearchToolBar_ButtonClose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/SearchToolBar_ButtonClose.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/SearchToolBar_ButtonFromBegin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/SearchToolBar_ButtonFromBegin.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/SearchToolBar_ButtonSearch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/SearchToolBar_ButtonSearch.png -------------------------------------------------------------------------------- /AdvancedDataGridView/Resources/Images/SearchToolBar_ButtonWholeWord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/Resources/Images/SearchToolBar_ButtonWholeWord.png -------------------------------------------------------------------------------- /AdvancedDataGridView/TreeNodeItemSelector.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // Advanced DataGridView 3 | // 4 | // Copyright (c), 2014 Davide Gironi 5 | // Original work Copyright (c), 2013 Zuby 6 | // 7 | // Please refer to LICENSE file for licensing information. 8 | #endregion 9 | 10 | using System; 11 | using System.Windows.Forms; 12 | 13 | namespace Zuby.ADGV 14 | { 15 | [System.ComponentModel.DesignerCategory("")] 16 | internal class TreeNodeItemSelector : TreeNode 17 | { 18 | 19 | #region public enum 20 | 21 | public enum CustomNodeType : byte 22 | { 23 | Default, 24 | SelectAll, 25 | SelectEmpty, 26 | DateTimeNode 27 | } 28 | 29 | #endregion 30 | 31 | 32 | #region class properties 33 | 34 | private CheckState _checkState = CheckState.Unchecked; 35 | private TreeNodeItemSelector _parent; 36 | 37 | #endregion 38 | 39 | 40 | #region constructor 41 | 42 | /// 43 | /// TreeNodeItemSelector constructor 44 | /// 45 | /// 46 | /// 47 | /// 48 | /// 49 | private TreeNodeItemSelector(String text, object value, CheckState state, CustomNodeType nodeType) 50 | : base(text) 51 | { 52 | CheckState = state; 53 | NodeType = nodeType; 54 | Value = value; 55 | } 56 | 57 | #endregion 58 | 59 | 60 | #region public clone method 61 | 62 | /// 63 | /// Clone a Node 64 | /// 65 | /// 66 | public new TreeNodeItemSelector Clone() 67 | { 68 | TreeNodeItemSelector n = new TreeNodeItemSelector(Text, Value, _checkState, NodeType) 69 | { 70 | NodeFont = NodeFont 71 | }; 72 | 73 | if (GetNodeCount(false) > 0) 74 | { 75 | foreach (TreeNodeItemSelector child in Nodes) 76 | n.AddChild(child.Clone()); 77 | } 78 | 79 | return n; 80 | } 81 | 82 | #endregion 83 | 84 | 85 | #region public getters / setters 86 | 87 | /// 88 | /// Get Node NodeType 89 | /// 90 | public CustomNodeType NodeType { get; private set; } 91 | 92 | /// 93 | /// Get Node value 94 | /// 95 | public object Value { get; private set; } 96 | 97 | /// 98 | /// Get Node parent 99 | /// 100 | new public TreeNodeItemSelector Parent 101 | { 102 | get 103 | { 104 | if (_parent is TreeNodeItemSelector) 105 | return _parent; 106 | else 107 | return null; 108 | } 109 | set 110 | { 111 | _parent = value; 112 | } 113 | } 114 | 115 | /// 116 | /// Node is Checked 117 | /// 118 | new public bool Checked 119 | { 120 | get 121 | { 122 | return _checkState == CheckState.Checked; 123 | } 124 | set 125 | { 126 | CheckState = (value == true ? CheckState.Checked : CheckState.Unchecked); 127 | } 128 | } 129 | 130 | /// 131 | /// Get or Set the current Node CheckState 132 | /// 133 | public CheckState CheckState 134 | { 135 | get 136 | { 137 | return _checkState; 138 | } 139 | set 140 | { 141 | _checkState = value; 142 | switch (_checkState) 143 | { 144 | case CheckState.Checked: 145 | StateImageIndex = 1; 146 | break; 147 | 148 | case CheckState.Indeterminate: 149 | StateImageIndex = 2; 150 | break; 151 | 152 | default: 153 | StateImageIndex = 0; 154 | break; 155 | } 156 | } 157 | } 158 | 159 | #endregion 160 | 161 | 162 | #region public create nodes methods 163 | 164 | /// 165 | /// Create a Node 166 | /// 167 | /// 168 | /// 169 | /// 170 | /// 171 | /// 172 | public static TreeNodeItemSelector CreateNode(string text, object value, CheckState state, CustomNodeType type) 173 | { 174 | return new TreeNodeItemSelector(text, value, state, type); 175 | } 176 | 177 | /// 178 | /// Create a child Node 179 | /// 180 | /// 181 | /// 182 | /// 183 | /// 184 | public TreeNodeItemSelector CreateChildNode(string text, object value, CheckState state) 185 | { 186 | TreeNodeItemSelector n = null; 187 | 188 | //specific method for datetimenode 189 | if (NodeType == CustomNodeType.DateTimeNode) 190 | { 191 | n = new TreeNodeItemSelector(text, value, state, CustomNodeType.DateTimeNode); 192 | } 193 | 194 | if (n != null) 195 | AddChild(n); 196 | 197 | return n; 198 | } 199 | public TreeNodeItemSelector CreateChildNode(string text, object value) 200 | { 201 | return CreateChildNode(text, value, _checkState); 202 | } 203 | 204 | /// 205 | /// Add a child Node to this Node 206 | /// 207 | /// 208 | protected void AddChild(TreeNodeItemSelector child) 209 | { 210 | child.Parent = this; 211 | Nodes.Add(child); 212 | } 213 | 214 | #endregion 215 | 216 | } 217 | } -------------------------------------------------------------------------------- /AdvancedDataGridView/bin/Debug/AdvancedDataGridView.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/bin/Debug/AdvancedDataGridView.dll -------------------------------------------------------------------------------- /AdvancedDataGridView/bin/Debug/AdvancedDataGridView.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridView/bin/Debug/AdvancedDataGridView.pdb -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27703.2047 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedDataGridView", "AdvancedDataGridView\AdvancedDataGridView.csproj", "{6EBA0A55-B390-4479-A564-58D46094998D}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedDataGridViewDataModel", "AdvancedDataGridViewDataModel\AdvancedDataGridViewDataModel.csproj", "{D3470E8E-8D2E-473D-976E-74CF5D5D350E}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {6EBA0A55-B390-4479-A564-58D46094998D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {6EBA0A55-B390-4479-A564-58D46094998D}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {6EBA0A55-B390-4479-A564-58D46094998D}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {6EBA0A55-B390-4479-A564-58D46094998D}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {D3470E8E-8D2E-473D-976E-74CF5D5D350E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {D3470E8E-8D2E-473D-976E-74CF5D5D350E}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {D3470E8E-8D2E-473D-976E-74CF5D5D350E}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {D3470E8E-8D2E-473D-976E-74CF5D5D350E}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {E153CAE3-D51C-4600-A760-D8F5F8849874} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/AdvancedDataGridViewDataModel.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D3470E8E-8D2E-473D-976E-74CF5D5D350E} 8 | WinExe 9 | AdvancedDataGridViewDataTable 10 | AdvancedDataGridViewDataTable 11 | v4.6.1 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | ..\packages\System.Linq.Dynamic.1.0.7\lib\net40\System.Linq.Dynamic.dll 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Form 53 | 54 | 55 | Form1.cs 56 | 57 | 58 | 59 | 60 | 61 | Form1.cs 62 | 63 | 64 | ResXFileCodeGenerator 65 | Resources.Designer.cs 66 | Designer 67 | 68 | 69 | True 70 | Resources.resx 71 | 72 | 73 | 74 | SettingsSingleFileGenerator 75 | Settings.Designer.cs 76 | 77 | 78 | True 79 | Settings.settings 80 | True 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | {6eba0a55-b390-4479-a564-58d46094998d} 89 | AdvancedDataGridView 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | using Zuby.ADGV; 2 | 3 | namespace AdvancedDataGridViewDataTable 4 | { 5 | partial class Form1 6 | { 7 | /// 8 | /// Required designer variable. 9 | /// 10 | private System.ComponentModel.IContainer components = null; 11 | 12 | /// 13 | /// Clean up any resources being used. 14 | /// 15 | /// true if managed resources should be disposed; otherwise, false. 16 | protected override void Dispose(bool disposing) 17 | { 18 | if (disposing && (components != null)) 19 | { 20 | components.Dispose(); 21 | } 22 | base.Dispose(disposing); 23 | } 24 | 25 | #region Windows Form Designer generated code 26 | 27 | /// 28 | /// Required method for Designer support - do not modify 29 | /// the contents of this method with the code editor. 30 | /// 31 | private void InitializeComponent() 32 | { 33 | this.dataGridView1 = new Zuby.ADGV.AdvancedDataGridView(); 34 | this.textBox_sort = new System.Windows.Forms.TextBox(); 35 | this.textBox_filter = new System.Windows.Forms.TextBox(); 36 | this.button_unloadfilters = new System.Windows.Forms.Button(); 37 | this.label_filter = new System.Windows.Forms.Label(); 38 | this.label_sort = new System.Windows.Forms.Label(); 39 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); 40 | this.SuspendLayout(); 41 | // 42 | // dataGridView1 43 | // 44 | this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 45 | | System.Windows.Forms.AnchorStyles.Left) 46 | | System.Windows.Forms.AnchorStyles.Right))); 47 | this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 48 | this.dataGridView1.FilterAndSortEnabled = true; 49 | this.dataGridView1.Location = new System.Drawing.Point(12, 152); 50 | this.dataGridView1.Name = "dataGridView1"; 51 | this.dataGridView1.Size = new System.Drawing.Size(776, 354); 52 | this.dataGridView1.TabIndex = 0; 53 | this.dataGridView1.SortStringChanged += new System.EventHandler(this.advancedDataGridView1_SortStringChanged); 54 | this.dataGridView1.FilterStringChanged += new System.EventHandler(this.dataGridView1_FilterStringChanged); 55 | this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); 56 | // 57 | // textBox_sort 58 | // 59 | this.textBox_sort.Location = new System.Drawing.Point(301, 24); 60 | this.textBox_sort.Multiline = true; 61 | this.textBox_sort.Name = "textBox_sort"; 62 | this.textBox_sort.ReadOnly = true; 63 | this.textBox_sort.ScrollBars = System.Windows.Forms.ScrollBars.Both; 64 | this.textBox_sort.Size = new System.Drawing.Size(264, 113); 65 | this.textBox_sort.TabIndex = 17; 66 | // 67 | // textBox_filter 68 | // 69 | this.textBox_filter.Location = new System.Drawing.Point(17, 24); 70 | this.textBox_filter.Multiline = true; 71 | this.textBox_filter.Name = "textBox_filter"; 72 | this.textBox_filter.ReadOnly = true; 73 | this.textBox_filter.ScrollBars = System.Windows.Forms.ScrollBars.Both; 74 | this.textBox_filter.Size = new System.Drawing.Size(264, 113); 75 | this.textBox_filter.TabIndex = 16; 76 | // 77 | // button_unloadfilters 78 | // 79 | this.button_unloadfilters.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 80 | this.button_unloadfilters.Location = new System.Drawing.Point(639, 114); 81 | this.button_unloadfilters.Name = "button_unloadfilters"; 82 | this.button_unloadfilters.Size = new System.Drawing.Size(150, 23); 83 | this.button_unloadfilters.TabIndex = 15; 84 | this.button_unloadfilters.Text = "Clean Filter And Sort"; 85 | this.button_unloadfilters.UseVisualStyleBackColor = true; 86 | this.button_unloadfilters.Click += new System.EventHandler(this.button_unloadfilters_Click); 87 | // 88 | // label_filter 89 | // 90 | this.label_filter.AutoSize = true; 91 | this.label_filter.Location = new System.Drawing.Point(14, 8); 92 | this.label_filter.Name = "label_filter"; 93 | this.label_filter.Size = new System.Drawing.Size(88, 13); 94 | this.label_filter.TabIndex = 18; 95 | this.label_filter.Text = "LINQ Filter string:"; 96 | // 97 | // label_sort 98 | // 99 | this.label_sort.AutoSize = true; 100 | this.label_sort.Location = new System.Drawing.Point(298, 8); 101 | this.label_sort.Name = "label_sort"; 102 | this.label_sort.Size = new System.Drawing.Size(85, 13); 103 | this.label_sort.TabIndex = 19; 104 | this.label_sort.Text = "LINQ Sort string:"; 105 | // 106 | // Form1 107 | // 108 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 109 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 110 | this.ClientSize = new System.Drawing.Size(801, 518); 111 | this.Controls.Add(this.label_sort); 112 | this.Controls.Add(this.label_filter); 113 | this.Controls.Add(this.textBox_sort); 114 | this.Controls.Add(this.textBox_filter); 115 | this.Controls.Add(this.button_unloadfilters); 116 | this.Controls.Add(this.dataGridView1); 117 | this.Name = "Form1"; 118 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 119 | this.Text = "Ocean Airdrop - Advanced DGV - Model DataBinding "; 120 | this.Load += new System.EventHandler(this.Form1_Load); 121 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); 122 | this.ResumeLayout(false); 123 | this.PerformLayout(); 124 | 125 | } 126 | 127 | #endregion 128 | 129 | private AdvancedDataGridView dataGridView1; 130 | private System.Windows.Forms.TextBox textBox_sort; 131 | private System.Windows.Forms.TextBox textBox_filter; 132 | private System.Windows.Forms.Button button_unloadfilters; 133 | private System.Windows.Forms.Label label_filter; 134 | private System.Windows.Forms.Label label_sort; 135 | } 136 | } 137 | 138 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/Form1.cs: -------------------------------------------------------------------------------- 1 | using AdvancedDataGridViewDataTable.Model; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Reflection; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using System.Windows.Forms; 12 | using System.Linq.Dynamic; 13 | 14 | namespace AdvancedDataGridViewDataTable 15 | { 16 | public partial class Form1 : Form 17 | { 18 | List m_dataGridBindingList = new List(); 19 | List m_filteredList = null; 20 | 21 | public Form1() 22 | { 23 | InitializeComponent(); 24 | } 25 | 26 | private void Form1_Load(object sender, EventArgs e) 27 | { 28 | StyleDataGridView(dataGridView1, true); 29 | AddTestData(); 30 | SetupDataBinding(); 31 | } 32 | 33 | private void SetupDataBinding() 34 | { 35 | m_filteredList = m_dataGridBindingList; 36 | 37 | dataGridView1.DataBindings.Clear(); 38 | dataGridView1.DataSource = null; 39 | dataGridView1.DataSource = m_dataGridBindingList; 40 | dataGridView1.AutoResizeRows(); 41 | } 42 | 43 | public static void StyleDataGridView(DataGridView dgv, bool isReadonly = true) 44 | { 45 | try 46 | { 47 | // Setting the style of the DataGridView control 48 | dgv.RowHeadersVisible = true; 49 | dgv.ColumnHeadersDefaultCellStyle.Font = new Font("Tahoma", 9, FontStyle.Bold, GraphicsUnit.Point); 50 | dgv.ColumnHeadersDefaultCellStyle.BackColor = SystemColors.ControlDark; 51 | dgv.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; 52 | dgv.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; 53 | dgv.DefaultCellStyle.Font = new Font("Tahoma", 9, FontStyle.Regular, GraphicsUnit.Point); 54 | dgv.DefaultCellStyle.BackColor = Color.Empty; 55 | dgv.CellBorderStyle = DataGridViewCellBorderStyle.Single; 56 | dgv.AllowUserToAddRows = false; 57 | dgv.ReadOnly = isReadonly; 58 | dgv.SelectionMode = DataGridViewSelectionMode.CellSelect; 59 | System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); 60 | dataGridViewCellStyle1.BackColor = Color.LightBlue; 61 | dgv.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; 62 | } 63 | catch (Exception ex) 64 | { 65 | } 66 | } 67 | 68 | 69 | private void AddTestData() 70 | { 71 | Random r = new Random(); 72 | 73 | List words = new List(); 74 | words.Add("seemly"); 75 | words.Add("puncture"); 76 | words.Add("puntastic"); 77 | words.Add("imaginary"); 78 | words.Add("absent"); 79 | words.Add("discover"); 80 | words.Add("spiteful"); 81 | words.Add("seen"); 82 | words.Add("paint"); 83 | words.Add("oceanic"); 84 | words.Add("ignorant"); 85 | 86 | for (int i = 0; i <= 10; i++) 87 | { 88 | DataModel d = new DataModel(); 89 | d.DataPointId = i; 90 | 91 | d.Description = words[i]; 92 | d.InAlarm = i % 2 == 0 ? true : false; 93 | d.LastUpdate = DateTime.Today.AddHours(i * 2).AddHours(i % 2 == 0 ? i * 10 + 1 : 0).AddMinutes(i % 2 == 0 ? i * 10 + 1 : 0).AddSeconds(i % 2 == 0 ? i * 10 + 1 : 0).AddMilliseconds(i % 2 == 0 ? i * 10 + 1 : 0); 94 | d.ScalingMultiplier = (double)i * 6 / 3; 95 | d.Price = (decimal)i * 7 / 3; 96 | 97 | m_dataGridBindingList.Add(d); 98 | } 99 | 100 | 101 | } 102 | 103 | private void advancedDataGridView1_EnabledChanged(object sender, EventArgs e) 104 | { 105 | 106 | } 107 | 108 | private void advancedDataGridView1_SortStringChanged(object sender, Zuby.ADGV.AdvancedDataGridView.SortEventArgs e) 109 | { 110 | try 111 | { 112 | if (string.IsNullOrEmpty(dataGridView1.SortString) == true) 113 | return; 114 | 115 | var sortStr = dataGridView1.SortString.Replace("[", "").Replace("]", ""); 116 | 117 | if (string.IsNullOrEmpty(dataGridView1.FilterString) == true) 118 | { 119 | // the grid is not filtered! 120 | m_dataGridBindingList = m_dataGridBindingList.OrderBy(sortStr).ToList(); 121 | dataGridView1.DataSource = m_dataGridBindingList; 122 | } 123 | else 124 | { 125 | // the grid is filtered! 126 | m_filteredList = m_filteredList.OrderBy(sortStr).ToList(); 127 | dataGridView1.DataSource = m_filteredList; 128 | } 129 | 130 | textBox_sort.Text = sortStr; 131 | } 132 | catch (Exception ex) 133 | { 134 | } 135 | } 136 | 137 | private string FilterStringConverter(string filter) 138 | { 139 | string newColFilter = ""; 140 | 141 | filter = filter.Replace("(", "").Replace(")", ""); 142 | 143 | var colFilterList = filter.Split(new string[] { "AND" }, StringSplitOptions.None); 144 | 145 | string andOperator = ""; 146 | 147 | foreach (var colFilter in colFilterList) 148 | { 149 | newColFilter += andOperator; 150 | 151 | var colName = ""; 152 | 153 | // Step 1: BOOLEAN Check 154 | if (colFilter.Contains(" IN ") == false && colFilter.Split('=').Length == 2) 155 | { 156 | // if the filter string is in the form "ColumnName=value". example = "(InAlarm != null && (InAlarm == true))"; 157 | colName = colFilter.Split('=')[0]; 158 | var booleanVal = colFilter.Split('=')[1]; 159 | 160 | newColFilter += $"({colName} != null && ({colName} == {booleanVal}))"; 161 | 162 | continue; 163 | } 164 | 165 | // Step 2: NUMBER (int/decimal/double/etc) and STRING Check 166 | if (colFilter.Contains(" IN ") == true ) 167 | { 168 | var temp1 = colFilter.Trim().Split(new string[] { "IN" }, StringSplitOptions.None); 169 | 170 | colName = GetStringBetweenChars(temp1[0], '[', ']'); 171 | 172 | var filterValsList = temp1[1].Split(','); 173 | 174 | newColFilter += string.Format("({0} != null && (", colName); 175 | 176 | string orOperator = ""; 177 | 178 | foreach (var filterVal in filterValsList) 179 | { 180 | double tempNum = 0; 181 | if (Double.TryParse(filterVal, out tempNum)) 182 | newColFilter += string.Format("{0} {1} = {2}", orOperator, colName, filterVal.Trim()); 183 | else 184 | newColFilter += string.Format("{0} {1}.Contains({2})", orOperator, colName, filterVal.Trim()); 185 | 186 | orOperator = " OR "; 187 | } 188 | 189 | newColFilter += "))"; 190 | } 191 | 192 | // Step 3: DATETIME Check 193 | if (colFilter.Contains(" LIKE ") == true && colFilter.Contains("Convert[") == true) 194 | { 195 | // first of all remove the cast 196 | var colFilterNoCast = colFilter.Replace("Convert", "").Replace(", 'System.String'", ""); 197 | 198 | var filterValsList = colFilterNoCast.Trim().Split(new string[] { "OR" }, StringSplitOptions.None); 199 | 200 | colName = GetStringBetweenChars(filterValsList[0], '[', ']'); 201 | 202 | newColFilter += string.Format("({0} != null && (", colName); 203 | 204 | string orOperator = ""; 205 | 206 | foreach (var filterVal in filterValsList) 207 | { 208 | var v = GetStringBetweenChars(filterVal, '%', '%'); 209 | 210 | newColFilter += string.Format("{0} {1}.Date = DateTime.Parse('{2}')", orOperator, colName, v.Trim()); 211 | 212 | orOperator = " OR "; 213 | } 214 | 215 | newColFilter += "))"; 216 | } 217 | 218 | andOperator = " AND "; 219 | } 220 | 221 | return newColFilter.Replace("'", "\""); 222 | } 223 | 224 | private string GetStringBetweenChars(string input, char startChar, char endChar) 225 | { 226 | string output = input.Split(startChar, endChar)[1]; 227 | return output; 228 | } 229 | 230 | private void dataGridView1_FilterStringChanged(object sender, Zuby.ADGV.AdvancedDataGridView.FilterEventArgs e) 231 | { 232 | try 233 | { 234 | if (string.IsNullOrEmpty(dataGridView1.FilterString) == true) 235 | { 236 | dataGridView1.DataSource = m_dataGridBindingList; 237 | m_filteredList = m_dataGridBindingList; 238 | } 239 | else 240 | { 241 | var listfilter = FilterStringConverter(dataGridView1.FilterString); 242 | 243 | m_filteredList = m_filteredList.Where(listfilter).ToList(); 244 | 245 | dataGridView1.DataSource = m_filteredList; 246 | 247 | textBox_filter.Text = listfilter; 248 | } 249 | } 250 | catch (Exception ex) 251 | { 252 | } 253 | } 254 | 255 | private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) 256 | { 257 | 258 | } 259 | 260 | private void button_unloadfilters_Click(object sender, EventArgs e) 261 | { 262 | dataGridView1.CleanFilterAndSort(); 263 | 264 | textBox_filter.Text = ""; 265 | textBox_sort.Text = ""; 266 | } 267 | } 268 | } 269 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/Form1.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/Model/DataModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AdvancedDataGridViewDataTable.Model 8 | { 9 | public class DataModel 10 | { 11 | public int DataPointId { get; set; } 12 | public string Description { get; set; } 13 | public bool InAlarm { get; set; } 14 | public DateTime LastUpdate { get; set; } 15 | public double ScalingMultiplier { get; set; } 16 | public decimal Price { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace AdvancedDataGridViewDataTable 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("AdvancedDataGridViewDataTable")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AdvancedDataGridViewDataTable")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d3470e8e-8d2e-473d-976e-74cf5d5d350e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace AdvancedDataGridViewDataTable.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AdvancedDataGridViewDataTable.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace AdvancedDataGridViewDataTable.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/bin/Debug/AdvancedDataGridView.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridViewDataModel/bin/Debug/AdvancedDataGridView.dll -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/bin/Debug/AdvancedDataGridView.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridViewDataModel/bin/Debug/AdvancedDataGridView.pdb -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/bin/Debug/AdvancedDataGridViewDataTable.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridViewDataModel/bin/Debug/AdvancedDataGridViewDataTable.exe -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/bin/Debug/AdvancedDataGridViewDataTable.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/bin/Debug/AdvancedDataGridViewDataTable.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridViewDataModel/bin/Debug/AdvancedDataGridViewDataTable.pdb -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/bin/Debug/System.Linq.Dynamic.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/AdvancedDataGridViewDataModel/bin/Debug/System.Linq.Dynamic.dll -------------------------------------------------------------------------------- /AdvancedDataGridViewDataModel/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AdvancedDataGridViewDataModel 2 | Sample project to demonstrate Advanced DataGridView that filters using a C# model object instead of a DataTable. 3 | 4 | This allows you to bind your DataGridView to a List of objects instead of a DataTable. 5 | 6 | The code is rough around the edges but as a proof of concept works.. Potential improvements could be to automatically detect the type of the column being filtered to determin the correct Linq query syntax. 7 | 8 | Tested with datatypes: int, string, bool, DateTime double & decimal. 9 | 10 | ![alt tag](https://github.com/OceanAirdrop/AdvancedDataGridViewDataModel/blob/master/ScreenShot.png?raw=true) 11 | 12 | -------------------------------------------------------------------------------- /ScreenShot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/ScreenShot.png -------------------------------------------------------------------------------- /packages/System.Linq.Dynamic.1.0.7/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/packages/System.Linq.Dynamic.1.0.7/NuGet.exe -------------------------------------------------------------------------------- /packages/System.Linq.Dynamic.1.0.7/System.Linq.Dynamic.1.0.7.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/packages/System.Linq.Dynamic.1.0.7/System.Linq.Dynamic.1.0.7.nupkg -------------------------------------------------------------------------------- /packages/System.Linq.Dynamic.1.0.7/lib/net40/System.Linq.Dynamic.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OceanAirdrop/AdvancedDataGridViewDataModel/78ce4fc7683c8756374083b25e26926b402ea069/packages/System.Linq.Dynamic.1.0.7/lib/net40/System.Linq.Dynamic.dll --------------------------------------------------------------------------------