recompiling VS NET WinForms app with VS NET 2003 causing serious problems.

  • Thread starter Thread starter BBFrost
  • Start date Start date
B

BBFrost

We just recently moved one of our major c# apps from VS Net 2002 to VS Net
2003. At first things were looking ok, now problems are starting to
appear.

So far ...

(1) ComboBox.SelectedValue = db_value;

If the db_value was not included in the ComboBox value list the
ComboBox.SelectedIndex used to return -1, Now the very same code is
returning 0, we are checking for -1. We use this trait quite a bit and I
want to know what's going on before weeding it out of 100,000 lines of C#
across 24 separate user controls.

(2) command button 'Access Keys' or Alt-character ...

specified by inserting & into the button text value have begun acting
abnormal. We have a main form that contains 24 user controls each with an
'&Add', '&Update' and '&Delete' button. When compiled in VS Net 2002 all
of these keys worked fine. After compiling with VS Net 2003 the ALT-A,
ALT-U & ALT-D buttons work on about half of the controls and refuse to work
on the rest. No clear indication as to why. The data entry staff is
standing outside my cube with Pitch Forks and Axes !!!

What's going on here ???? (Besides not looking carefully enough before we
leaped.)


Is there a FAQ or message thread for problems with VS Net 2002 to VS Net
2003 conversions somewhere?


Near death experiences like this are extremely unplesant.

Thanks in advance.

Barry
Oregon
 
More information.

It turns out pressing command button 'Access Keys' or Alt-character on one
control seems to be randomly triggering the corresponding command button on
another user control contained by the form. i.e. ALT-U on UserControl1 is
triggering the &Update command button on UserControl12.

How does one prevent this type of UserControl 'cross over' when numerous
user controls are contained by the same form?

Thanks in advance.

Barry
Oregon

P.S. I've changed the combobox code (see below) in a couple of instances
from

ComboBox.SelectedValue = dbValueString;
(if ComboBox.SelectedIndex == -1) TO (if ComboBox.SelectedIndex < 1)

in an attempt to determine if dbValueString matches a value in the ComboBox
display List. This change seems to be working for the time being.
 
Hi Barry,

Based on my test, when you assign a "value" to ComboBox.SelectedValue, if
this value is in the list of the combobox, SelectedIndex is set to its
index. Otherwise, the SelectedIndex property keeps unchanged. As for the
'Access Keys', do you have duplicate Access Keys defined in the
application?

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
 
Felix,

Thanks for the quick response ... our attempt to move to VS Net 2003 is
definitely stopped until we can correct these problems.

1st - Please understand that this data entry application has been WORKING
PROBLEM FREE FOR OVER A YEAR when compiled with VS Net 2002. These problems
appeared only when we used VS Net 2003 to recompile the application. This
is a very large and complex data entry application supporting the State of
Oregon's Water Right Tracking system.

The application has a Main Form that contains 24 user controls. EACH USER
CONTROL HAS an
'&Add', '&Update' and '&Delete' button. So the answer to your question is
'yes', the Main Form contains 24 '&Update' buttons, with each User Control
containing a single '&Update' button. However, previously in Net 2002
Access Keys behaved as if each User Control was an application unto itself.
Net 2003 seems to have somehow broken that functionality.

Until we recompiled the app using VS Net 2003, pressing ALT-U within any
control activated the control's '&Update' button. Now we have found that
pressing ALT-U in some controls activates the '&Update' button in a
completely different control. This is a REALLY BAD THING. To add to the
confusion, the Access Keys work correctly and consistently in some controls
and consistently fail (while activating the access key in other completely
unrelated user controls).

We have have reverted to the Net 2002 Version of the app which works
correctly. i.e. Pressing ALT-U within in a control activates that
control's '&Update' button. The combobox issue also works correctly with
the Net 2002 version.

Barry
Oregon
 
Felix,

This situation is so critical that I've started a case with MS Tech support.
I've got a partial solution so far the problem has not been completely
resolved. I'll post to this string with the resolution when the problem is
resolved. Thanks.

Barry
Oregon
 
Thanks for the information. I will take a further look into this issue and
update you if I find anything useful.

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
Reply-To: "BBFrost" <[email protected]>
From: "BBFrost" <barry.b.frost@remove_this.wrd.state.or.us>
References: <#[email protected]>
 
