|
-
Aug 29th, 2005, 04:39 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Updating MSHFlexgrid to reflect changes in data
This may well not be the right place to post it, but I hope it will help anyone who has experienced the difficulties I have had with the (generally excellent) MSHFlexGrid control.
The problem I had was that I used an MSHFlexGrid to display data from an MSDataShape recordset, by binding it to a command object in the data environment. However if I added or deleted a record (using an .execute statement on the connection) I could only get the Flexgrid to update by closing its underlying recordset, unloading the form, reopening the recordset and then reloading the form. .additem and .removeitem do not work with hierarchical recordsets the way the help file says they should, and .refresh does nothing. Even closing the recordset, setting .datamember to "", issuing .clearstructure then reopening the recordset and rebinding the grid does nothing. It seems that once the grid is bound to a command object it just won't let go!
However I have now found out that if I create my ADO connection in code (rather than using the dataenvironment designer) and populate the MSHFlexGrid using
Set MSHFlexGrid.Recordset = ADOconn.Execute(strSQL)
then changing the recordset and repopulating the grid works fine, without unloading and reloading the form.
No doubt this will come as no surprise to you proper programmers who never use databound controls anyway, but I thought that since the Flexgrid only gives you read-only access that it wouldn't really count as a databound control. Shows how wrong you can be.
Another connected issue- if you update the recordset obviously the pattern of .expanded rows is lost. I was advised (in a previous thread) to use an array to track which rows are expanded, then rebuild the structure after repopulating the grid. The problem is that .row and .rows change in a grid displaying a heirarchical recordset, depending on which rows are or are not expanded. In my grid, with the same recordset .rows can go from 5 if all rows are collapsed to 100 if all are expanded, or anywhere in between. What I did to get round this was to use a uniqueID column in each band (width set to zero). I then stepped through the rows in each band and if a row in a band was expanded put its uniqueID in a variable. I then used these variables to re-expand the rows after repopulating.
Anyway, I hope this helps someone. Should I mark the thread as resolved, as it isn't really a question?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|