473,386 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

too many form instances...

Hi
I have a main form showing personal information (name, address etc.) bound
to a dataset.
One of the pieces of information is the Group the person belongs to. This is
selected from a combo box.
If I want to add a new group to the list. I open a new form like this

myfrmAddGroup = New FrmAddGroup(Me.Dataset1)
myfrmAddGroup.Show()
myfrmAddGroup = Nothing

The FrmAddgroup has this constructor:

Public Sub New(ByRef inpds As Dataset)

It then uses this dataset as datasource in a grid.
No problems this far.

But if I open the form and add a new group.
Then close the form
Then open the form and delete a group. (Any group)
I receive the error:
"An unhandled exception of type 'System.IndexOutOfRangeException' occurred
in system.windows.forms.dll
Additional information: No value at index 13."
In the _main_ forms first line (Public Class frmMainForm) .
And I canŽt debug it. It does not say where it appeared. (And I of course
have try catch on all functions)

(I have 14 items in the group list)
I added an rowdeleting eventhandler to frmAddGroup and it appears that this
is called one time for each time I open the form. Ie if open and close the
form 5 times the eventhandler is called 5 times when I delete a row.

So it makes sense: it first deletes the row as it is supposed to. index 13
is fine. But then it tries to delete the row at index 13 again. and fails.
How do get rid of the closed instances of the frmAddGroup so this will not
happen?

Any suggestions?

TIA

Jan
Nov 21 '05 #1
18 1612
Jan,

New FrmAddGroup(Me.Dataset1)
myfrmAddGroup.Show()
myfrmAddGroup = Nothing


When I see this kind of code I think directly on "IsDisposed"

Setting a frm to nothing has no sense by the way, this will be ignored when
there is still a reference to that object.

http://msdn.microsoft.com/library/de...posedtopic.asp

A piece of code from a message from Hefried
\\\\
If foSearchForm Is Nothing OrElse foSearchForm.IsDisposed Then
foSearchForm = New FrmSearchForm()
End If
foSearchForm.Show()
///

I hope this helps?

Cor

Nov 21 '05 #2
Jan,

New FrmAddGroup(Me.Dataset1)
myfrmAddGroup.Show()
myfrmAddGroup = Nothing


When I see this kind of code I think directly on "IsDisposed"

Setting a frm to nothing has no sense by the way, this will be ignored when
there is still a reference to that object.

http://msdn.microsoft.com/library/de...posedtopic.asp

A piece of code from a message from Hefried
\\\\
If foSearchForm Is Nothing OrElse foSearchForm.IsDisposed Then
foSearchForm = New FrmSearchForm()
End If
foSearchForm.Show()
///

I hope this helps?

Cor

Nov 21 '05 #3
Hi Cor
Thanks for answering.

I tried Herfrieds code
It does not make any difference.
Remember I close the form (by clicking the red X) then open it, then close
it etc.
This also disposes it. (I have verified this. The Dispose of the form is
executed)

Jan
"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:e%****************@TK2MSFTNGP14.phx.gbl...
Jan,

New FrmAddGroup(Me.Dataset1)
myfrmAddGroup.Show()
myfrmAddGroup = Nothing


When I see this kind of code I think directly on "IsDisposed"

Setting a frm to nothing has no sense by the way, this will be ignored
when there is still a reference to that object.

http://msdn.microsoft.com/library/de...posedtopic.asp

A piece of code from a message from Hefried
\\\\
If foSearchForm Is Nothing OrElse foSearchForm.IsDisposed Then
foSearchForm = New FrmSearchForm()
End If
foSearchForm.Show()
///

I hope this helps?

Cor

Nov 21 '05 #4
Hi Cor
Thanks for answering.

I tried Herfrieds code
It does not make any difference.
Remember I close the form (by clicking the red X) then open it, then close
it etc.
This also disposes it. (I have verified this. The Dispose of the form is
executed)

Jan
"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:e%****************@TK2MSFTNGP14.phx.gbl...
Jan,

New FrmAddGroup(Me.Dataset1)
myfrmAddGroup.Show()
myfrmAddGroup = Nothing


