-
May 5th, 2019, 01:31 AM
#1
Thread Starter
Lively Member
[RESOLVED] DropDownList is only filling alternate rows in DataGridView
This is really bizarre and I could not figure it out.
Why is the Job_Status and Production_Status filled up in an alternate manner?
By default, when user creates a New Row Entry, Job_Status and Production_Status will have a default value set to them.
But here, I could not figure why only the alternate rows are filled.
As you can see, there are no problem with other fields, only DropDownList isn't filling the rows properly...
User creates New Entry by clicking AddNew Button.
Here I set default values to Job_StatusComboBox & Production_StatusComboBox
Code:
Private Sub AddNew_btn_Click(sender As Object, e As EventArgs) Handles AddNew_btn.Click
POTextBox.Focus()
ProjectsBindingSource.AddNew()
'Set Default Text
Job_StatusComboBox.Text = "On Hold"
Production_StatusComboBox.Text = "Processing"
Date_Of_EntryDateTimePicker.Value = DateTime.Now
Lead_TimeDateTimePicker.Value = DateTime.Now
Last_UpdatedLabel1.Text = Date.Now.ToString("dd-MM-yyyy HH:mm:ss")
save_btn.BackColor = Color.DarkGray
AddNew_btn.Enabled = False
End Sub
User then click SAVE to commit changes
Code:
Private Sub save_btn_Click(sender As Object, e As EventArgs) Handles save_btn.Click
AddNew_btn.Enabled = True
Try
Last_UpdatedLabel1.Text = Date.Now.ToString("dd-MM-yyyy HH:mm:ss")
ProjectsBindingSource.EndEdit()
ProjectsTableAdapter.Update(EVC_ProjectsDataSet.Projects) 'Name of DB Table
'Refresh the ID in the GridView
EVC_ProjectsDataSet.Clear()
ProjectsTableAdapter.Fill(EVC_ProjectsDataSet.Projects)
MessageBox.Show("Data Saved!")
save_btn.BackColor = DefaultBackColor
Catch ex As Exception
MessageBox.Show("Error saving data!")
End Try
loadCellColor()
End Sub
Only SAVE, the DataGridView will update with the new row.
So why are only alternate rows having the default value?
-
May 5th, 2019, 10:34 AM
#2
Re: DropDownList is only filling alternate rows in DataGridView
There isn't enough code to be certain what the problem is, but there are a couple possibilities.
1) The simplest one is that you have set some kind of custom coloring such that those cells are white on white.
2) Another is that adding something is causing a series of events which are interacting in such a way that the cells are being emptied.
The first can be eliminated pretty easily by highlighting the rows. If there is text there, it will show up when highlighted, most likely. However, that first one is unlikely, since you don't appear to be coloring cells at all.
The second one is going to be harder to figure out. You might step through the actions of adding. By using F11, you should step through every event handler that is triggered by the act of adding, which might show you one that is clearing out those cells when you didn't think it would, or should.
If I understand what you were saying about saving, which is very much in doubt, you seem to be suggesting that the rows save correctly. Is that right?
My usual boring signature: Nothing
-
May 6th, 2019, 09:01 AM
#3
Thread Starter
Lively Member
Re: DropDownList is only filling alternate rows in DataGridView
Thanks for reply.
I decided to use this to make default value.
Code:
Private Sub AddNew_btn_Click(sender As Object, e As EventArgs) Handles AddNew_btn.Click
POTextBox.Focus()
ProjectsBindingSource.AddNew()
'Set Default Text
Dim row = CType(ProjectsBindingSource.Current, DataRowView).Row
row.SetField("Job_Status", " ")
row.SetField("Production_Status", " ")
End Sub
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
|