Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello Programmers

 

I've build a pretty nice program.

Everything works rigth but 1 panel is loaded 2 times, that looks stupid.

Everything gets build up. and its broken and loaded again. Then its good.

 

How can i handel that?

My code:

 

        private void listBar1_ItemClicked(object sender, vbAccelerator.Components.ListBarControl.ItemClickedEventArgs e)
       {
           if (e.MouseButton == MouseButtons.Left)
           {
               panel3.Controls.Clear();
               if (e.Item.IconIndex == 0)
               {                    
                   NieuwFactuur myCtrl = new NieuwFactuur();
                   panel3.Controls.Add(myCtrl);
               }
           }
       }

Posted
I really have no idea what your looking for here? Using an objects .SuspendLayout and .ResumeLayout you can prevent flickering of controls. You call .SuspendLayout before removing/adding anything, then .ResumeLayout when everthing is added/removed. Does this help?
Anybody looking for a graduate programmer (Midlands, England)?
Posted

Sorry for my late post...

 

I tried it .. but it doesn't help.

The code is placed on the click tap of the listbar.

 

That code is loaded 2 times:

 

        private void listBar1_ItemClicked(object sender, vbAccelerator.Components.ListBarControl.ItemClickedEventArgs e)
       {
           if (e.MouseButton == MouseButtons.Left)
           {
               panel3.Controls.Clear();
               if (e.Item.IconIndex == 0)
               {                    
                   NieuwFactuur myCtrl = new NieuwFactuur();
                   myCtrl.SuspendLayout();
                   MessageBox.Show("1");
                   panel3.Controls.Add(myCtrl);
                   myCtrl.ResumeLayout();
               }
               else if (e.Item.IconIndex == 1) 
               {
                   ZoekFactuur myCtrl = new ZoekFactuur();
                   MessageBox.Show("2");
                   panel3.Controls.Add(myCtrl);
               }
           }
       }

 

If the e.item.iconindex ==0 then i get 2 times on the screen: "1".

Thats the error.

 

This piece:

 

                    NieuwFactuur myCtrl = new NieuwFactuur();
                   myCtrl.SuspendLayout();
                   MessageBox.Show("1");
                   panel3.Controls.Add(myCtrl);
                   myCtrl.ResumeLayout();

 

Needs to be loaded 1 time!

The susprendlayout doesnt help much in this case ;)

Posted

Not possible.. is only activated by the click of the mouse...

I build it so:

 

        private void listBar1_ItemClicked(object sender, vbAccelerator.Components.ListBarControl.ItemClickedEventArgs e)
       {
           if (kliktel == 0)
           {
               if (e.MouseButton == MouseButtons.Left)
               {
                   panel3.Controls.Clear();
                   if (e.Item.IconIndex == 0)
                   {
                       NieuwFactuur myCtrl = new NieuwFactuur();
                       myCtrl.SuspendLayout();
                       panel3.Controls.Add(myCtrl);
                       myCtrl.ResumeLayout();
                   }
                   else if (e.Item.IconIndex == 1)
                   {
                       ZoekFactuur myCtrl = new ZoekFactuur();
                       panel3.Controls.Add(myCtrl);
                   }
                   kliktel = kliktel + 1;
               }
           }
       }

 

The kliktel is a variable.

On the first its 0, after 1 run it gets 1.

 

But how can i get it back to 0 again???

 

Its working, but only 1 time .. so you can't press another button

  • Leaders
Posted

Now that I've looked at the code more closely, it definitely seems like the event handler is attatched twice. That you need a variable to count the number of times the handler is called and only run the code the first time shows that the code is being run twice per click (which means the handler must be attatched twice).

 

How do you attatch the event to the handler? Through the designer? In code? Or both?

[sIGPIC]e[/sIGPIC]
Posted (edited)

here is a package with some components, i 'borrowed' from.

So this is not my official project.

 

the click event is on one of the objects on the left side.

I don't see it...

listbar.zip

Edited by PlausiblyDamp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...