Results 1 to 7 of 7

Thread: [RESOLVED] Enable/Disable Column in a DataGrid?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Michigan
    Posts
    304

    Resolved [RESOLVED] Enable/Disable Column in a DataGrid?

    I tried this but it seems to do absolutly nothing.

    VB Code:
    1. Private Sub Session5SupportedCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Session5SupportedCheckBox.CheckedChanged
    2.         If Session5SupportedCheckBox.Checked = True Then
    3.             dtService.Columns.Item(6).ReadOnly = False
    4.             DataGridServices.Refresh()
    5.         Else
    6.             dtService.Columns.Item(6).ReadOnly = True
    7.             DataGridServices.Refresh()
    8.         End If
    9.     End Sub
    Last edited by fdunford; Sep 27th, 2005 at 02:37 PM.

  2. #2
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: Enable/Disable Colunm in a DataGrid?

    Is this DataGrid is bounded to a DataGridTableStyle and DataGridColumnStyle ?
    Using VS 2010 on Fw4.0

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Michigan
    Posts
    304

    Re: Enable/Disable Colunm in a DataGrid?

    Hi Z. Yes on both.

  4. #4
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: Enable/Disable Colunm in a DataGrid?

    Well Have you try to Disabled the Column by it's bounded DataGridColumnStyle ?
    Using VS 2010 on Fw4.0

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Michigan
    Posts
    304

    Re: Enable/Disable Colunm in a DataGrid?

    Zak,

    I mis-spoke. I have a DataGridTableStyle but not a DataGridColumnStyle . I just tried to figure out how to create a DataGridColumnStyle but seem to be having a bad go of it. Can you help?


    code from a previous question

  6. #6
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: Enable/Disable Colunm in a DataGrid?

    A easy way to create DataGridColumnStyle is by the usage of the Collection editor from the DataGrid, look at the TableStyles property from the Grid and from that collection editor look for DataGridColumnStyle

    You may also look at this MSDN Article for more info
    http://msdn.microsoft.com/library/de...lumnstyle1.asp

    Hope it will help !!
    Using VS 2010 on Fw4.0

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Michigan
    Posts
    304

    Re: Enable/Disable Colunm in a DataGrid?

    Got it via the DataGridTableStyle.

    VB Code:
    1. Private Sub Session4SupportedCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Session4SupportedCheckBox.CheckedChanged
    2.         Dim dgts As DataGridTableStyle
    3.         Dim cb1 As DataGridColumnStyle
    4.  
    5.         If dtService.Columns.Count > 0 Then
    6.             dgts = DataGridServices.TableStyles(sServiceTable)
    7.             cb1 = dgts.GridColumnStyles.Item(sSessionCB4)
    8.             If Session4SupportedCheckBox.Checked = True Then
    9.                 gSessions(4).Mandatory = False
    10.                 cb1.ReadOnly = False
    11.             Else
    12.                 gSessions(4).Mandatory = True
    13.                 cb1.ReadOnly = True
    14.             End If
    15.         End If
    16.     End Sub

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