Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

Problem with MS DataGrid ActiveX Control (V6 - SP3)


Im currently using this control to read tables from a database and allow the user to update them. Table values are loaded into this control based on the option selected in the Select Table menu. So if a user selects Table A from the the Menu, the values of Table A are loaded from the database.

However, Ive noticed that I cannot seem to display additional columns for other tables I dispaly. For example, in design mode I have set the DataMember property of this control to "Table A" So only the columns in this table will appear. (say 2 columns). But when I change it through my code to a different table (depending upon the option that the user has selected - Example Table B) only the first two rows of table B appear not the third one. But ive noticed that if i set this to a default in design mode and click on the "Retrieve Fields" property of the datagrid control, all three columns appear hasslefree. Is there a way to run this "retrieve fields" property dynamically through my code.

Heres my code:

Private Sub mnuSelectTable_Click(index As Integer)
    ' Structure to set data grid to selected table
    Select Case index
    Case 0
        dtgTable.DataMember = "tblA" 'has 2 columns, also this table is already set, in design mode, to appear as default
    Case 1
        dtgTable.DataMember = "tblB" 'has 3 columns, but only the first two show up...
    Case 2
        dtgTable.DataMember = "tblC"
    End Select
End Sub    

I'll appreciate if somecan please help me with this. I cannot use otehr controls as I am fixing someone elses code so that would require restructing his code/application.

1 Solution
I think from memory you have to perform a refresh or requery after you have set the datamember,
something like dtgtable.refresh or dtgtable.requery

rsajooAuthor Commented:
Its ok Ive fixed it by removing the default table that the control is linked to (in design view). However, I have another question, is there a way to change the dataformat of a column (ie for boolean datafields we want checkboxes) from my code? Ive tryed the following but both do not seem to work. Is there a work around?

mygrid.colums(2).dataformat = "boolean"
mygrid.colums(2).dataformat = 8

Please let meknow

PAQed with points refunded (50)

Community Support Moderator

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now