Solved

MSHFlexiGird. How To Add Columns At Runtime

Posted on 2000-03-30
7
183 Views
Last Modified: 2010-05-02
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
Comment
Question by:Shandy
7 Comments
 

Expert Comment

by:jayaraghu
ID: 2668854
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
 

Author Comment

by:Shandy
ID: 2668979
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
 
LVL 6

Expert Comment

by:Marine
ID: 2669099
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Shandy
ID: 2669159
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
 

Accepted Solution

by:
mfclaes earned 50 total points
ID: 2670481
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
 
LVL 6

Expert Comment

by:VBGuru
ID: 2672329
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
 

Author Comment

by:Shandy
ID: 2672578
Setting the width to 0 works. Obvious as soon as you pointed it out to me!
Thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now