Hi Barry,

I repro-ed the accesss key issue you mentioned. To resolve this problem,
you can override ProcessDialogChar in all your UserControls:

public class UserControl1 : System.Windows.Forms.UserControl
{
...
protected override bool ProcessDialogChar(char charCode)
{
if (charCode != ' ' && ProcessMnemonic(charCode)) return true;
return base.ProcessDialogChar(charCode);
}
...
}


However, I am not able to repro SelectedIndex issue. It shows the same
behavior in both .NET Framework 1.0 and 1.1.

Actually, when you set a value to the SelectedValue property, combobox
searches its list and returns the index if the value is found, otherwise,
returns -1. This return value is set to the SelectedIndex property of the
control. Then, combobox needs to update the CurrencyManager.Position
property of the underlying datasource based on the SelectedIndex. However,
the Position will be adjusted to 0 if the SelectedIndex is less than 0.
After this, CurrencyManager updates the underlying datasource if it finds
that the current Position value (is adjusted "0" is this case) is different
from the previous Position value. During this process, CurrencyManager
will udpate the SelectedIndex to the current CurrencyManager.Position
value, that is, 0.

In a nutshell, if the current SelectedIndex is "0", SelectedIndex will
return -1 when you set an invaid value (the value that is not included in
the ComboBox value list ) to the SelectedValue property. If the current
SelectedIndex is not "0", it will return 0.

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
Reply-To: "BBFrost" <[email protected]>
From: "BBFrost" <barry.b.frost@remove_this.wrd.state.or.us>
References: <#[email protected]>
 
Felix,

THANKS for the info! Its very much appreciated. I've think we've corrected
the Combobox anomolie by checking for < 1 rather than == -1.

I'm working on integrating the ProcessDialogChar override.

I'll post back to the group with the results.

Again many THANKS !!

Barry
Oregon
 
Felix,

1st: The override of ProcessDialogChar( ) method is working great. It
forces our User Controls to handle the ALT- keys 'locally' just as we
needed. Yahooo.

2nd: Thanks for the 'heads up' on the combobox. Its very much appreciated.
We've avoided this particular issue because most of our comboboxes are
loaded from lookup tables that include a blank (null) display value that we
place at SelectedIndex 0. :-) So the method we're now using resets the
Combobox index to 0, then loads the db value into the
ComboBox.SelectedValue. The database values will never be blank or null in
these cases so if the Selected Index is < 1 we know that there was no match.
Seems to be working so far. :-)

Thank you very much for your help with this issue.

Best wishes & Happy Computing!

Barry
Oregon

Felix Wu said:
Welcome, Barry.

However, I am afraid that simply checking SelectedIndex < 1 is not enough.
Since SelectedIndex zero-based, what if the dbValueString happens to be the
same as the first value in the list?

One workaround is to check if the new value equals the first value in the
list when SelectedIndex is 0. For example:

DataRowView drv=(DataRowView)comboBox1.Items[0];

...
comboBox1.SelectedValue=newVal;

if (comboBox1.SelectedIndex==-1 || (comboBox1.SelectedIndex==0 &&
(drv["colName"].ToString()!=newVal.ToString())))
MessageBox.Show("It's Invalid: " + newVal.ToString());
else
MessageBox.Show("It's Valid: " + newVal.ToString());

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.<[email protected]>
<[email protected]>
Subject: Re: recompiling VS NET WinForms app with VS NET 2003 causing serious problems.
Date: Mon, 9 Feb 2004 08:06:17 -0800
Lines: 267
X-Newsreader: Microsoft Outlook Express 5.50.4922.1500
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4925.2800
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: 159.121.113.234
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:219291
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Felix,

THANKS for the info! Its very much appreciated. I've think we've corrected
the Combobox anomolie by checking for < 1 rather than == -1.

I'm working on integrating the ProcessDialogChar override.

I'll post back to the group with the results.

Again many THANKS !!

Barry
Oregon



cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP0
8 problem
is within
any to
the to
VS starting
to lines
of refuse
to
 
That's great! Enjoy it :-)

