PC Review


Reply
Thread Tools Rate Thread

Combo Box Selected Value changed event Gives Unhandleed exception.

 
 
=?Utf-8?B?VmluYXkgS2FudA==?=
Guest
Posts: n/a
 
      7th Nov 2005
Hey All,
What we are trying to achieve is, when Selected value changed event is fired
for a combo box, then we are trying to close the current form and display the
new form. The forms are mdi child of a MDI form named as MasterForm.

The code being used to close the current form and open the new form is as
follows:

lForm = new TestForm
lForm.MdiParent = Me.MdiParent
lForm.Show()
Me.Close()

Problem is on Selected value changed event, we get an unhandled exception,
Object reference not set to an instance of Object. I debugged and found that
while closing the current form, its throwing the error.

Can anyone please suggest this behaviour, is it a known issue.

Thanks,

Vinay Kant

 
Reply With Quote
 
 
 
 
S.M. Altaf [MVP]
Guest
Posts: n/a
 
      7th Nov 2005
I don't know how you've declared lForm, but you should declare it as public
in your MDI form, then

CType(Me.MdiParent, MAINMDI).lForm = New TestForm

CType(Me.MdiParent, MAINMDI).lForm.Show()

Me.Close()





--------------------------------------------------------------------------------
All that glitters has a high refractive index.
www.mendhak.com


"Vinay Kant" <(E-Mail Removed)> wrote in message
news:0A39849F-D463-48AD-B8F0-(E-Mail Removed)...
> Hey All,
> What we are trying to achieve is, when Selected value changed event is
> fired
> for a combo box, then we are trying to close the current form and display
> the
> new form. The forms are mdi child of a MDI form named as MasterForm.
>
> The code being used to close the current form and open the new form is as
> follows:
>
> lForm = new TestForm
> lForm.MdiParent = Me.MdiParent
> lForm.Show()
> Me.Close()
>
> Problem is on Selected value changed event, we get an unhandled exception,
> Object reference not set to an instance of Object. I debugged and found
> that
> while closing the current form, its throwing the error.
>
> Can anyone please suggest this behaviour, is it a known issue.
>
> Thanks,
>
> Vinay Kant
>



 
Reply With Quote
 
=?Utf-8?B?VmluYXkgS2FudA==?=
Guest
Posts: n/a
 
      7th Nov 2005
Altaf,
I used a Dim to declare that, i have event tried declaring it as public,
still the same problem. Code just breaks and takes me to the MDI Parent class
while debugging.
Problem persists. Any other suggestions.

Thanks,
Vinay kant

"S.M. Altaf [MVP]" wrote:

> I don't know how you've declared lForm, but you should declare it as public
> in your MDI form, then
>
> CType(Me.MdiParent, MAINMDI).lForm = New TestForm
>
> CType(Me.MdiParent, MAINMDI).lForm.Show()
>
> Me.Close()
>
>
>
>
>
> --------------------------------------------------------------------------------
> All that glitters has a high refractive index.
> www.mendhak.com
>
>
> "Vinay Kant" <(E-Mail Removed)> wrote in message
> news:0A39849F-D463-48AD-B8F0-(E-Mail Removed)...
> > Hey All,
> > What we are trying to achieve is, when Selected value changed event is
> > fired
> > for a combo box, then we are trying to close the current form and display
> > the
> > new form. The forms are mdi child of a MDI form named as MasterForm.
> >
> > The code being used to close the current form and open the new form is as
> > follows:
> >
> > lForm = new TestForm
> > lForm.MdiParent = Me.MdiParent
> > lForm.Show()
> > Me.Close()
> >
> > Problem is on Selected value changed event, we get an unhandled exception,
> > Object reference not set to an instance of Object. I debugged and found
> > that
> > while closing the current form, its throwing the error.
> >
> > Can anyone please suggest this behaviour, is it a known issue.
> >
> > Thanks,
> >
> > Vinay Kant
> >

>
>
>

 
Reply With Quote
 
S.M. Altaf [MVP]
Guest
Posts: n/a
 
      7th Nov 2005
I tried this out myself. Let me post all the code I used and you can
compare.

MDI Declarations, outside any sub:
Public f1 As Form1

Public f2 As Form2


MDI Load event:

f1 = New Form1

f1.MdiParent = Me

f1.Show()

In a button click event in form1,

CType(Me.MdiParent, MAINMDI).f2 = New Form2

CType(Me.MdiParent, MAINMDI).f2.MdiParent = Me.MdiParent

CType(Me.MdiParent, MAINMDI).f2.Show()

Me.Close()


Compare well?
HTH
Altaf

--------------------------------------------------------------------------------
All that glitters has a high refractive index.
www.mendhak.com

