Results 1 to 11 of 11

Thread: db grid

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    I'm using this but not binding it to anything. The reason I'm using it is because I'm using list boxes etc inside the cells. My problem is how do I add a row into the grid? Can I use this control like I do with a normal grid? I need to add rows everytime they modify a row. Basically, have 1 empty row in the begining. When they click and edit this row, a new blank one appears so that there is always a blank one there. Can I do this with this control?

    If not, what grid control should I use that will allow me to insert other controls into the cells?

    ------------------
    -------------------------
    I'm really easy to get along with once you people learn to
    worship me.
    -------------------------

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    I don't have that option. Is there any way I can do that using the Databound grid or the normal data grid? Other wise I'll have to try to do the same thing with a flex grid with code. And I don't really want to do that.

    ------------------
    ----------------------
    I'm really easy to get along with once you people learn to
    worship me.
    ----------------------

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    Ok, I have the apex control. But I'm still not sure how to do what I need. I know with a normal grid I'd do this:

    flexgrid1.rows = flexgrid1.rows +1

    to add the new row. Well one how do I do that with the data grid? I can do what I want for the first row but if I click on a second one (unchecked Hide Empty rows) it says Data Access error. I don't want to bind it to any kind of data control.

    Basically, I have 3 columns. I;m using it to build a query. The first column is a list box of Field names. Depending on the field selected, it will fill the second column iwth the correct operand types and the third column will either be a check box, a list box or a plain text box.
    What I need to do everytime they click a line, either add an empty one below it incase they want to make another query OR have a series of empty ones that they can click and select.
    But, the Apec control gives me that error so I can't do it. I'm missing a property or code or something. Can anyone help?

  4. #4
    New Member
    Join Date
    Feb 2000
    Posts
    5

    Post

    I don't know if this is what you want but,
    to add a line to an unbound DBGrid you can use the code below.

    Private Sub DBGrid1_AfterColUpdate(ByVal ColIndex As Integer)

    DBGrid1.Row = DBGrid1.Row + 1

    To automatically add the row once you reach
    a specified column use the code below. The code below well add the row once you tab
    off column 3.

    Private Sub DBGrid1_AfterColUpdate(ByVal ColIndex As Integer)

    DBGrid1.Row= DBGrid1.Row + 1
    DBGrid1.Col = DBGrid1.Col - 3
    DBGrid1.SetFocus

    ===========================================

    Originally posted by netSurfer:
    I'm using this but not binding it to anything. The reason I'm using it is because I'm using list boxes etc inside the cells. My problem is how do I add a row into the grid? Can I use this control like I do with a normal grid? I need to add rows everytime they modify a row. Basically, have 1 empty row in the begining. When they click and edit this row, a new blank one appears so that there is always a blank one there. Can I do this with this control?

    If not, what grid control should I use that will allow me to insert other controls into the cells?


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

    Post

    Buy Apex TrueDBGrid - www.apexsc.com - not only do you get a far far far superior grid control (better than DBGrid or FlexGrid) for connecting to databases but you can also use it in a special 'storage' mode via an XArray object (provided with the grid) which you can basically treat like a database.
    This will enable you to add, edit, delete rows and columns etc without actually having to have a database to store the data.


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



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

    Post

    With the Apex TrueDBGrid;

    1. Add an Apex XArray object to the project (using references)

    2. Setup the grid as you wish, but change it's DataMode to STORAGE, and set it's AllowAddNew to TRUE

    3. In code;

    (declarations)
    Dim MyData as New Xarray

    (normally in the load event of the form)
    'this sets up an array of 0 rows and 4 columns - change the number of columns to match the grid you have setup, but you normally start with 0 rows - this means the grid will only display the AddNew row.

    MyData.Redim 0,-1,0,3
    TDBGrid1.Array=MyData
    TDBGrid1.Rebind
    TDBGrid1.Refresh

    Now you should be able to keep adding new rows to the grid - as rows are added and changed the XArray object behind the scenes is storing the data.
    To see what the user has put in the grid, either talk to the grid directly using

    TDBGrid1.Columns([column).CellValue([row])

    or talk to the XArray object

    MyData([column],[row])


    I have been using the TrueDBGrid (and the XArray object) for nearly 3 years now so if you need any more help send me an e-mail.



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



  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    Thanks Buzby, only have 1 question. when I place:

    Dim MyData as New Xarray

    in the Declarations section of the form, it says User Defined Type not defined and highlights it. I've never used my own types so I'm not sure what I'm supposed to do.

    Etta: Thanks for the answer, but that doesn't work for this type of grid. Which sucks because that's what I'm used to doing too. Thanks though.

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

    Post

    You need to add the XArray object to the project references;

    1. Click on PROJECT / REFERENCES
    2. Select Apex XArray Object

    Let me know how you get on.



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



  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    Buzby, that lets me run it but after I fill in one row and click on antoher one, it blanks the data. I'm not sure what it is I'm not doing. I haven't used the appex control (or any datagrid control) before so I'm not sure exactly what I'm supposed to do. Do I have to code to add a new row? I assume I'd have to Redim MyData again, what params do I use to keep the data already in it? Thanks for your help.

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

    Post

    Check that AllowAddNew is set to TRUE.
    Check that the DataMode is set to STORAGE.
    If it still doesn't work - e-mail the form(s) involved to me and I'll take a look.



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




    [This message has been edited by Buzby (edited 02-04-2000).]

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    I'm still having problems. I'm sending the form to you right now. Thanks.

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