listbox doesn't refresh after adding an item.

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

RE: listbox doesn't refresh after adding an item by polynomial5d

polynomial5d
Sun Oct 24 09:25:02 CDT 2004

Actually, I've discovered the problem is much deeper than I thought. After
adding a new concept and closing the NewConcept form, the listboxes are not
functional any more. No matter which item I select in the lstConcepts0
listbox, the other three listboxes remain the same. When I changed
selections in the lstConcepts1 listbox, I got the following error:


system.data.rownotintableexception. this row has been removed from a table
and does not have an data.....
at .......lstConcepts!_SelectedValueChanged...line 1973

line 1873 is within the lstConcepts_SelectedValueChanged

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


RE: listbox doesn't refresh after adding an item by v-jetan

v-jetan
Mon Oct 25 04:32:50 CDT 2004

Hi Dennis,

I have added a reply to you in
microsoft.public.dotnet.framework.windowsforms group, please follow up
there, I will work with you. Thanks for your understanding!

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.


RE: listbox doesn't refresh after adding an item by polynomial5d

polynomial5d
Mon Oct 25 07:03:08 CDT 2004

I resolved the problem from you answer in windowforms. Thanks again.

Dennis

""Jeffrey Tan[MSFT]"" wrote:

> Hi Dennis,
>
> I have added a reply to you in
> microsoft.public.dotnet.framework.windowsforms group, please follow up
> there, I will work with you. Thanks for your understanding!
>
> 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.
>
>

RE: listbox doesn't refresh after adding an item by v-jetan

v-jetan
Tue Oct 26 01:16:19 CDT 2004

You are welcome!!

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.


RE: listbox doesn't refresh after adding an item by polynomial5d

polynomial5d
Tue Oct 26 09:29:09 CDT 2004

Jeffry ,

As you might have read in my follow up thread, it's working only for
lstconcepts0. Now I figured out how to send an attachment. If you're still
willing, I'll create an application only involving this issue, and send it in
a zip file through outlook express. Are you still willing?

dennis

""Jeffrey Tan[MSFT]"" wrote:

> You are welcome!!
>
> 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.
>
>

RE: listbox doesn't refresh after adding an item by v-jetan

v-jetan
Wed Oct 27 02:54:30 CDT 2004

Hi dennis,

Yes, you may attach a reproudce sample project in reply. You'd better
describe the details steps to reproduce out. And the expected behavior.
Then I can understand your problem better. I will wait for your further
feedback. Thanks

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.