"Vinay Kant" <(E-Mail Removed)> wrote in message
news:7A653D44-F7A1-47D6-AEFF-(E-Mail Removed)...
> Altaf,
> I used a Dim to declare that, i have event tried declaring it as public,
> still the same problem. Code just breaks and takes me to the MDI Parent
> class
> while debugging.
> Problem persists. Any other suggestions.
>
> Thanks,
> Vinay kant
>
> "S.M. Altaf [MVP]" wrote:
>
>> I don't know how you've declared lForm, but you should declare it as
>> public
>> in your MDI form, then
>>
>> CType(Me.MdiParent, MAINMDI).lForm = New TestForm
>>
>> CType(Me.MdiParent, MAINMDI).lForm.Show()
>>
>> Me.Close()
>>
>>
>>
>>
>>
>> --------------------------------------------------------------------------------
>> All that glitters has a high refractive index.
>> www.mendhak.com
>>
>>
>> "Vinay Kant" <(E-Mail Removed)> wrote in message
>> news:0A39849F-D463-48AD-B8F0-(E-Mail Removed)...
>> > Hey All,
>> > What we are trying to achieve is, when Selected value changed event is
>> > fired
>> > for a combo box, then we are trying to close the current form and
>> > display
>> > the
>> > new form. The forms are mdi child of a MDI form named as MasterForm.
>> >
>> > The code being used to close the current form and open the new form is
>> > as
>> > follows:
>> >
>> > lForm = new TestForm
>> > lForm.MdiParent = Me.MdiParent
>> > lForm.Show()
>> > Me.Close()
>> >
>> > Problem is on Selected value changed event, we get an unhandled
>> > exception,
>> > Object reference not set to an instance of Object. I debugged and found
>> > that
>> > while closing the current form, its throwing the error.
>> >
>> > Can anyone please suggest this behaviour, is it a known issue.
>> >
>> > Thanks,
>> >
>> > Vinay Kant
>> >

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?VmluYXkgS2FudA==?=
Guest
Posts: n/a
 
      7th Nov 2005
Altaf,

It works fine with the Button click event, but doing the same on TextChanged
event of a combo box throws the error.
Can you please try that as well?

Thanks for your support,
Vinay Kant

"S.M. Altaf [MVP]" wrote:

> I tried this out myself. Let me post all the code I used and you can
> compare.
>
> MDI Declarations, outside any sub:
> Public f1 As Form1
>
> Public f2 As Form2
>
>
> MDI Load event:
>
> f1 = New Form1
>
> f1.MdiParent = Me
>
> f1.Show()
>
> In a button click event in form1,
>
> CType(Me.MdiParent, MAINMDI).f2 = New Form2
>
> CType(Me.MdiParent, MAINMDI).f2.MdiParent = Me.MdiParent
>
> CType(Me.MdiParent, MAINMDI).f2.Show()
>
> Me.Close()
>
>
> Compare well?
> HTH
> Altaf
>
> --------------------------------------------------------------------------------
> All that glitters has a high refractive index.
> www.mendhak.com
>
> "Vinay Kant" <(E-Mail Removed)> wrote in message
> news:7A653D44-F7A1-47D6-AEFF-(E-Mail Removed)...
> > Altaf,
> > I used a Dim to declare that, i have event tried declaring it as public,
> > still the same problem. Code just breaks and takes me to the MDI Parent
> > class
> > while debugging.
> > Problem persists. Any other suggestions.
> >
> > Thanks,
> > Vinay kant
> >
> > "S.M. Altaf [MVP]" wrote:
> >
> >> I don't know how you've declared lForm, but you should declare it as
> >> public
> >> in your MDI form, then
> >>
> >> CType(Me.MdiParent, MAINMDI).lForm = New TestForm
> >>
> >> CType(Me.MdiParent, MAINMDI).lForm.Show()
> >>
> >> Me.Close()
> >>
> >>
> >>
> >>
> >>
> >> --------------------------------------------------------------------------------
> >> All that glitters has a high refractive index.
> >> www.mendhak.com
> >>
> >>
> >> "Vinay Kant" <(E-Mail Removed)> wrote in message
> >> news:0A39849F-D463-48AD-B8F0-(E-Mail Removed)...
> >> > Hey All,
> >> > What we are trying to achieve is, when Selected value changed event is
> >> > fired
> >> > for a combo box, then we are trying to close the current form and
> >> > display
> >> > the
> >> > new form. The forms are mdi child of a MDI form named as MasterForm.
> >> >
> >> > The code being used to close the current form and open the new form is
> >> > as
> >> > follows:
> >> >
> >> > lForm = new TestForm
> >> > lForm.MdiParent = Me.MdiParent
> >> > lForm.Show()
> >> > Me.Close()
> >> >
> >> > Problem is on Selected value changed event, we get an unhandled
> >> > exception,
> >> > Object reference not set to an instance of Object. I debugged and found
> >> > that
> >> > while closing the current form, its throwing the error.
> >> >
> >> > Can anyone please suggest this behaviour, is it a known issue.
> >> >
> >> > Thanks,
> >> >
> >> > Vinay Kant
> >> >
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get combo box selected index changed event in another page from the existing page in winforms Naresh Microsoft C# .NET 5 8th Jan 2010 06:25 PM
3 combobox datasource ,selected indexed changed, event confusing, =?Utf-8?B?cnQ=?= Microsoft Dot NET Compact Framework 0 13th Feb 2006 09:09 AM
Combo.SelectedIndex Changed Event? James Goodman Microsoft Dot NET Compact Framework 2 10th Jun 2005 04:15 PM
RadioButton (or Checkbox) event firing if selected (not changed) tshad Microsoft ASP .NET 5 15th Mar 2005 09:36 AM
Is there a Post Load event? Trying to set selected indeces on bound combo boxes. Glorfindel Microsoft Dot NET Framework Forms 1 22nd Aug 2003 10:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:49 PM.