How do I exclude a field in a RS from being shown in my datagrid?
thnx,
squirrelly1
Printable View
How do I exclude a field in a RS from being shown in my datagrid?
thnx,
squirrelly1
VB Code:
dg.Columns(0).Width = 0 '1st column will not be displayed
Another thought is to direct your datasource to an SQL statement which doesn't include the excluded column.
These are both wonderful ideas and would work great if my datagrid was setup a specific way everytime; however, it isn't. The user of my program has the ability to choose which fields he wants displayed in the datagrid and in which order, so I can not know where the field is located that I want excluded from viewing.
Unless...
Ok, how would I know which field is the last field shown in the datagrid?
If I could do this, then I could just set that columns visible property to false...
thanx,
squirrelly1
The column captions and positions can be determined:
for i = 0 to datagrid1.Columns.Count - 1
position = i
caption = datagrid1.Columns(i).Caption
next i
Similarly the fields in the underlying recordset
for i = 0 to rs.Fields.Count - 1
position = i
name= rs.Fields(i).Name
next i