Vinod,
use the ColContaining method of the data grid.
Just pass the x coordinate of the mouse down event,
and it returns to you the index of the corresponding column (see example
below)
Sub DataGrid1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y
As Single)
Dim ColValue as Integer
ColValue = DataGrid1.ColContaining(X)
End Sub
m.
> -----Original Message-----
> From: Vinod Thomas [SMTP:vthomas@a...]
> Sent: Tuesday, February 27, 2001 11:37 AM
> To: professional vb
> Subject: [pro_vb] Re: column index on the move down event
>
> Thanks,
> It seems to be working. ONly if I click on any visible columns. If I click
>
> on the first column and there are some cols in the end which is not
> visible, it goes in a loop and give me the column number for all those
> that are not visible.
>
>
> >
> > what about taking the width of the columns and adding them together
> until you get a
> > number higher than the value of X, which was the horizontal location of
> the mouse
> > when a mouse button was clicked.
> >
> > Private Sub DataGrid1_MouseDown(Button As Integer, Shift As Integer, X
> As Single, Y
> > As Single)
> >
> > Dim i as integer
> >
> > For i = 0 to DataGrid1.Columns.Count - 1
> > If x > DataGrid1.Column(i).Left And _
> > x < (DataGrid1.Columns(i).Width + DataGrid1.Column(i).Left)
> Then
> > 'this was the column that was chosen
> > MsgBox "you clicked on the " & x & " column!"
> > End If
> > Next i
> >
> > End Sub
> >
> > something like that should do it. At least, it works well with a
> listview control.
> > :)
> >
> > hope this helps,
> >
> > john
> >
> > --- Vinod Thomas <vthomas@a...> wrote:
> > > Hi,
> > > How can I get the column Index on a mouse down event in data grid?
> > > Thanks
> > >
> > > Vinod
> >
> > ----------------------------
> > John Pirkey
> > MCSD
> > John@S...
> > http://www.stlvbug.org
>
>