Yes you can use GetType().ToString() and after that to
look in this string but better is would be:
....
Dim dgc As DataGridColumn
Dim bc As ButtonColumn
dim tc as TemplateColumn
....
For Each dgc In myGrid.Columns
If TypeOf dgc Is ButtonColumn Then
bc = dgc
...
end if
...
If TypeOf dgc Is TemplateColumn Then
tc = dgc
...
end if
...
Next
Best
Svetlin Grancharov
[quoted text, click to view] >-----Original Message-----
>Well at this point I don't know how to figure out what
kind of column bc is.
>Do I use bc.GetType?
>Any example appreciated.
>
>"Svetlin Grancharov" <sgrancharov@frontsys.com> wrote in
message news:<0ecd01c3859a$8fee1af0$a301280a@phx.gbl>...
>> Use DataGridColumn instead of BoundColumn. So the code
>> should be:
>>
>> dim bc as DataGridColumn
>> for each bc in myGrid.Columns
>> ...
>> After that depends on column (some could be
BoundColumn,
>> some TemplateColumn) you can read headings and data
column
>> names.
>>
>> Svetlin Grancharov
>>
>> >-----Original Message-----
>> >Hello,
>> >
>> >I have several pages with datagrids, and I was
thinking
>> of writing a common
>> >excel function.
>> >
>> >I want to iterate through the columns of each datagrid
to
>> pick off the
>> >headings and data column names.
>> >
>> >The datagrids may include template columns, so if I do
>> this:
>> >
>> > dim bc as BoundColumn
>> > for each bc in myGrid.Columns
>> > ...
>> >
>> >it'll raise an error when it hits the template column.
>> >
>> >I saw a post about going through the items collection
of
>> the datagrid, but I
>> >wasn't sure how
>> >to do this.
>> >
>> >JC
>> >
>> >
>> >
>> >
>> >.
>> >
>.