Results 1 to 3 of 3

Thread: how to set columns in datagrid so that they can't have focus?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2016
    Posts
    255

    how to set columns in datagrid so that they can't have focus?

    Is there a way to set columns in a datagrid so that they can not have focus?

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,686

    Re: how to set columns in datagrid so that they can't have focus?

    A simple method would be to set the column Readonly to true then use the code below

    Code:
     Private Sub CustomersDataGridView_SelectionChanged(sender As Object, e As EventArgs) Handles CustomersDataGridView.SelectionChanged
         If CustomersDataGridView.Columns(CustomersDataGridView.CurrentCell.ColumnIndex).Name = "CompanyNameColumn" Then
             CustomersDataGridView.CurrentCell.Selected = False
         End If
    End Sub
    Replace CustomersDataGridView with the name of your DataGridView and replace CompanyNameColumn with the name of the column to have un-selectable.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2016
    Posts
    255

    Re: how to set columns in datagrid so that they can't have focus?

    thanks,
    the "readonly" part does already the job.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width