When I see this kind of code I think directly on "IsDisposed"

Setting a frm to nothing has no sense by the way, this will be ignored
when there is still a reference to that object.

http://msdn.microsoft.com/library/de...posedtopic.asp

A piece of code from a message from Hefried
\\\\
If foSearchForm Is Nothing OrElse foSearchForm.IsDisposed Then
foSearchForm = New FrmSearchForm()
End If
foSearchForm.Show()
///

I hope this helps?

Cor

Nov 21 '05 #5
Jan,

A question, is there in your datagrid a comboboxcolumn?

Cor

"Jan Nielsen"
Hi Cor
Thanks for answering.

I tried Herfrieds code
It does not make any difference.
Remember I close the form (by clicking the red X) then open it, then close
it etc.
This also disposes it. (I have verified this. The Dispose of the form is
executed)

Jan
"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:e%****************@TK2MSFTNGP14.phx.gbl...
Jan,

New FrmAddGroup(Me.Dataset1)
myfrmAddGroup.Show()
myfrmAddGroup = Nothing


When I see this kind of code I think directly on "IsDisposed"

Setting a frm to nothing has no sense by the way, this will be ignored
when there is still a reference to that object.

http://msdn.microsoft.com/library/de...posedtopic.asp

A piece of code from a message from Hefried
\\\\
If foSearchForm Is Nothing OrElse foSearchForm.IsDisposed Then
foSearchForm = New FrmSearchForm()
End If
foSearchForm.Show()
///

I hope this helps?

Cor


Nov 21 '05 #6
Jan,

A question, is there in your datagrid a comboboxcolumn?

Cor

"Jan Nielsen"
Hi Cor
Thanks for answering.

I tried Herfrieds code
It does not make any difference.
Remember I close the form (by clicking the red X) then open it, then close
it etc.
This also disposes it. (I have verified this. The Dispose of the form is
executed)

Jan
"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:e%****************@TK2MSFTNGP14.phx.gbl...
Jan,

New FrmAddGroup(Me.Dataset1)
myfrmAddGroup.Show()
myfrmAddGroup = Nothing


When I see this kind of code I think directly on "IsDisposed"

Setting a frm to nothing has no sense by the way, this will be ignored
when there is still a reference to that object.

http://msdn.microsoft.com/library/de...posedtopic.asp

A piece of code from a message from Hefried
\\\\
If foSearchForm Is Nothing OrElse foSearchForm.IsDisposed Then
foSearchForm = New FrmSearchForm()
End If
foSearchForm.Show()
///

I hope this helps?

Cor


Nov 21 '05 #7
Jan,

I do not understand this.
Therefore I added a sample is that something as you are doing this?

\\\form1 with a button
Dim ds As New DataSet
Dim frm As Form2
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
createDS()
frm = New Form2(ds)
frm.Owner = Me
frm.Show()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
ds.Tables(0).Rows(2).Delete()
If frm.IsDisposed Then
frm = New Form12(ds)
frm.Show()
Else
frm.TopMost = True
End If
End Sub
Public Sub createDS()
Dim dt As New DataTable
ds.Tables.Add(dt)
dt.Columns.Add("Numbers", GetType(System.Int32))
dt.Columns.Add("Characters")
For i As Integer = 0 To 9
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
ds.Tables(0).Rows(i).ItemArray = _
(New Object() {i.ToString, ChrW(i + 65)})
Next
End Sub
////
\\\Form2 has a datagrid and the form new is like this
Private ds1 As DataSet
Public Sub New(ByVal ds As DataSet)
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
ds1 = ds
'Add any initialization after the InitializeComponent() call
DataGrid1.DataSource = ds1.Tables(0)
End Sub
////

I am curious about that

Cor
"Jan Nielsen"
Hi Cor
No, just one textbox
(I added a jpeg)

Best regards

Jan

"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:%2******************@TK2MSFTNGP09.phx.gbl...
Jan,

A question, is there in your datagrid a comboboxcolumn?

Cor

"Jan Nielsen"
Hi Cor
Thanks for answering.

