[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 144
  • Last Modified:

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 .  
0
kukiya
Asked:
kukiya
  • 2
  • 2
  • 2
1 Solution
 
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
 
É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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
É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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now