Results 1 to 4 of 4

Thread: Data grid: How to enter and change data?

  1. #1

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

    Post

    Hi, folks!

    I've added a Datagrid control to my form and have set its properties like this:
    AllowAddNew = false
    AllowDelete = false
    AllowUpdate = false, on the form load event

    There's a button called "Add New", with the following module:
    MyDatagrid.AllowAddNew = True
    Mydatagrid.AddNewMode
    But when I click this button, this error message appears:
    Invalid use of property (regarding the 2nd line, property .AddNewMode

    There's another button called "Changes", with the module:
    MyDataGrid.AllowUpdate = True
    MyDataGrid.EditActive
    And the same error message appears for the .EditActive property.

    What I am doing wrong?
    I'd like to allow the user to change or add new records only after clicking the proper buttons. I've done with another forms, but that's the 1rst. time I work with the DataGrid Control.

    Please, help!
    Thanks in advance for any ideas,

    Roselene


  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Here is what MSDN help has to say
    ========================================

    AddNewMode Property


    Returns a value that describes the location of the current cell with respect to the grid's AddNew row. Read-only at run time and not available at design time.

    Syntax

    object.AddNewMode

    The AddNewMode property syntax has these parts:

    Part Description
    object Anobject expression that evaluates to an object in the Applies To list.


    Values

    The AddNewMode property returns one of the following:

    Constant Value Description
    dbgNoAddNew 0 The current cell is not in the last row, and no AddNew operation is pending.
    dbgAddNewCurrent 1 The current cell is in the last row, but no AddNew operation is pending.
    dbgAddNewPending 2 The current cell is in the next to last row as a result of a pending AddNew operation initiated by the user through the grid's user interface, or by code as a result of setting the Value or Text properties of a column.


    Remarks

    If the AllowAddNew property is True, the last row displayed in the grid is left blank to permit users to enter new records. If the AllowAddNew property is False, the blank row is not displayed, and AddNewMode always returns 0.


    ------------------
    Marty
    What did the fish say when it hit the concrete wall?
    > > > > > "Dam!"

  3. #3
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670

    Post

    AddNewMode cannot be set at runtime (hence the phrase "read-only at runtime").



    ------------------
    Mark "Buzby" Beeton
    VB Developer
    [email protected]



  4. #4

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

    Post

    Martin and Mark,

    Thanks for taking the time to help me.
    I was using those properties on the wrong way. Now, I'm using a code like this in my "Add New" button:
    MyDataGrid.Enabled = True
    MyDataGrid.AllowAddNew = True
    AdodcDataGrid.Recordset.AddNew
    MyDataGrid.SetFocus

    But I still have some doubts, in case you, please, can help me more:
    A)if I use
    AdodcDataGrid.Recordset.Delete
    (AdodcDataGrid is the ADO Control which feeds the Data Grid Control)
    it will delete only the line of the data grid where the cursor is?
    How can send the user a message to let him/her know if he/she is deleting the correct record?

    B) My Datagrid has 3 columns. The first column is the one I use to connect the data in the DataGrid with the data in the top of the form. This column will always displays the same data that is already in the top, cause EquipID in the top of the form = EquipID in the DataGrid.
    So, I've set this column width to 1 in the DataGrid, in order to make it invisible.
    when the user enter new data, I'll have to enter data in this column using code or VB will fill this column? (cause the SQL which feeds the DataGrid says: select Manyfields where MyTableEquipID = MyDataComboEquipID)

    I'm really sorry if my questions are too simple or if I bother you somehow, but I really can't see the way it works clearly so far.

    Thanks very much for you attention,
    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