I tried Herfrieds code
It does not make any difference.
Remember I close the form (by clicking the red X) then open it, then
close
it etc.
This also disposes it. (I have verified this. The Dispose of the form is
executed)

Jan
"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:e%****************@TK2MSFTNGP14.phx.gbl...
Jan,
>New FrmAddGroup(Me.Dataset1)
> myfrmAddGroup.Show()
> myfrmAddGroup = Nothing
>

When I see this kind of code I think directly on "IsDisposed"

Setting a frm to nothing has no sense by the way, this will be ignored
when there is still a reference to that object.

http://msdn.microsoft.com/library/de...posedtopic.asp

A piece of code from a message from Hefried
\\\\
If foSearchForm Is Nothing OrElse foSearchForm.IsDisposed Then
foSearchForm = New FrmSearchForm()
End If
foSearchForm.Show()
///

I hope this helps?

Cor




Nov 21 '05 #8
Hi Cor

Form1 code:
************************************************** *******************************
Dim ds As New DataSet()
Dim frm As Form2
Dim i As Integer
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
createDS()
End Sub
Public Sub createDS()
Dim dt As New DataTable()
ds.Tables.Add(dt)
dt.Columns.Add("Numbers", GetType(System.Int32))
dt.Columns.Add("Characters")
For i = 0 To 9
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
ds.Tables(0).Rows(i).ItemArray = _
(New Object() {i.ToString, ChrW(i + 65)})
Next
End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
frm = New Form2(ds)
' frm.Owner = Me
frm.Show()
End Sub
************************************************** *******************************

Form2 code (Entire form class):
************************************************** *******************************
Public Class Form2
Inherits System.Windows.Forms.Form
Private ds1 As DataSet
#Region " Windows Form Designer generated code "
Public Sub New(ByVal ds As DataSet)
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
ds1 = ds
'Add any initialization after the InitializeComponent() call
DataGrid1.DataSource = ds1.Tables(0)
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.DataGrid1 = New System.Windows.Forms.DataGrid()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginIni t()
Me.SuspendLayout()
'
'DataGrid1
'
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(264, 256)
Me.DataGrid1.TabIndex = 0
'
'Form2
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.DataGrid1})
Me.Name = "Form2"
Me.Text = "Form2"
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit( )
Me.ResumeLayout(False)
End Sub
#End Region
End Class

************************************************** *******************************

Now open form2 and add a row
Close form2
Open form2 again and delete the row you just added

Best regards

Jan

"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:eW****************@TK2MSFTNGP09.phx.gbl...
Jan,

I do not understand this.
Therefore I added a sample is that something as you are doing this?

\\\form1 with a button
Dim ds As New DataSet
Dim frm As Form2
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
createDS()
frm = New Form2(ds)
frm.Owner = Me
frm.Show()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
ds.Tables(0).Rows(2).Delete()
If frm.IsDisposed Then
frm = New Form12(ds)
frm.Show()
Else
frm.TopMost = True
End If
End Sub
Public Sub createDS()
Dim dt As New DataTable
ds.Tables.Add(dt)
dt.Columns.Add("Numbers", GetType(System.Int32))
dt.Columns.Add("Characters")
For i As Integer = 0 To 9
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
ds.Tables(0).Rows(i).ItemArray = _
(New Object() {i.ToString, ChrW(i + 65)})
Next
End Sub
////
\\\Form2 has a datagrid and the form new is like this
Private ds1 As DataSet
Public Sub New(ByVal ds As DataSet)
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
ds1 = ds
'Add any initialization after the InitializeComponent() call
DataGrid1.DataSource = ds1.Tables(0)
End Sub
////

I am curious about that

Cor
"Jan Nielsen"
Hi Cor
No, just one textbox
(I added a jpeg)

Best regards

Jan

"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:%2******************@TK2MSFTNGP09.phx.gbl...
Jan,

A question, is there in your datagrid a comboboxcolumn?

Cor

"Jan Nielsen"

Hi Cor
Thanks for answering.

