all groups > vb.net > january 2004 >
You're in the

vb.net

group:

Selection issue


Selection issue Fay Yocum
1/17/2004 9:30:26 PM
vb.net:
On loading of a form I have a datagrid loaded, If there is only one person
in the database I want that record to automatically be selected. I used this
code and it works.At least the one row is highlighted.
If Me.BindingContext(DsPerson1, "tblPerson").Count = 1 Then

DataGrid1.Select(0)

End If

Prior to including this code I had the following code on the open click
event.
If PK = 0 Then

MsgBox("You must select a person, then click Open.")

PK indicates that no record has been selected hence the 0.

My problem is that I get the message box even though the above code
apparently had selected the one and only record.

Any ideas? Thank you for your time.

Fay

Re: Selection issue Tom Leylan
1/18/2004 12:40:32 AM
"Fay Yocum" <fyocum@REMOVEix.netcom.com> wrote...

Hi Fay,

[quoted text, click to view]

I think it depends upon how PK is getting set and from the sounds of it, it
isn't getting set... but rather than set PK perhaps you can reference
DataGrid1.CurrentCell.RowNumber()

Tom

AddThis Social Bookmark Button