I am getting some strange results when trying to access data thrown into a
DataGrid. Perhaps someone can shed some light and provide a solution to my
issues....

Process:
Load DataGrid1 with an ADOrs - no problem
Click a cell to retrieve it's value - some problems

When clicked, I am *trying* to set the Row number like this,

Dim RowValue
RowValue = DataGrid1.RowContaining(Y)

What I get for the value is actually +1 from the ADOrs value (so, clicking a
cell in the first row will give me a RowValue = 1). No problem, just
subtract 1 ( -1) from the actual row number to access the correct row (0) in
the ADOrs, right? Well, this works for rows 1 thru 3 in the DataGrid1.
Here's what happens past row 3:

Clicking a cell in row #4 in the DataGrid returns a RowValue = 5!!!! So, by
subtracting 1 from this, gives me row 4 in the ADOrs which is the inncorect
value from where I clicked. It should be giving me a RowValue = 4 (which in
turn would select row 3 in the ADOrs).

Also -- when clicking on or past row 5 in the DataGrid, it returns a
RowValue = -1 which of course totally throws everything off and bombs out the
app.

Any insight as to this behavior and how to remedy would be greatly
appreciated. Code below.

Thanks,

j


Private Sub dataGrid1_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As stdole.OLE_XPOS_PIXELS, ByVal Y As stdole.OLE_YPOS_PIXELS)
Dim RowValue, ColValue
Dim cellVal As String
Dim pos As Integer
ColValue = DataGrid1.ColContaining(X)
RowValue = DataGrid1.RowContaining(Y)
pos = RowValue - 1
cellVal = DataGrid1.Columns("ID").CellText(DataGrid1.RowBookmark(pos))
End Sub

Re: DataGrid HELP! by Bob

Bob
Thu Jun 23 15:11:52 CDT 2005

jamesfreddyc wrote:
> I am getting some strange results when trying to access data thrown
> into a DataGrid. Perhaps someone can shed some light and provide a
> solution to my issues....

I don't get it. You are doing neither scripting nor vbscript. Why did you
expect to get an answer to this question here?

There are plenty of newsgroups devoted to .Net programming: Look for groups
with the word "dotnet" in their names, such as
microsoft.public.dotnet.framework.aspnet
or
microsoft.public.dotnet.framework.vbnet
or
microsoft.public.dotnet.framework.adonet

Pick one (don't crosspost to all of them) and post your question to it. If
you choose the wrong one, I'm sure someone will point you to the proper
group

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



Re: DataGrid HELP! by jamesfreddyc

jamesfreddyc
Fri Jun 24 09:02:04 CDT 2005

whoops. sorry bout that! No, didn't make any cross posts, just thought this
was the correct forum!

j

"Bob Barrows [MVP]" wrote:

> jamesfreddyc wrote:
> > I am getting some strange results when trying to access data thrown
> > into a DataGrid. Perhaps someone can shed some light and provide a
> > solution to my issues....
>
> I don't get it. You are doing neither scripting nor vbscript. Why did you
> expect to get an answer to this question here?
>
> There are plenty of newsgroups devoted to .Net programming: Look for groups
> with the word "dotnet" in their names, such as
> microsoft.public.dotnet.framework.aspnet
> or
> microsoft.public.dotnet.framework.vbnet
> or
> microsoft.public.dotnet.framework.adonet
>
> Pick one (don't crosspost to all of them) and post your question to it. If
> you choose the wrong one, I'm sure someone will point you to the proper
> group
>
> Bob Barrows
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>
>

Re: DataGrid HELP! by Bob

Bob
Fri Jun 24 09:31:45 CDT 2005

jamesfreddyc wrote:
> whoops. sorry bout that!

Oops. I badly worded that (in a rush, bad day, pick an excuse ...). I did
not intend to make you feel the need to apologize. There was nothing for
which to apologize. You chose the wrong group: I advised you about better
groups to use to get an answer. That's all. I was not offended, just
puzzled. :-)

> No, didn't make any cross posts,

:-) I didn't say you did. I was just advising you not to do it when you post
your question to the dotnet group(s).

Bob

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"