G
Guest
2nd problem with that listbox doesn't refresh after adding an item.
When I originally submitted this problem and received a much appreciated
solution from Jeffry, I tried the new button only with lstConcepts0, which
worked fine. However, it doesn't work for any other of the three listboxes.
I even tried the following:
Private Sub btnNewC1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnNewC1.Click
Dim frm As New frmNewConcept
With frm
.iNew = Me.lstConcepts0.SelectedValue
.iNewAddMode = True
.ShowDialog()
End With
frm.Dispose()
Dim i As Integer = lstConcepts0.Items.Count
Dim iSelected As Integer
iSelected = lstConcepts0.SelectedIndex
Select Case iSelected
Case Is = i - 1
lstConcepts0.SelectedIndex = iSelected - 1
lstConcepts0.SelectedIndex = iSelected + 1
Case Else
lstConcepts0.SelectedIndex = iSelected + 1
lstConcepts0.SelectedIndex = iSelected - 1
End Select
End Sub
Not surprisingly, it didn't help at all.
Jeffrey suggested I send a sample app as an attachment. I normally use the
web news reader. I tried Outlook Express, but didn't see attachments someone
graciously sent me, nor did I see how to attach any files. Perhaps somebody
could tell me exactly how to add and download attachments. The help file
wasn't helpful.
Thanks,
Dennis
On a page I have 4 listboxes, the last three of which are child entries of
the previous. Works fine.
Above each listbox I have a New button. New opens up a NewConcepts form in
an AddNew state. I fill in the new concept, update the database and the form
closes.
NewConcepts was opened showdialog so focus returns to the listboxes. I
would have expected the listbox to show the new concept, but it doesn't.
Here is the code for the relevant New button:
Private Sub btnNewC0_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNewC0.Click
Dim frm As New frmNewConcept
With frm
'.iNew = Me.lstConcepts0.SelectedValue this is true for all the
others
.iNew = 0
.iNewAddMode = True
.ShowDialog()
End With
'Dim int As Integer = frm.iAddNumber
'MsgBox(int.ToString)
If frm.iAddNumber > 0 Then
Me.dsC.Clear()
Me.daC.Fill(dsC, "Concepts")
Me.lstConcepts0.Refresh()
End If
frm.Dispose()
End Sub
If I check the database, the new concept is there. If I close the form and
reopen it, the new concept is there.
Can somebody please be so kind as to show me how to persuade the listbox to
show the new item?
Thank you.
Dennis
Private Sub lstConcepts1_SelectedValueChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles lstConcepts1.SelectedValueChanged
Dim r As Dataset1.ConceptsRow = CType(Me.lstConcepts1.SelectedItem,
Dataset1.ConceptsRow)
Try
Me.lstConcepts2.DataSource =
dsC.Concepts.FindByID(r.ID).GetChildRows("ConceptsConcepts")
iParentID2 = lstConcepts1.SelectedValue
this line Me.lstConcepts2.DataSource =
dsC.Concepts.FindByID(r.ID).GetChildRows("ConceptsConcepts")
However, when I close the form and reopen it, everything is ok again.
It seems it ought to be easy to refresh the listbox to include the added
concept. I would really appreciate some help.
Dennis
Winform databinding is a 2 ways databinding, that is the change in the
underlying datasource(dataset) will immediately reflect to the UI(listbox).
I can not reproduce our your issue yet.
I think this issue should have nothing to do with the database, because the
UI only reflect the change of datasource. I suggest you create a sample
project(which gets rid of the database dependency) to help me to reproduce
your issue, then I can understand your issue much better, and help you to
figure out the problem.(You may attach the reproduce project as an
attachment in a reply) I will wait for your further feedback, thanks!
======================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Jeffrey,
Thank you very much. I read your answer, and removed the following
statements from my button_click handler
Me.dsC.Clear()
Me.daC.Fill(dsC, "Concepts")
Me.lstConcepts0.Refresh()
After that it worked fine.
Thanks again.
Dennis
When I originally submitted this problem and received a much appreciated
solution from Jeffry, I tried the new button only with lstConcepts0, which
worked fine. However, it doesn't work for any other of the three listboxes.
I even tried the following:
Private Sub btnNewC1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnNewC1.Click
Dim frm As New frmNewConcept
With frm
.iNew = Me.lstConcepts0.SelectedValue
.iNewAddMode = True
.ShowDialog()
End With
frm.Dispose()
Dim i As Integer = lstConcepts0.Items.Count
Dim iSelected As Integer
iSelected = lstConcepts0.SelectedIndex
Select Case iSelected
Case Is = i - 1
lstConcepts0.SelectedIndex = iSelected - 1
lstConcepts0.SelectedIndex = iSelected + 1
Case Else
lstConcepts0.SelectedIndex = iSelected + 1
lstConcepts0.SelectedIndex = iSelected - 1
End Select
End Sub
Not surprisingly, it didn't help at all.
Jeffrey suggested I send a sample app as an attachment. I normally use the
web news reader. I tried Outlook Express, but didn't see attachments someone
graciously sent me, nor did I see how to attach any files. Perhaps somebody
could tell me exactly how to add and download attachments. The help file
wasn't helpful.
Thanks,
Dennis
On a page I have 4 listboxes, the last three of which are child entries of
the previous. Works fine.
Above each listbox I have a New button. New opens up a NewConcepts form in
an AddNew state. I fill in the new concept, update the database and the form
closes.
NewConcepts was opened showdialog so focus returns to the listboxes. I
would have expected the listbox to show the new concept, but it doesn't.
Here is the code for the relevant New button:
Private Sub btnNewC0_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNewC0.Click
Dim frm As New frmNewConcept
With frm
'.iNew = Me.lstConcepts0.SelectedValue this is true for all the
others
.iNew = 0
.iNewAddMode = True
.ShowDialog()
End With
'Dim int As Integer = frm.iAddNumber
'MsgBox(int.ToString)
If frm.iAddNumber > 0 Then
Me.dsC.Clear()
Me.daC.Fill(dsC, "Concepts")
Me.lstConcepts0.Refresh()
End If
frm.Dispose()
End Sub
If I check the database, the new concept is there. If I close the form and
reopen it, the new concept is there.
Can somebody please be so kind as to show me how to persuade the listbox to
show the new item?
Thank you.
Dennis
Private Sub lstConcepts1_SelectedValueChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles lstConcepts1.SelectedValueChanged
Dim r As Dataset1.ConceptsRow = CType(Me.lstConcepts1.SelectedItem,
Dataset1.ConceptsRow)
Try
Me.lstConcepts2.DataSource =
dsC.Concepts.FindByID(r.ID).GetChildRows("ConceptsConcepts")
iParentID2 = lstConcepts1.SelectedValue
this line Me.lstConcepts2.DataSource =
dsC.Concepts.FindByID(r.ID).GetChildRows("ConceptsConcepts")
However, when I close the form and reopen it, everything is ok again.
It seems it ought to be easy to refresh the listbox to include the added
concept. I would really appreciate some help.
Dennis
Winform databinding is a 2 ways databinding, that is the change in the
underlying datasource(dataset) will immediately reflect to the UI(listbox).
I can not reproduce our your issue yet.
I think this issue should have nothing to do with the database, because the
UI only reflect the change of datasource. I suggest you create a sample
project(which gets rid of the database dependency) to help me to reproduce
your issue, then I can understand your issue much better, and help you to
figure out the problem.(You may attach the reproduce project as an
attachment in a reply) I will wait for your further feedback, thanks!
======================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Jeffrey,
Thank you very much. I read your answer, and removed the following
statements from my button_click handler
Me.dsC.Clear()
Me.daC.Fill(dsC, "Concepts")
Me.lstConcepts0.Refresh()
After that it worked fine.
Thanks again.
Dennis