Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging Columns in a grid

Status
Not open for further replies.

ravicoder

Programmer
Apr 29, 2006
26
0
1
IN
hi all

I am using the grid control extensively to display data on screen

Just wanted to know if there is any way to merge some columns (like excel) based on a condition

e.g. my grid has say 5 column based on table data. if a record has a particular condition like field1 = 'TOTAL', i want the 5 columns of that particular row to display as merged.

i have attached a sample screenshot of my existing grid for reference

Is this possible? any help or guidance would be greatly appreciated

 
 https://files.engineering.com/getfile.aspx?folder=44786795-1a8e-48a2-8fdb-5201ed83121d&file=GridDisplay.png
No, you can't do this in the way that you can in Excel. The grid is nothing more or less than a window into a table or cursor. It can only display columns that correspond to fields in the cursor. Furthermore, the columns in a grid are all the same width. You cannot have a column in the total row equal to the widths of five individual columns.

That said, it would be possible for one of the columns in the total rows to show a concatenation of the five fields. The problem is that it would still be the same width as the single columns. It would not span five columns, as it would in Excel.

If you can live with that, then you need to create a cursor that reflects that arrangement. In other words, put the five values in the individual fields for the non-total rows, and put the merged values in the first field in the total rows.

The only other solution I can think of is to look for a third-party grid that supports this functionality.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
The two simplest third party grids you can use are

1. An Excel sheet object, of course.
2. a WebBrowser control diaplaying a HTML grid that allows spanning columns and rows.

For 1 you'll need to dig into VBA code to merge cells, the macro recording feature of Office applilcation helps a lot with that.
For 2 you'll need HTML knowledge or need to learn the necessary bits about mainly the <table> html tag and related tags.

Chriss
 
You can use MSHFlexGrid to merge cells.



If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top