Bet Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
Reply-To: "BBFrost" <[email protected]>
From: "BBFrost" <barry.b.frost@remove_this.wrd.state.or.us>
References: <#[email protected]>
<[email protected]>
<[email protected]>
<#[email protected]>
<[email protected]>
Subject: Re: recompiling VS NET WinForms app with VS NET 2003 causing serious problems.
Date: Tue, 10 Feb 2004 09:07:48 -0800
Lines: 381
X-Newsreader: Microsoft Outlook Express 5.50.4922.1500
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4925.2800
Message-ID: <#[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: 159.121.113.234
Path: cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.
phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:219602
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Felix,

1st: The override of ProcessDialogChar( ) method is working great. It
forces our User Controls to handle the ALT- keys 'locally' just as we
needed. Yahooo.

2nd: Thanks for the 'heads up' on the combobox. Its very much appreciated.
We've avoided this particular issue because most of our comboboxes are
loaded from lookup tables that include a blank (null) display value that we
place at SelectedIndex 0. :-) So the method we're now using resets the
Combobox index to 0, then loads the db value into the
ComboBox.SelectedValue. The database values will never be blank or null in
these cases so if the Selected Index is < 1 we know that there was no match.
Seems to be working so far. :-)

Thank you very much for your help with this issue.

Best wishes & Happy Computing!

Barry
Oregon

Felix Wu said:
Welcome, Barry.

However, I am afraid that simply checking SelectedIndex < 1 is not enough.
Since SelectedIndex zero-based, what if the dbValueString happens to be the
same as the first value in the list?

One workaround is to check if the new value equals the first value in the
list when SelectedIndex is 0. For example:

DataRowView drv=(DataRowView)comboBox1.Items[0];

...
comboBox1.SelectedValue=newVal;

if (comboBox1.SelectedIndex==-1 || (comboBox1.SelectedIndex==0 &&
(drv["colName"].ToString()!=newVal.ToString())))
MessageBox.Show("It's Invalid: " + newVal.ToString());
else
MessageBox.Show("It's Valid: " + newVal.ToString());

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.<[email protected]>
<[email protected]>
Subject: Re: recompiling VS NET WinForms app with VS NET 2003 causing serious problems.
Date: Mon, 9 Feb 2004 08:06:17 -0800
Lines: 267
X-Newsreader: Microsoft Outlook Express 5.50.4922.1500
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4925.2800
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: 159.121.113.234
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP0 8
phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:219291
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Felix,

THANKS for the info! Its very much appreciated. I've think we've corrected
the Combobox anomolie by checking for < 1 rather than == -1.

I'm working on integrating the ProcessDialogChar override.

I'll post back to the group with the results.

Again many THANKS !!

Barry
Oregon


Hi Barry,

I repro-ed the accesss key issue you mentioned. To resolve this problem,
you can override ProcessDialogChar in all your UserControls:

public class UserControl1 : System.Windows.Forms.UserControl
{
...
protected override bool ProcessDialogChar(char charCode)
{
if (charCode != ' ' && ProcessMnemonic(charCode)) return true;
return base.ProcessDialogChar(charCode);
}
...
}


However, I am not able to repro SelectedIndex issue. It shows the same
behavior in both .NET Framework 1.0 and 1.1.

Actually, when you set a value to the SelectedValue property, combobox
searches its list and returns the index if the value is found, otherwise,
returns -1. This return value is set to the SelectedIndex property of the
control. Then, combobox needs to update the CurrencyManager.Position
property of the underlying datasource based on the SelectedIndex. However,
the Position will be adjusted to 0 if the SelectedIndex is less than 0.
After this, CurrencyManager updates the underlying datasource if it finds
that the current Position value (is adjusted "0" is this case) is
different
from the previous Position value. During this process, CurrencyManager
will udpate the SelectedIndex to the current CurrencyManager.Position
value, that is, 0.

In a nutshell, if the current SelectedIndex is "0", SelectedIndex will
return -1 when you set an invaid value (the value that is not included in
the ComboBox value list ) to the SelectedValue property. If the current
SelectedIndex is not "0", it will return 0.

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
Reply-To: "BBFrost" <[email protected]>
From: "BBFrost" <barry.b.frost@remove_this.wrd.state.or.us>
References: <#[email protected]>
<[email protected]>
<[email protected]>
Subject: Re: recompiling VS NET WinForms app with VS NET 2003 causing
serious problems.
Date: Thu, 5 Feb 2004 16:59:57 -0800
Lines: 153
X-Newsreader: Microsoft Outlook Express 5.50.4922.1500
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4925.2800
Message-ID: <#[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: 159.121.113.234
Path:

cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP 0
8
phx.gbl!TK2MSFTNGP09.phx.gbl
Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.languages.csharp:218632
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Felix,

This situation is so critical that I've started a case with MS Tech
support.
I've got a partial solution so far the problem has not been completely
resolved. I'll post to this string with the resolution when the problem
is
resolved. Thanks.

Barry
Oregon


Felix,

Thanks for the quick response ... our attempt to move to VS Net
2003
is
definitely stopped until we can correct these problems.

1st - Please understand that this data entry application has been
WORKING
PROBLEM FREE FOR OVER A YEAR when compiled with VS Net 2002. These
problems
appeared only when we used VS Net 2003 to recompile the application.
This
is a very large and complex data entry application supporting the State
of
Oregon's Water Right Tracking system.

The application has a Main Form that contains 24 user controls. EACH
USER
CONTROL HAS an
'&Add', '&Update' and '&Delete' button. So the answer to your
question
is
'yes', the Main Form contains 24 '&Update' buttons, with each User
Control
containing a single '&Update' button. However, previously in Net 2002
Access Keys behaved as if each User Control was an application unto
itself.
Net 2003 seems to have somehow broken that functionality.

Until we recompiled the app using VS Net 2003, pressing ALT-U within
any
control activated the control's '&Update' button. Now we have found
that
pressing ALT-U in some controls activates the '&Update' button in a
completely different control. This is a REALLY BAD THING. To add to
the
confusion, the Access Keys work correctly and consistently in some
controls
and consistently fail (while activating the access key in other
completely
unrelated user controls).

We have have reverted to the Net 2002 Version of the app which works
correctly. i.e. Pressing ALT-U within in a control activates that
control's '&Update' button. The combobox issue also works correctly
with
the Net 2002 version.

Barry
Oregon


Hi Barry,

Based on my test, when you assign a "value" to
ComboBox.SelectedValue,
if
this value is in the list of the combobox, SelectedIndex is set to
its
index. Otherwise, the SelectedIndex property keeps unchanged. As for
the
'Access Keys', do you have duplicate Access Keys defined in the
application?

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
Reply-To: "BBFrost" <[email protected]>
From: "BBFrost" <barry.b.frost@remove_this.wrd.state.or.us>
Subject: recompiling VS NET WinForms app with VS NET 2003 causing
serious
problems.
Date: Wed, 4 Feb 2004 11:30:58 -0800
Lines: 40
X-Newsreader: Microsoft Outlook Express 5.50.4922.1500
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4925.2800
Message-ID: <#[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: 159.121.113.234
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA07.phx.gbl!TK2MSFTNG
X
A
6.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.languages.csharp:218215
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

We just recently moved one of our major c# apps from VS Net 2002 to
VS
Net
2003. At first things were looking ok, now problems are starting
to
appear.

So far ...

(1) ComboBox.SelectedValue = db_value;

If the db_value was not included in the ComboBox value list the
ComboBox.SelectedIndex used to return -1, Now the very same code is
returning 0, we are checking for -1. We use this trait quite a bit
and
I
want to know what's going on before weeding it out of 100,000 lines
of
C#
across 24 separate user controls.

(2) command button 'Access Keys' or Alt-character ...

specified by inserting & into the button text value have begun
acting
abnormal. We have a main form that contains 24 user controls each
with
an
'&Add', '&Update' and '&Delete' button. When compiled in VS Net
2002
all
of these keys worked fine. After compiling with VS Net 2003 the
ALT-A,
ALT-U & ALT-D buttons work on about half of the controls and refuse
to
work
on the rest. No clear indication as to why. The data entry
staff
is
standing outside my cube with Pitch Forks and Axes !!!

What's going on here ???? (Besides not looking carefully enough
before
we
leaped.)


Is there a FAQ or message thread for problems with VS Net 2002
to
VS
Net
2003 conversions somewhere?


Near death experiences like this are extremely unplesant.

Thanks in advance.

Barry
Oregon
 
Back
Top