473,799 Members | 3,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Buttons visibility

15 New Member
I have app in which I would like to use buttons as an Drop Down menu.

Expand|Select|Wrap|Line Numbers
  1. private void button16_Click(object sender, EventArgs e)
  2.         {
  3.                 button1.Visible = true;
  4.                 button2.Visible = true;
  5.                 button3.Visible = true;
  6.                 button4.Visible = true;
  7.                 button5.Visible = true;
  8.                 button6.Visible = true;
  9.                 button7.Visible = true;
  10.                 button8.Visible = true;
  11.                 button9.Visible = true;
  12.                 button10.Visible = true;
  13.                 button11.Visible = true;
  14.                 button12.Visible = true;
  15.                 button13.Visible = true;
  16.                 button14.Visible = true;
  17.                 button15.Visible = true;
  18.         }
  19.  
  20.         private void button17_Click(object sender, EventArgs e)
  21.         {
  22.             button1.Visible = false;
  23.             button2.Visible = false;
  24.             button3.Visible = false;
  25.             button4.Visible = false;
  26.             button5.Visible = false;
  27.             button6.Visible = false;
  28.             button7.Visible = false;
  29.             button8.Visible = false;
  30.             button9.Visible = false;
  31.             button10.Visible = false;
  32.             button11.Visible = false;
  33.             button12.Visible = false;
  34.             button13.Visible = false;
  35.             button14.Visible = false;
  36.             button15.Visible = false;
  37.         }
All is working but turning buttons invisible again is really slow, turning them visible is completed in milliseconds while turning them invisible takes about 2-3 seconds.

How can I speed that up?
Apr 27 '12 #1
9 6568
RhysW
70 New Member
put it in a groupbox and instead of hiding and showing the buttons individually, hide the groupbox, will only require one process and therefore should be quicker, in theory

edit: though on second thoughts its the drawing it to the UI thats eating up the time, which would still be a problem with hiding and showing the groupbox
Apr 27 '12 #2
Djiber
15 New Member
Puting them in groupBox helped but now it's not pretty :P

I still don't understand if drawing is the problem how is it easier to draw them(make them visible) then destroy them (make them invisible)
Apr 27 '12 #3
Plater
7,872 Recognized Expert Expert
Do you have event handlers attached to the visible state changes on any of the buttons?
Apr 27 '12 #4
roshan ban
21 New Member
try the code as
this.button1.Vi sible = false;
for every button
Apr 29 '12 #5
Djiber
15 New Member
@Plater
How do you mean?

I have EventHandlers for button.Click for what would I need it for Visible state? (Like I've said it's a Menu so I just need that Buttons are shown when I click on button that's always visible and that they disappear when I click on another+it makes visible another set of buttons)
Apr 30 '12 #6
RhysW
70 New Member
If you click on the form and click one of the buttons then look in its properties window, click the lightning bolt (that takes you to that controls events) one of them will be VisibleChanged, this is code that is fired when the buttons visibility is changed from true to false or vice versa, i'm not sure how this event would help as the same code would need to be executed anyway and you would still have the same problem of it being slow to show them, but thats an explanation of the event anyhow
Apr 30 '12 #7
RhysW
70 New Member
On a massive side note i just tried to replicate the problem you have, i used 26 buttons instead of your 15, hoping that this would exaggerate your problem, and i didnt have it, it showed just as quickly as it hid. So its nothing with your code, its literally just the speed that your computer is capable of hiding and drawing at (mine is only a month or so old so has next to nothing slowing it down) so yeah the problem is not the code, so you dont need to use the groupbox if you dont want to as there really isnt a way of speeding it up short of formatting your computer!
Apr 30 '12 #8
Djiber
15 New Member
Thank you for confirmation, computer I'm working on is old, has 1GB of RAM and 2,4 GHz CPU :P
Apr 30 '12 #9
RhysW
70 New Member
hehe thought it might be that the moment i tried it because i suddenly remembered doing something similar a few projects ago
May 1 '12 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
23891
by: Owen Funkhouser | last post by:
I have a form with three radio options. And I have three buttons: <input type="submit" name="mainform_action" value="Edit Data"> <input type="submit" name="mainform_action" value="View Data"> <input type="submit" name="mainform_action" value="Delete Data"> If the first radio button is selected, I only want all three buttons to be visible to the user. If the second radio button is selected, I only want the "Edit Data" and "View Data"...
2
47692
by: dzeeq | last post by:
Hi, I wonder if it's possible to replace standard text on confirm-popup buttons from 'ok' and 'cancel' to some other captions. If not, is there a way to create quickly custom dialog, with only two buttons, returning 'true' or 'false'? Would I have to use forms to return value from my custom dialog? Thanx for any help.
1
2076
by: Paul THompson | last post by:
I am using IE to hide sections of a form. When I display the first section (name='ea'), the form widgets are not clickable in IE nor do they accept focus. When I display the 3rd section (name='ec'), the items in all sections become clickable/accept focus. Has anyone ever seen anything like this? There are no problems at all in NN/Firefox/Mozilla. Here is some of the code - there is rather a lot, so I just display some of it:
10
13463
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group related to checkboxes. Thanks!!!
0
5577
by: sam | last post by:
I have 2 radio buttons on my form which are hidden. I need to have these radio buttons visible once a checkbox is selected. The radio buttons are hidden on loading of the form but I cannot make them visible once the check box is checked. The error I get is 'document.radiology.rcontmedia.style' is null or not an object. The code I am using is below. Please note that I have no previous experience programming in javascript. function...
2
1334
by: COHENMARVIN | last post by:
I have a table with 2 buttons in it - a SAVE button and a DELETE button. If Session("BothButtons") = True, I want to show both buttons. If Session("BothButtons") = False, I want to show only the SAVE button. This would be easy to do (I just would set DeleteButton.Visible = False), but the problem is that the 2 buttons are in 2 different cells of a table, something like this: <td align="center"><ASP:Button id="Save" runat="server" /></td>...
6
3197
by: AJBopp | last post by:
I'm wrestling with CSS variations between Firefox and IE. I'm trying to create rollover buttons in a menu frame. It is working perfectly in Firefox but in IE only the first button is properly highlighted and linked. The second button, has only a partial "hit area" at the top of the image, although if you click the link, you can see the link border is properly place around the image. The rest of the buttons have no rolloever state or link...
2
3727
by: Scamjunk | last post by:
I am a total JavaScript newbie and I got a JavaScript for maintenance that collapses/expands rows whenever the (-)/(+) GIFs are clicked. Could it be changed to do the same with radio buttons? on checking of a radio button the respective row should expand, else remain collapsed. and if another radio button is chosen then the row originally expanded should collapse. Is this doable? If so, what should I be changing in this code? TIA, Scam.
3
1339
by: firebirds98 | last post by:
I have 4 buttons on the start page. The first and last button are set to visible and the two middle buttons are set to false visibility. <asp:Button ID="btnviewtracks" class="button_schedcontinue" Visible="true" runat="server" Text="View Tracks >>" /><br /> <asp:Button ID="btnRequestClass" class="button_schedcontinue" runat="server" Visible="False" Text="Update Status" AutoPostBack="True" /> <br /> ...
5
6707
by: satyabhaskar | last post by:
hi all, In my web page i have created radio buttons dynamically on to the page .....following is my code string Course, Semester, Section; int rowsCount; string con = ConfigurationManager.ConnectionStrings.ConnectionString; protected void Page_Load(object sender, EventArgs e) { try
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10252
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.