Solved

Building Infopower TwwDBGrids at runtime

Posted on 2004-09-09
4
935 Views
Last Modified: 2010-04-05
I'm using Inforpower 4000 and Delphi 7

I need to build a TwwDBGrid dynamically at runtime.

I need to control which fields are displayed and column attributes.

Problems I have run into:

The Count property of the Columns collection appears to be hidden so how do you get column count (which can be different from field count)?

To start with a blank grid, do I need to delete all the default fields/ columns created automatically?  If so, how do I do that?

How does one then create the grid columns you want and do you need to just create columns or columns and fields?
0
Comment
Question by:Paul197466
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12015239
what i do is simply to change the selected.strings property and then call Applyselected.

To see the structure of the selected strings, build a wwdbgrid in designtime and see the selected property in the .dfm file

here's a piece of code from a my project where i build an empty grid in runtime (used then with more different tables)...

    grdTabella.Selected.Strings[0] := Prefisso + '_Cx'#9'9'#9'codice'#9'F';
    grdTabella.Selected.Strings[1] := Prefisso + '_Descrizione'#9'32'#9'descrizione'#9'F';
    grdTabella.ApplySelected;
    grdTabella.DataSource := ADataSource;

grdTabella is a TwwDBGrid
every Selected Item is a column, so here i'me creating two columns
now let's see the string '_Cx'#9'9'#9'codice'#9'F' : every #9 is a separator
the first '_Cx' is the fieldname
the second '9' is the columnwidth
the third 'codice' is the displayed columntitle
and the last is the readonly flag F or T (False or True)

finally i call the selcted.applyselected to design the columns and apply them and then the datasource (i've already said that i use it with many similar tables)...

BTW this is quite what you have to do


Hope it helps

F68 ;-)
0
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 500 total points
ID: 12015246
Forgot to say: don't worry about those 'Prefisso'; it's a prefix that i use to pass the table name to the grid (again, for using it with more tables)....

F68 ;-)
0
 

Author Comment

by:Paul197466
ID: 12015254
Thanks a lot

I looked at all the obvious properties but never looked at selected as I assumed it was something to do with current selection!
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12015294
Every day is a good day to learn some new thing, as i do also :)))

Glad to have helped you :)

F68 ;-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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