Results 1 to 2 of 2

Thread: datagrid on form - enter data in cell event

  1. #1

    Thread Starter
    Registered User jkw119's Avatar
    Join Date
    Oct 2001
    Location
    Pittsburgh
    Posts
    256

    datagrid on form - enter data in cell event

    doe anyone know how to trigger an event when a user enters data in a cell in a data grid. also, is it possible to disable columns (make readonly) and allow only certain columns to be edited.
    thanks,

    jeff

  2. #2
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621

    Re: datagrid on form - enter data in cell event

    Originally posted by jkw119
    doe anyone know how to trigger an event when a user enters data in a cell in a data grid. also, is it possible to disable columns (make readonly) and allow only certain columns to be edited.
    thanks,

    jeff
    I have used the Validate event in other controls which fires anytime somthing is done, don't know if this is any use.

    As far as disabling the columns, I don't know.

    You can however hide them. The following code hides columns if it is of any use.

    VB Code:
    1. Private Sub HideColumns()
    2.    ' Use the DataField property to determine which column is being
    3.    ' tested. Show only three columns: ProductName, UnitPrice, and
    4.    ' UnitsInStock.
    5.    
    6.    Dim c As Column
    7.    For Each c In DataGrid1.Columns
    8.       Select Case c.DataField
    9.       Case "ProductName"
    10.          c.Visible = True
    11.       Case "UnitPrice"
    12.          c.Visible = True
    13.       Case "UnitsInStock"
    14.          c.Visible = True
    15.          c.Caption = "In Stock" ' Change the column header.
    16.       Case Else ' Hide all other columns.
    17.          c.Visible = False
    18.       End Select
    19.    Next c
    20. End Sub
    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


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