I tried Herfrieds code
It does not make any difference.
Remember I close the form (by clicking the red X) then open it, then
close
it etc.
This also disposes it. (I have verified this. The Dispose of the form
is
executed)

Jan
"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:e%****************@TK2MSFTNGP14.phx.gbl...
> Jan,
>
>
>>New FrmAddGroup(Me.Dataset1)
>> myfrmAddGroup.Show()
>> myfrmAddGroup = Nothing
>>
>
> When I see this kind of code I think directly on "IsDisposed"
>
> Setting a frm to nothing has no sense by the way, this will be ignored
> when there is still a reference to that object.
>
> http://msdn.microsoft.com/library/de...posedtopic.asp
>
> A piece of code from a message from Hefried
> \\\\
> If foSearchForm Is Nothing OrElse foSearchForm.IsDisposed Then
> foSearchForm = New FrmSearchForm()
> End If
> foSearchForm.Show()
> ///
>
> I hope this helps?
>
> Cor
>
>
>



Nov 21 '05 #9
Jan,

I tested what you sent, however that did not throw an error in the way as
you told it.

Not important, however in my sample is an typor there is on someplaces
form12 what has to be form2 (i changed it in the text)

Cor
Nov 21 '05 #10
Hi Cor
Yes, I noticed the form12 thing.
I use VS 2002. Could that be the problem?

Jan

Jan
"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:%2****************@TK2MSFTNGP12.phx.gbl...
Jan,

I tested what you sent, however that did not throw an error in the way as
you told it.

Not important, however in my sample is an typor there is on someplaces
form12 what has to be form2 (i changed it in the text)

Cor

Nov 21 '05 #11
Jan,

I would not know why, I don't have that any more installed.

However would look strange to me, you tested it exactly with that sample
program as you showed me?

(And does the delete just with the delete key)

Cor

"Jan Nielsen"
Hi Cor
Yes, I noticed the form12 thing.
I use VS 2002. Could that be the problem?

Jan

Jan
"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:%2****************@TK2MSFTNGP12.phx.gbl...
Jan,

I tested what you sent, however that did not throw an error in the way as
you told it.

Not important, however in my sample is an typor there is on someplaces
form12 what has to be form2 (i changed it in the text)

Cor


Nov 21 '05 #12
Hi Cor
Here is the exact code for the 2 forms:
Form1:
************************************************** ***************
Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents Button1 As System.Windows.Forms.Button

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.Button1 = New System.Windows.Forms.Button()

Me.SuspendLayout()

'

'Button1

'

Me.Button1.Location = New System.Drawing.Point(88, 56)

Me.Button1.Name = "Button1"

Me.Button1.TabIndex = 0

Me.Button1.Text = "Button1"

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 266)

Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1})

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout(False)

End Sub

#End Region

Dim ds As New DataSet()

Dim frm As Form2

Dim i As Integer

Private Sub Form1_Load(ByVal sender As Object, _

ByVal e As System.EventArgs) Handles MyBase.Load

createDS()
End Sub
Public Sub createDS()

Dim dt As New DataTable()

ds.Tables.Add(dt)

dt.Columns.Add("Numbers", GetType(System.Int32))

dt.Columns.Add("Characters")

For i = 0 To 9

ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)

ds.Tables(0).Rows(i).ItemArray = _

(New Object() {i.ToString, ChrW(i + 65)})

Next

End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

frm = New Form2(ds)

' frm.Owner = Me

frm.Show()

End Sub

End Class

************************************************** ***************
Form2:
************************************************** ***************
Public Class Form2

Inherits System.Windows.Forms.Form

Private ds1 As DataSet

#Region " Windows Form Designer generated code "

Public Sub New(ByVal ds As DataSet)

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

ds1 = ds

'Add any initialization after the InitializeComponent() call

DataGrid1.DataSource = ds1.Tables(0)

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.DataGrid1 = New System.Windows.Forms.DataGrid()

CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginIni t()

Me.SuspendLayout()

'

'DataGrid1

'

Me.DataGrid1.DataMember = ""

Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText

Me.DataGrid1.Name = "DataGrid1"

