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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid Columns 1

Status
Not open for further replies.

isha

MIS
Mar 7, 2002
216
IN
I have used DataGrid with ADODC control and set the DataGrid data source as ADODC1. By doing this all the ten columns of the concerned table are displayed in the grid. But I want to have only five colums on the DataGrid. When i do so the column header and data is not displayed but the total number of columns of the grid remains as 10.(Five filled and five blank)I want to remove these five blank grid columns. How can I do that. Please help.
 
Not sure if I'm being too simplistic, but it looks like you need to organise the data before connecting the grid to it. So instead of connecting directly to your table, Create a View/Query which removes the blank items like -

SELECT * FROM products WHERE Len(Code) > 0

or use Not isnull(Code) depending on which systems you are using.
 
This will not remove the columns but it makes them not visable.
datagrid1.columns(2).visable=false
'this will make the third column not shown.
datagrid column count starts at zero(0)

the next two lines creates a HEADER that says SERIAL NUMBER and the data inside each columns will be aligned in the center.


DataGrid1.Columns(3).Alignment = dbgCenter
DataGrid1.Columns(3).Caption = " Serial Number"

By making a column invisable you can still access that information if needed.
 

Use the following in the RecordSource property of the data control:

SELECT Field1, Field2, Field7, Field8, Field9 FROM TheTable

Replacing Fieldx with the field names you want on the grid and TheTable with the actual table name where the data comes from.

Also set the CommandType property to 1 - CmdText



The other option would be to just hide the columns:

DataGrid1.Columns(3).Visible = False

In doing so, you keep the fields in the underlying recordset in case you need to reference them for what ever reason, but the data grid doesn't show them.

[/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
CCLINT
Thanks.
your hint has solved the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top