PC Review


Reply
Thread Tools Rate Thread

Q: Determing in a column in a datagrid

 
 
Geoff Jones
Guest
Posts: n/a
 
      20th Nov 2004
Hi

Can anybody tell me how to find the column index in a DataGrid knowing only
the text in the column heading? Any sample code would be most useful.

Thanks in advance

Geoff


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      20th Nov 2004
Geoff,

With styles?

When not than can it in my opinion be something as (depending on your
datasource)
\\\
dim columnindex as integer
for columnindex = 0 to dg.datasource.datatable.columns
if datasource.datatable.columns(i).name = mytest
exit for
next
///
I never did this, but just typed in this message as idea.

Cor

"Geoff Jones" <(E-Mail Removed)>

> Hi
>
> Can anybody tell me how to find the column index in a DataGrid knowing
> only
> the text in the column heading? Any sample code would be most useful.
>
> Thanks in advance
>
> Geoff
>
>



 
Reply With Quote
 
 
 
 
Geoff Jones
Guest
Posts: n/a
 
      20th Nov 2004
Hi Cor

I like the idea, unfortunately it does not work i.e. dg.datasource does not
have a member "datatable".

Geoff

"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Geoff,
>
> With styles?
>
> When not than can it in my opinion be something as (depending on your
> datasource)
> \\\
> dim columnindex as integer
> for columnindex = 0 to dg.datasource.datatable.columns
> if datasource.datatable.columns(i).name = mytest
> exit for
> next
> ///
> I never did this, but just typed in this message as idea.
>
> Cor
>
> "Geoff Jones" <(E-Mail Removed)>
>
> > Hi
> >
> > Can anybody tell me how to find the column index in a DataGrid knowing
> > only
> > the text in the column heading? Any sample code would be most useful.
> >
> > Thanks in advance
> >
> > Geoff
> >
> >

>
>



 
Reply With Quote
 
Geoff Jones
Guest
Posts: n/a
 
      20th Nov 2004
Hi again Cor

You were, as always, on the right lines. Many thanks.

All that was needed was a few minor changes to the code:

Dim index As Integer
For index=0 To dg.DataSource.Columns.Count - 1
If dg.DataSource.Columns(index).ColumnName = mytestString Exit For
Next

i.e. The dg.DataSource returns a DataTable, in my case, so there is no need
to use the DataTable part in the original code.

Geoff

"Geoff Jones" <(E-Mail Removed)> wrote in message
news:419f5fc5$0$310$(E-Mail Removed)...
> Hi Cor
>
> I like the idea, unfortunately it does not work i.e. dg.datasource does

not
> have a member "datatable".
>
> Geoff
>
> "Cor Ligthert" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Geoff,
> >
> > With styles?
> >
> > When not than can it in my opinion be something as (depending on your
> > datasource)
> > \\\
> > dim columnindex as integer
> > for columnindex = 0 to dg.datasource.datatable.columns
> > if datasource.datatable.columns(i).name = mytest
> > exit for
> > next
> > ///
> > I never did this, but just typed in this message as idea.
> >
> > Cor
> >
> > "Geoff Jones" <(E-Mail Removed)>
> >
> > > Hi
> > >
> > > Can anybody tell me how to find the column index in a DataGrid knowing
> > > only
> > > the text in the column heading? Any sample code would be most useful.
> > >
> > > Thanks in advance
> > >
> > > Geoff
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determing which column is identity column Doug Microsoft ADO .NET 4 16th Dec 2005 03:19 PM
Determing DataType for a returned DataSet Column =?Utf-8?B?QW1lbGlh?= Microsoft ADO .NET 3 25th Sep 2004 03:15 AM
Determing current table row from DataGrid =?Utf-8?B?VWJp?= Microsoft C# .NET 1 5th Sep 2004 02:47 AM
Determing MaxLength of SQLCE DB Column Joe Keller Microsoft Dot NET Compact Framework 0 4th Feb 2004 04:34 PM
hijack this-need help determing what to dump Lew Windows XP Internet Explorer 0 4th Sep 2003 03:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:47 PM.