Me.DataGrid1.Size = New System.Drawing.Size(264, 256)

Me.DataGrid1.TabIndex = 0

'

'Form2

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 266)

Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.DataGrid1})

Me.Name = "Form2"

Me.Text = "Form2"

CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit( )

Me.ResumeLayout(False)

End Sub

#End Region

End Class

************************************************** ***************

And here is exact what I do:
I start the program
Then I click Button1
Then I add the values "99", "Testing" to a row. And click with the mouse in
a NEW row to save this row (ie the row with the * to the left). This is very
important for the error to appear. Sorry I forgot to tell that. If you
create the row and click in an old row the error will not appear.
Then I close Form2
Then I open Form2
Then I delete the row with values "99", "Testing" by marking the record
selector with the mouse and pressing the Delete key
Then the error appears

Jan

"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:eS**************@TK2MSFTNGP09.phx.gbl...
Jan,

I would not know why, I don't have that any more installed.

However would look strange to me, you tested it exactly with that sample
program as you showed me?

(And does the delete just with the delete key)

Cor

"Jan Nielsen"
Hi Cor
Yes, I noticed the form12 thing.
I use VS 2002. Could that be the problem?

Jan

Jan
"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:%2****************@TK2MSFTNGP12.phx.gbl...
Jan,

I tested what you sent, however that did not throw an error in the way
as you told it.

Not important, however in my sample is an typor there is on someplaces
form12 what has to be form2 (i changed it in the text)

Cor



Nov 21 '05 #13
Jan,

Now I could simulate the error,

With adding this the error was gone. I did not test on side effects of
course.
\\\
Private Sub Form2_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
BindingContext(ds1.Tables(0)).EndCurrentEdit()
End Sub
///

I hope it helps however?

Cor
Nov 21 '05 #14
Hi Cor
Thanks for your help
Appearantly it solved the problem
I'll be back

Jan
"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:%2****************@TK2MSFTNGP11.phx.gbl...
Jan,

Now I could simulate the error,

With adding this the error was gone. I did not test on side effects of
course.
\\\
Private Sub Form2_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles
MyBase.Closing
BindingContext(ds1.Tables(0)).EndCurrentEdit()
End Sub
///

I hope it helps however?

Cor

Nov 21 '05 #15
Hi again Cor
As I wrote in my last mail, it solves the problem, but it adds an empty row
(a row with null value) to the datatable.
But I guess IŽll just have to delete all rows with null value when I close
the form.

I still do not understand why the problem occurs.
And I do not understand why I canŽt catch it with a try catch

Best regards

Jan


"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:%2****************@TK2MSFTNGP11.phx.gbl...
Jan,

Now I could simulate the error,

With adding this the error was gone. I did not test on side effects of
course.
\\\
Private Sub Form2_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles
MyBase.Closing
BindingContext(ds1.Tables(0)).EndCurrentEdit()
End Sub
///

I hope it helps however?

Cor

Nov 21 '05 #16
Jan,

I am not reproducing your error anymore or read the thread, however was it
not that you created an empty row and than closes when the error did occur.
This kind of behaviour you can prevent by adding an "NewRow" button to your
form and remove the + row with.

table.defaultview.allownew = false

When you than want to add a row you have to set it temporaly to true by the
way.

Just my thought,

Cor

"Jan Nielsen" <Re**************@tiscali.dk>
Hi again Cor
As I wrote in my last mail, it solves the problem, but it adds an empty
row (a row with null value) to the datatable.
But I guess IŽll just have to delete all rows with null value when I close
the form.

I still do not understand why the problem occurs.
And I do not understand why I canŽt catch it with a try catch

Best regards

Jan


"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:%2****************@TK2MSFTNGP11.phx.gbl...
Jan,

Now I could simulate the error,

With adding this the error was gone. I did not test on side effects of
course.
\\\
Private Sub Form2_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles
MyBase.Closing
BindingContext(ds1.Tables(0)).EndCurrentEdit()
End Sub
///

I hope it helps however?

Cor


