Results 1 to 3 of 3

Thread: Selecting "cells" of a datagrid?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Itabirito,Minas Gerais, Brazil
    Posts
    79

    Post

    Hi, everybody!

    I have a DataGrid which contains 2 columns. I’d like the user to not be allowed to add or change data in the 1rst. one, since it'll be filled by code.

    The user also would be allowed to change data only in the last row.

    Is there anyway I can "disable" some cells of a datagrid and allow others to be "enabled"?

    Thanks in advance for any help,

    Roselene

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    Roselen,

    In the RowColChange event

    if datagrid1.col <> 1 then
    'this would be the second col
    msgbox "You cannot edit this column", vbokonly, "Error"
    datagrid1.col = 1
    end

    for the row, you'd have to get or store the number of rows in the datagrid because it doesn't have a ROWS property. Then do the same:

    If use ROWCOUNTER as the number of records in the datagrid, then go 1 less because first row is 0

    dim ROWCOUNTER as integer

    ROWCOUNTER = Data1.Recordset.RecordCount

    'this is the number of records in the data control. I'm assuming that you are using a datagrid that's bound to a data control.

    If datagrid1.row <> ROWCOUNTER -1
    'then not on last row
    msgbox "You can only edit the last row.",vbokonly, "Error"
    datagrid1.row = ROWCOUNTER -1
    end if

    Yo umay have to play with the code a bit but it should work.

    ------------------
    'cos Buzby says so!'

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Itabirito,Minas Gerais, Brazil
    Posts
    79

    Post

    netSurfer,

    It works beautifully and you've helped to solve another problem. As usual, I must say!

    Thanks very, very much!

    Best wishes,
    Roselene

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