DataGridView vs DataGrid

Hi

I'm struggeling to manipulate the columns of the DataGridView when bound to a dataset. I've used 'DataGridViewCellStyle' to set some properties, but I also need to hide some columns on the grid (ID's etc.).
The various MSDN samples uses

dataGridView.Columns(0).Name = "Recipe"
dataGridView.Columns(0).Frozen = True

but this only works when you add the columns in code (i.e. unbound DataGridView)

Any ideas



Answer this question

DataGridView vs DataGrid

  • rtb77

    Hi, found that

    dataGridView.Columns(0).Name = "Recipe"
    dataGridView.Columns(0).Frozen = True

    can only be done AFTER the form has loaded when the dataGridView is bounded to a Dataset. Not so nice cause where do I put code to size the columns (dataGridView.Columns.Item(0).Width = dataGridView.ClientSize.Width) On Activate or GotFocus the ClientSize is still not 100% as the form is not fully Maximized

    Now what


  • Petr Jakobe

    Hi, found that

    dataGridView.Columns(0).Name = "Recipe"
    dataGridView.Columns(0).Frozen = True

    can only be done AFTER the form has loaded. Not so nice cause where do I put code to size the columns (dataGridView.Columns.Item(0).Width = dataGridView.ClientSize.Width) On Activate or GotFocus the ClientSize is still not 100% as the form is not fully Maximized

    Now what


  • DataGridView vs DataGrid