Hide a datagrid column in VB .NET 2003
-
Hi! I have a datagrid filled with a dataset table. I would like to know if it is possible to hide a one of the datagrid column? thanks! Hugo
Hey hlortie, To answer your question, you want to access the .Visible property of the DataGridView.Columns("ColumnName") object. So if your dataGridView is called "dgvProducts", and your column is called "Amount", you could effectively hide it by writing the following: dgvProducts.Columns("Amount").Visible = False Hope that helps!
Jonathan Sampson www.SampsonResume.com
-
Hey hlortie, To answer your question, you want to access the .Visible property of the DataGridView.Columns("ColumnName") object. So if your dataGridView is called "dgvProducts", and your column is called "Amount", you could effectively hide it by writing the following: dgvProducts.Columns("Amount").Visible = False Hope that helps!
Jonathan Sampson www.SampsonResume.com
-
I've found the way to do it: 'Assign style to datagrid tStyle.MappingName = datagrid.DataMember datagrid.TableStyles.Add(tStyle) 'Hide column datagrid.TableStyles("Table_name").GridColumnStyles("column_name").Width = 0
The way I told you will work as well, and is actually the way you're supposed to do it. Your way allows people the option to widen the width, and see the information you were hiding. May I suggest you hide the column if you sincerely want to hide it. Setting the width to 0 is not hiding it.
Jonathan Sampson www.SampsonResume.com