473,473 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ListBox Actions

26 New Member
I have a List box that pops up when a tool button is pressed. I want to detect if the user clicks outside of the List box and make it go away (enable = visable = false.)

Any Ideas?
Apr 2 '09 #1
3 2422
cloud255
427 Recognized Expert Contributor
Hi

Look at custom event handlers and the LostFocus event of your list box.
Using these two elements you can create a custom event for the listbox.LostFocus event in which you can achieve the desired results.
Apr 3 '09 #2
chris52672
26 New Member
Ok,

Thanks for the reply.

I am pretty much a novice. Could you explain more or give an example? Or could you point me to an example as I am very much visuale?
Apr 3 '09 #3
cloud255
427 Recognized Expert Contributor
You should read up on the Focus aspect of controls (the MSDN is a good place for this information). But in a nutshell this allows you to determine which control has focus, which control is getting focus and which control has lost focus.

The idea behind custom event handlers is that you add or remove some code to the standard event handler of that action.

Consider:

Expand|Select|Wrap|Line Numbers
  1. int x = 10;
  2. x += 5; //x now has a value of 15
Using similar logic you can now add some custom code which will be executed when the event is fired. This MSDN page explains the syntax and logic behind event handlers, have a read and feel free to post any questions if some parts are unclear.

The MSDN speaks of custom event arguments, for the problem which you have, you don't need custom arguments the standard EventArgs will work fine.

So once you have a subscription you simply put the code you want executed into the procedure you have created for the event. That's all there is to it (I know it sounds like a lot now, but it really isn't too bad - just play around with it a little)

The code you will execute will most probably just set a property of your list box, maybe something like:

Expand|Select|Wrap|Line Numbers
  1. Listbox1.visible = false;
Again feel free to post if you are stuck.

Good Luck
Apr 4 '09 #4

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

Similar topics

1
by: Chris | last post by:
Hi, I have an application written in ASP and I am converting to ASP.NET in the old ASP page users can add items to a listbox control. When the user hits the "submit" command button on the...
17
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP)...
2
by: Sami | last post by:
I am creating a student database. We would like to be able to look up students by ID number. New students will be input to the tables / records daily, but looking up student by ID number will be...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
4
by: schaf | last post by:
Hi NG ! I have an application which writes information for the user in a ListBox. This works very good on my computer and also on other computers. But there are some computers on which the text...
0
by: sasankasekhar2003 | last post by:
i have a textbox txtName (web form element) 2 listboxes lstAll (web form element) (autopostback=false, select=multiple) lstSel (web form element)(autopostback=false,...
18
by: Zytan | last post by:
I want the same function to be run whether you press Enter or double click the listbox. It seems really verbose to write both handlers to both events everytime, even if they both call the same...
2
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have tried to use a ListBox with SelectionMode set to MultiSimple. I have also tried quite a lot of the event handlers, but no events seem to be triggered. Why aren't the events triggered?
4
by: Dave | last post by:
I recently found out that the RequiredFieldValidator works differently for a ListBox than I needed; it checks to see if a row is selected, rather than checking to see if the listbox is empty. I...
6
by: AB | last post by:
Hi, I have a listbox and a webbrowser control. For each single item selected I am generating a different web page. However for more than one selection, a common web page gets generated. I...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.