I'm having a weird toolbar problem.
The issue is that I've got this toolbar which call "this.Close()" on my
Form, by some obscure reasons I need to press the toolbar TWICE before
the form actually CLOSES...

I have stepped through the code and verified that the code is actually
CALLED but still the Form isn't being closed...
The form is being showed with ShowDialog() and it doesn't contain alot
of fancy stuff.
I've got one custom DataGrid control in it, but that DataGrid works
perfect in other forms.
I'm using the OpenNETCF/SDF in my app and I've optimized the
InitializeControls with the "rules" to make it faster. (setting Parent
property instead of adding the controls, loading controls top-down
style etc...)
Form is localized for two languages but I've handremoved everything in
both resx files and InitializeControls which don't have anything thing
to do with "text" properties (optimization)

It seems to me as if the "Close" method on the form is somehow
"broken"...??

Appreciate any suggestions...

I can submit code, but it's gonna be LONG... (650 lines...)

Also I've got lots of forms in my app, many which are way more
"advanced" then this one, many ofo the also "optimized" but they all
seem to function perfect except this one though...


Regards

Thomas Hansen

Re: Weird toolbar problem... by Alex

Alex
Tue Apr 26 11:18:29 CDT 2005

Do you do anything in Form.Closing by some chance?

--
Alex Feinman
---
Visit http://www.opennetcf.org
"Thomas Hansen" <polterguy@gmail.com> wrote in message
news:1114517211.668954.7980@f14g2000cwb.googlegroups.com...
> I'm having a weird toolbar problem.
> The issue is that I've got this toolbar which call "this.Close()" on my
> Form, by some obscure reasons I need to press the toolbar TWICE before
> the form actually CLOSES...
>
> I have stepped through the code and verified that the code is actually
> CALLED but still the Form isn't being closed...
> The form is being showed with ShowDialog() and it doesn't contain alot
> of fancy stuff.
> I've got one custom DataGrid control in it, but that DataGrid works
> perfect in other forms.
> I'm using the OpenNETCF/SDF in my app and I've optimized the
> InitializeControls with the "rules" to make it faster. (setting Parent
> property instead of adding the controls, loading controls top-down
> style etc...)
> Form is localized for two languages but I've handremoved everything in
> both resx files and InitializeControls which don't have anything thing
> to do with "text" properties (optimization)
>
> It seems to me as if the "Close" method on the form is somehow
> "broken"...??
>
> Appreciate any suggestions...
>
> I can submit code, but it's gonna be LONG... (650 lines...)
>
> Also I've got lots of forms in my app, many which are way more
> "advanced" then this one, many ofo the also "optimized" but they all
> seem to function perfect except this one though...
>
>
> Regards
>
> Thomas Hansen
>


Re: Weird toolbar problem... by Thomas

Thomas
Wed Apr 27 03:25:06 CDT 2005


Alex Feinman [MVP] wrote:
> Do you do anything in Form.Closing by some chance?

Hi Alex.
Nope!
Nothing in the OnClose event!
I don't trap it at all!
The only events I handle in the form is Context Sensitive Menu click
events, CurrentCellChanged event of datagrid, menu click events,
toolbar button click events and Load event of form...
I am using my own custom DataGrid where I change the size of the cells
(I think I got it from your blog) and makes it "thumb scrollable"
(scroll by "dragging" the grid like Acrobat Reader can do with the
hand)
But that DataGrid is being used in other forms without these
problems...

I've also "optimized" the form loading (also from help of your blog I
think) by adding the controls top-down and setting the controls Parent
instead of adding them up into the Controls collection.

Then the form is also localized (two languages) the standard way with
using resx files.
But I've removed all "unnessecary" data from the resx files... (and
also handcoded the removed values into the InitializeComponents)

So I'm really out in the blue here, I've tried to "rearrange" the stuff
inside the InitializeComponent function without success though since
the problem came when I optimized the code there...

Thomas Hansen


Re: Weird toolbar problem... by John

John
Thu Apr 28 09:36:32 CDT 2005

Thomas Hansen wrote:
>
> The issue is that I've got this toolbar which call "this.Close()" on
> my Form, by some obscure reasons I need to press the toolbar TWICE
> before the form actually CLOSES...
>
> I have stepped through the code and verified that the code is actually
> CALLED but still the Form isn't being closed...

Is there any code in the ToolBar event handler after the call to
this.Close()? The only thing that should be behind this call is a Return...

--
John T
____________________




Re: Weird toolbar problem... by Thomas

Thomas
Thu Apr 28 16:09:20 CDT 2005


John T wrote:
> Thomas Hansen wrote:
> >
> > The issue is that I've got this toolbar which call "this.Close()"
on
> > my Form, by some obscure reasons I need to press the toolbar TWICE
> > before the form actually CLOSES...
> >
> > I have stepped through the code and verified that the code is
actually
> > CALLED but still the Form isn't being closed...
>
> Is there any code in the ToolBar event handler after the call to
> this.Close()? The only thing that should be behind this call is a
Return...

Hi John, thanks for taking time to diggest my problem, but no, there is
no code after the close except for a break!

[code]
private void itsToolbar_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch( e.Button.ImageIndex )
{
case 0: Close(); break;
}
}
[/code]

But I'm beginning to become rather superstitous about this problem,
maybe I should try to exchange the "break" with a "return"...?

.t


Re: Weird toolbar problem... by John

John
Fri Apr 29 09:14:09 CDT 2005

Thomas Hansen wrote:
>
> But I'm beginning to become rather superstitous about this problem,
> maybe I should try to exchange the "break" with a "return"...?

I typically use a series of IF blocks to check for desired buttons and
return, if necessary. I haven't tried using switch blocks for this purpose
so I don't know if that is having an effect.

I do know that not leaving the method immediately after calling Close() will
keep the window open (assuming the code is in the window's class).

--
John T
____________________




Re: Weird toolbar problem... by Thomas

Thomas
Sat Apr 30 09:58:21 CDT 2005


John T wrote:
> Thomas Hansen wrote:
> >
> > But I'm beginning to become rather superstitous about this problem,
> > maybe I should try to exchange the "break" with a "return"...?
>
> I typically use a series of IF blocks to check for desired buttons
and
> return, if necessary. I haven't tried using switch blocks for this
purpose
> so I don't know if that is having an effect.
>
> I do know that not leaving the method immediately after calling
Close() will
> keep the window open (assuming the code is in the window's class).

hmm...
Maybe I SHOULD try to do a return instead...

.t