Nov 21 '05 #17
Hi again Cor
Thanks for your advice
The error occurred when you
1) added a new row, and
2) clicked with the mouse in the new empty row that appears as soon as you
enter text in the new row.
3) closed the form and re-opened it
4) deleted the newly added row

IŽll look at your solution.
But as far as I can see it will not take me anywhere ;-)
As soon as I allowNew I imagine that the problem appears again.

Best regards

Jan
"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:uS**************@TK2MSFTNGP12.phx.gbl...
Jan,

I am not reproducing your error anymore or read the thread, however was it
not that you created an empty row and than closes when the error did
occur. This kind of behaviour you can prevent by adding an "NewRow" button
to your form and remove the + row with.

table.defaultview.allownew = false

When you than want to add a row you have to set it temporaly to true by
the way.

Just my thought,

Cor

"Jan Nielsen" <Re**************@tiscali.dk>
Hi again Cor
As I wrote in my last mail, it solves the problem, but it adds an empty
row (a row with null value) to the datatable.
But I guess IŽll just have to delete all rows with null value when I
close the form.

I still do not understand why the problem occurs.
And I do not understand why I canŽt catch it with a try catch

Best regards

Jan


"Cor Ligthert" <no************@planet.nl> skrev i en meddelelse
news:%2****************@TK2MSFTNGP11.phx.gbl...
Jan,

Now I could simulate the error,

With adding this the error was gone. I did not test on side effects of
course.
\\\
Private Sub Form2_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles
MyBase.Closing
BindingContext(ds1.Tables(0)).EndCurrentEdit()
End Sub
///

I hope it helps however?

Cor



Nov 21 '05 #18
Jan,

Than I remembered me it well,
The error occurred when you
1) added a new row, and
2) clicked with the mouse in the new empty row that appears as soon as you
enter text in the new row.
And here the row will be produced by the endcurrentedit
Because of the fact that you cannot see if the user has entered something or
not when he pushed on the close button you should in my opinion either
checks on null or make this behaviour impossible by deleting the + button.
That is of course your choise.
3) closed the form and re-opened it
4) deleted the newly added row

IŽll look at your solution.
But as far as I can see it will not take me anywhere ;-)
As soon as I allowNew I imagine that the problem appears again.

Best regards

Nov 21 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tonya | last post by:
Hi, Does anyone have any example of how i can manage forms in my application?? I want to be able to reference my form instances that are currently open from other forms. why cant i open...
16
by: David Lauberts | last post by:
Hi Wonder if someone has some words of wisdom. I have a access 2002 form that contains 2 graph objects that overlay each other and would like to export them as a JPEG to use in a presentation....
6
by: John | last post by:
Hi Is it possible to close a form through code from within itself without using the form name? I just worry that form name can change and the code will stop working. Thanks Regards
12
by: (Pete Cresswell) | last post by:
I know I can open many instances of a given form, but I've never done it. Now I'm analyzing an application where that seems like just the ticket: Many investment funds, *lots* of data points for...
17
by: Barret Bonden | last post by:
As an old programmer just now looking at VB.net I have a question: How does one simply open one form from another ? I don't mean how does one create a new instance of that form , but rather how...
7
by: Terry | last post by:
I have a Mainform with a Statusbar. When opening another form or doing some processing I want to display info in the Statusbar of the Mainform. I have read a lot of articles on this & have come up...
4
by: GGerard | last post by:
Hello I have a program where the user can open as many instances of a form as the user wants. The only limit to how many instances can be opened is determined by the limit of the computer...
6
by: Savante | last post by:
I have been writing a datalogging application. It reads in double's into a database. I want to be able to click on a row in a database (holds name of variable and also current value of variable)...
3
by: Jon | last post by:
My main form opens up another form, and from this other form, I'd like to access things in the main form. The problem is that although I know the name of the class of the main form (FormMain) I...
5
by: Neil | last post by:
"lyle" <lyle.fairfield@gmail.comwrote in message news:48c3dde7-07bd-48b8-91c3-e157b703f92b@f3g2000hsg.googlegroups.com... Question for you. I'm doing something similar, only, instead of opening...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.