Getting the caption of a column that was clicked

when I click one of the cells in a data grid, I need to know the caption of the column that belongs to the clicked cell.

how do i do that????
please help me.
thank's alot .  
kukiyaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

stefanxCommented:
Uhmm,

I don't work with the DBGrid. But if it works like the MSFlexGrid then get it by saying:

Dbgrid1.TextMatrix(0,DBGrid1.Col)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Éric MoreauSenior .Net ConsultantCommented:
Use this:

Private Sub DataGrid1_Click()
    MsgBox DataGrid1.Columns(DataGrid1.Col).Caption
End Sub
0
kukiyaAuthor Commented:
The problem is  that the DataGrid1.Col value is not correct
(show 0 and sometimes -1).
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Éric MoreauSenior .Net ConsultantCommented:
Private Sub DataGrid1_Click()
   with datagrid1
      if .col < 0 then .col = 0
      MsgBox .Columns(.Col).Caption
   end with
End Sub
0
kukiyaAuthor Commented:
THIS IS GREAT.
TANK YOU VERY MUCH.

I'TS BETTER BE WRITTEN IN THE ROWCOLCHANGE EVENT, SO THAT THE CAPTIONOF THE CURRENT COLUMN WILL BE SHOWN AND NOT THE LAST COLUMN.

THANK'S ALOT!!!!!!
0
stefanxCommented:
Uhmm - I think this is emoreau's answer. Please contact EE Helpdesk so that emoreau can get his points
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.