|
-
May 31st, 2017, 03:41 PM
#1
Thread Starter
Lively Member
DataGridView UncheckAdd conflicts with delete row code
Hello! I hate having to bother you all with questions, I usually ask when I do not know how to word it in Google Search Engine so yeah... Anyways, I had this issue that when you click the starting row that automatically fills with datagridview, it crashes the program due to my code. Anyways, I was wanting that to go away anyways so I went into the Datagridview properties and unchecked Enable Adding. Now, I suspect it is messing up my index variable, which index is integer Because when I click the whole row that I manually populated with enable adding unchecked and click delete, it crashes the program with error: 'Index was out of range. Must be non-negative and less than the size of the collection.'
Which shouldn't be happening right? Here is my code for it all:
Code:
Dim index As Integer
Delete Row Button Code:
Code:
DataGridView1.Rows.Remove(DataGridView1.SelectedRows(index))
I do not understand why this is happening, it works when the Enable Adding is checked. Is it because the program visuals shows populating but in the data, the row isn't populating but only does visually? That is what I suspect is happening.
Last edited by Dragnorian; May 31st, 2017 at 04:33 PM.
Tags for this Thread
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
|