Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

MSHFlexiGird. How To Add Columns At Runtime

I am using a MSHFlexiGrid to which I am allocating a recordset at run time. I don't want to display all the fields returned from the recordset in the MSHFlexiGrid but want to select which ones to display at runtime. How do I do this?
0
Shandy
Asked:
Shandy
1 Solution
 
jayaraghuCommented:
HI,
you can just assign the field name to the grids cell.
for example,
if your query is
strsql="select * from StudentsTable"
set recordset=...

the table contains 5 fields, namely
studentid, studentname, studentDOB, studentcourse, studentgrade.

you want to display studentid and studentname in the grid.

for row=1 to recordset.recordcount-1
for col = 0 to 1
msflexgrid1.textmatrix(row,col)=recordset(col)
next col
next row

i hope this is what u expect.
good luck
JayaRaghu
0
 
ShandyAuthor Commented:
Not quite what I was after. I want to bind the MSHFlexGrid at runtime to a recordset and then only display certain columns/fields from the recordset in the MSHFlexGrid. I want the MSHFlexGrid to populate itself from the datasource I set at runtime (which it does), not assign field values manually to the MSHFlexGrid.
0
 
MarineCommented:
Ok say your recordset will retrieve 100 records at once. But you want only to show 10 at first and when click next load the next 10 ? There is something called "Paging" Set the cachsize of recordset = to 10 then use pagecount property and in a loop you move though the records. Post your reply if this what you need i will give an example.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ShandyAuthor Commented:
I'm afraid I'm not explaining this very well.

Try this example.
I want to use a recordset containing the fields:
forename, surname, Identity Number
I want to bind the MSHFlexGrid to this recordset at run time but only display forename and surname. By default it seems to display all 3 fields.

I know I could set up 2 separate recordsets but it just seemed a waste of resource if I could get the MSHFlexGrid to run off a recordset I already had open.
0
 
mfclaesCommented:
Hi Shandy

I might understand this wrong but if I get it right, then I suggest this

if you assign  your recordset like this

strsql="select * from StudentsTable"
set recordset=...

then you can do the following thing:

strsql="select forename, surname from StudentsTable"
set recordset=...

or just set the width of your third column to 1, so it is there but you won't see it





0
 
VBGuruCommented:
Lets say you have 3 fields in your recordset namely f1,f2 and f3
and you don't want to display the field f2
So you will query the database like this
"select f1,f3,f2 from table"

and you will set the flexgrids colms as this
MSFlexGrid1.Cols = 2
so the last column is removed from display. So make sure to get the fields which you don't want to diaply at the last.


Hope it will help.
0
 
ShandyAuthor Commented:
Setting the width to 0 works. Obvious as soon as you pointed it out to me!
Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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