473,758 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

question on combobox



Hi All.
I have a problem with combobox, what I want is when combobox gets focus I need it to show the dropdown list
t.This is fine if the user selects the combobox via keystrokes but when the combobox is selected via mouse click it draws
the dropdown list twice. As I am trapping the enter event, I can see thats is called as well some other ?

the style is set to dropdownlist as they must select one from the list

I assume I must trap a mouse event so it doesn't draw the dropdown list because I will be in the enter event, but which one?

thanks for any input.
Code below.

P.S I did post this question to m.p.d.f.winform s but did not receive any replies.

using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;


namespace test
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows. Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeCompo nent();

//
// TODO: Add any constructor code after InitializeCompo nent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.cbp = new System.Windows. Forms.ComboBox( );
this.textBox1 = new System.Windows. Forms.TextBox() ;
this.SuspendLay out();
//
// cbp
//
this.cbp.DropDo wnStyle = System.Windows. Forms.ComboBoxS tyle.DropDownLi st;
this.cbp.Locati on = new System.Drawing. Point(208, 176);
this.cbp.Name = "cbp";
this.cbp.Size = new System.Drawing. Size(121, 21);
this.cbp.TabInd ex = 6;
//
// textBox1
//
this.textBox1.L ocation = new System.Drawing. Point(208, 136);
this.textBox1.N ame = "textBox1";
this.textBox1.T abIndex = 1;
this.textBox1.T ext = " ";
//
// Form1
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(792, 566);
this.Controls.A dd(this.textBox 1);
this.Controls.A dd(this.cbp);
this.Name = "Form1";
this.Load += new System.EventHan dler(this.Form1 _Load);
this.ResumeLayo ut(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run (new Form1());
}

private System.Windows. Forms.TextBox textBox1;
private System.Windows. Forms.ComboBox cbp;
private void Form1_Load(obje ct sender, System.EventArg s e)
{
cbp.Items.Add(" Hello");
cbp.Items.Add(" Everyone");
cbp.DropDown+=n ew EventHandler(cb p_DropDown);
cbp.Enter+=new EventHandler(cb p_Enter);

cbp.MouseUp+=ne w MouseEventHandl er(cbp_MouseUp) ;

}

private void cbp_DropDown(ob ject sender, EventArgs e)
{
if (cbp.DroppedDow n==true)
return;
}

private void cbp_Enter(objec t sender, EventArgs e)
{
cbp.DroppedDown =true;
}
private void cbp_MouseUp(obj ect sender, MouseEventArgs e)
{
cbp.DroppedDown =true;
}
}

}

Nov 25 '05 #1
0 1480

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
1948
by: Mr. B | last post by:
I've been seeking the solution to this. But can't figure it out (sounds simple enough). When you Populat a ComboBox, you can select the initial displayed items on startup simply by setting the TEXT to a valide item in the Combobox. What I want to do is to select the initial listed item to an item based upon a varrying veriable. For example, the combobox is populated with a list of Users.
6
2340
by: Georges Heinesch | last post by:
An easy ComboBox question. ;) I would like to create a ComboBox, which permits to cycle through 3 subforms. These 3 subforms are entered in the ComboBox as Value List. The subforms should only be selectable via the cycle gadget (the button with the arrow right of every ComboBox control) of the ComboBox. How can disable the left part (text part of every ComboBox), so that no entry can be manually made into the ComboBox?
3
1980
by: Pete | last post by:
I'm currently doing a database that uses comboboxes to look up records in other tables, whether they be lookup tables or otherwise. When a user needs to add an item to one of these tables, the user has to either double-click on the combobox or go to the appropriate form via an item on the main menu. So, using an example, if someone is entering enrollment information, they would definitely need a student and a course. If the course has...
20
2376
by: Jack Schitt | last post by:
I thought I was starting to get a handle on Access, until I tried doing something useful...now I'm stuck. I have a DB with two tables - to keep it simple I'll say that one is an Employee File (Employees), and the other is an Address File (Addresses) linked by SSN. I've set Addresses as a Lookup Table - If the user starts typing in the SSN it should pull up the Employees records. I'm getting stuck in the Data Entry form. When I type in...
6
1537
by: Noozer | last post by:
I'm developing a database using MS Access and have come across a problem. The majority of my database is pretty straightforward "many to one" relationships. I have one relationship that is backwards though... This is probably easier to diagram than to describe... Countries -M to1-> Provinces - M to 1-> Cities <-M to 1- Call Centres With the above relationships I am having trouble implementing a simple data entry interface. Basically...
4
1753
by: David Sworder | last post by:
Hi, I have a ComboBox that contains 1,400 sorted items . Here's the list: abba apple ... cabba caccaa capple
11
362
by: Doug Bell | last post by:
Hi, I have a problem with a ComboBox bound to a DataView. The ComboBox shows the correct number of rows but instead of the data, each row shows "System.Data.DataRowView" Can someone explain how to fix this and why it is happening? The Form's Class has: Imports DataAccessLayer 'Class that retrieves data as a DataSet
1
2632
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from Products table.
2
2013
by: JohnR | last post by:
I have a question on bindingcontext, bindings, and controlbindingscollection. I understand the very basic idea, and I think I should be able to do this, but I'm not sure how. First problem: I have a combobox and a textbox on a form. I also have a "Customers" table loaded into a dataset. I set the combobox.datasource to the table in the dataset, and add a binding to the text property of the combobox for the 'Name' field. I also add...
0
9492
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
9299
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
10076
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9740
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
8744
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
7287
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
5332
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3402
muto222
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.