-
Jan 13th, 2016, 04:21 PM
#1
Thread Starter
Fanatic Member
SelectedRows Always 0
searchResultsDataGrid.SelectedRows.Count always says 0 even when I click on a row. I have the selection mode set to FullRowSelect. Any ideas?
vb Code:
If String.IsNullOrEmpty(JC.Global.StudyForm.filename) And searchResultsDataGrid.SelectedRows.Count > 0 Then
JC.Global.StudyForm.defaultFilename = searchResultsDataGrid.SelectedRows(0).Cells(1).Value.ToString()
End If
I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.
-
Jan 13th, 2016, 05:51 PM
#2
Re: SelectedRows Always 0
What sort of grid is it exactly? I'm guessing a DataGridView but I don't see where you've actually made that clear. What happens if you select multiple rows? Also, do you really care about SelectedRows? Do you maybe just want the CurrentRow regardless?
-
Jan 13th, 2016, 07:52 PM
#3
Thread Starter
Fanatic Member
Re: SelectedRows Always 0
It is a DataGridView.
searchResultsDataGrid.CurrentRow = Nothing
I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.
-
Jan 13th, 2016, 09:15 PM
#4
Re: SelectedRows Always 0
Originally Posted by rex64
searchResultsDataGrid.SelectedRows.Count always says 0 even when I click on a row. I have the selection mode set to FullRowSelect. Any ideas?
vb Code:
If String.IsNullOrEmpty(JC.Global.StudyForm.filename) And searchResultsDataGrid.SelectedRows.Count > 0 Then JC.Global.StudyForm.defaultFilename = searchResultsDataGrid.SelectedRows(0).Cells(1).Value.ToString() End If
Where is this code located? Which Event/Procedure/Function? How do you know SelectedRows.Count is 0, where do you test it?
-
Jan 14th, 2016, 01:20 PM
#5
Thread Starter
Fanatic Member
Re: SelectedRows Always 0
I put a brake point on the line inside of the If statement:
searchResultsDataGrid.CurrentRow = Nothing
vb Code:
Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles btnAdd.Click If String.IsNullOrEmpty(JC.Global.StudyForm.filename) Then JC.Global.StudyForm.defaultFilename = searchResultsDataGrid.CurrentRow.Cells(1).Value.ToString 'searchResultsDataGrid.SelectedRows(0).Cells(1).Value.ToString() End If End Sub
I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.
-
Jan 14th, 2016, 01:34 PM
#6
Thread Starter
Fanatic Member
Re: SelectedRows Always 0
I found the problem. I am dumb. I moved this to the bottom of my function and added a comment. This was the issue:
vb Code:
'User is done with this form. EXITS. LOL <<<<<<<<<<<< Close()
I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|