locked
Populating a grid - strategy. RRS feed

  • Question

  • Hi all - another newbie question:

    I'm trying to have a grid populated by a sql statement.

    I am wondering if the proper strategy is to create the grid in the form designer by dropping the original table from the DE into the form, and then tweek the fields, record source etc, or do the whole thing in code?

    Thanks,
    Aleniko
    Monday, November 21, 2005 5:34 PM

Answers

  • There is no proper strategy for it. It's a personal preference. ie: You might create a grid from customer table, arrange it as you want and save as a class. Then you could put that subclassed grid on a form and use it with say a cursor with the same structure and alias. Or you might do all in code etc. ie: I use a custom builder to create the grid with headings and column widths as I want. My subclassed grids read and restore those heading caption, widths etc during init at runtime (subclassed grids I use have their own subclassed headers, columns, textboxes. Original only serves as a visual template).
    If at runtime that grid would be used by that table in DE then dropping the table in DE, selecting fields (or whole table), drag&drop onto form to create the grid is the simpliest way. You can also add your own subclassed grid as a grid to use when such a dragdrop from DE occurs (see field mappings under tools\options).
    Tuesday, November 22, 2005 10:07 AM

All replies

  • I create a table from the sql as readwrite exactly as it will appear then use the form designer to create the grid.

    In the load of the form I set the control source for the grid.

    Others may have better ways, but this is the way I like to create them.
    Monday, November 21, 2005 6:51 PM
  • There is no proper strategy for it. It's a personal preference. ie: You might create a grid from customer table, arrange it as you want and save as a class. Then you could put that subclassed grid on a form and use it with say a cursor with the same structure and alias. Or you might do all in code etc. ie: I use a custom builder to create the grid with headings and column widths as I want. My subclassed grids read and restore those heading caption, widths etc during init at runtime (subclassed grids I use have their own subclassed headers, columns, textboxes. Original only serves as a visual template).
    If at runtime that grid would be used by that table in DE then dropping the table in DE, selecting fields (or whole table), drag&drop onto form to create the grid is the simpliest way. You can also add your own subclassed grid as a grid to use when such a dragdrop from DE occurs (see field mappings under tools\options).
    Tuesday, November 22, 2005 10:07 AM
  • Great response CetinBasoz. Could you elaborate on how to do the click and drag when you are using lookup tables via a foriegn key? For example:

    TABLE: MASTER
          Field: MasterID     Type: identity
          Field: CountryID    Type: Int

    TABLE: luCountries
          Field: CountryID    Type: identity
          Field: Name           Type: nvarchar(50)

    I am looking to have the grid provide a drop down box to show all the countries when it goes to edit mode.

    Thanks in advanced.

    Wednesday, January 11, 2006 7:49 PM
  • I am looking to have the grid provide a drop down box to show all the countries when it goes to edit mode.

    You can download the white papaer and sample code from the session I gave on "How to put a combo box in a grid" from http://www.tightlinecomputers.com/Downloads.htm. It will give you everything you need to do this.

     

     

    Thursday, January 12, 2006 11:27 AM