PDA

Click to See Complete Forum and Search --> : combining table fields in a DataGrid & HeadClick event


billwagnon
Nov 2nd, 1999, 09:18 AM
1. Is there a way to combine datafields in a DataGrid? I am opening a new recordset, setting the DataGrid datasource to the recordset.

In my tables I have firstname field and a last name field. I would like to leave the tables the way they are, but combine the names in "last, first" format in the DataGrid.

I suppose the issue is, can you create new fields for the recordset on the fly, or are you stuck with the fields in the base tables?

2. I am using the HeadClick event to sort the DataGrid by the column clicked. But - after the click, the WHOLE column is selected. How do you turn the column selection off (and just select one of the cells?)

Manish
Nov 2nd, 1999, 11:27 AM
hi,
to bind a recordset with a grid at runtime u need to use column collection of the grid. set field name for each column using datafield property.

I don't think there is any way to create fields using recordset object. u need to update base table separately and save the table structure before u can use any new field added to the base table.

reg the selected column u can place the following statement in the headclick event of the grid
dbgrid.SelStartCol = -1

Thanx Manish

billwagnon
Nov 2nd, 1999, 09:25 PM
Thanks Manish. I already am binding the recordset to the DataGrid, and that works fine. What I will try next is opening my Dynaset, and creating a new recordset from it that combines two of the fields.