473,729 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implementing completion combobox using touch-screen buttons

Hi All,

I am trying to develop an application for a touch screen using buttons
for the numeric pad with Completion ComboBoxes.

At the moment I am having a problem sending the button presses to my
Completion ComboBox using sendkey.wait. From the keyboard (that will
not exist for my final application) I can enter text into my
Completion and the selection completes as expected.

In the attached demo program I can type using the keyboard

Type Selection Box shows
4 " 440 - Line 0"
44 " 440 - Line 0"
444 " 444 - Line 4"

However when I press the four button on my form I get.

Type Selection Box shows
4 " 440 - Line 0"
4 line clears

I assume that this is related to the fact that the focus is changing
from the ComboBox to the button during the press. Then I am forcing
the focus back to the Completion ComboBox. Not the same as typing
with a keyboard where the focus does not change.

What can I do so I can have both keyboard and button pressing to work
correctly in my Completion ComboBox? Is Sendkeys the way to go?

I have attached the shortest demo program I could develop. I hope
that this is suitable to demostrate my question.

Thanks for your time in reviewing my question. I have not been clear
please ask.

Tanaka

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

namespace keypad
{
public class mdtclientForm : System.Windows. Forms.Form
{
private System.Componen tModel.Containe r components = null;
private System.Windows. Forms.Button FourButton;
private CompletionCombo Box CompletionCombo Box;

private string strLostFocus;

public mdtclientForm()
{

InitializeCompo nent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
} base.Dispose( disposing );
}

#region Windows Form Designer generated code

private void InitializeCompo nent()
{
this.FourButton = new System.Windows. Forms.Button();
this.Completion ComboBox = new keypad.Completi onComboBox();
this.SuspendLay out();

this.FourButton .Location = new System.Drawing. Point(100, 150);
this.FourButton .Name = "FourButton ";
this.FourButton .Size = new System.Drawing. Size(50, 45);
this.FourButton .TabIndex = 29;
this.FourButton .Text = "4";
this.FourButton .Click += new
System.EventHan dler(this.Numer icPad_Click);

this.Completion ComboBox.Locati on = new System.Drawing. Point(32,
88);
this.Completion ComboBox.Name = "CompletionComb oBox";
this.Completion ComboBox.Size = new System.Drawing. Size(200, 21);
this.Completion ComboBox.TabInd ex = 3;
this.Completion ComboBox.LostFo cus += new
System.EventHan dler(this.COMBO BOX_LostFocus);
this.Completion ComboBox.Text = "<Press Keys or Buttons>";
this.Completion ComboBox.Items. AddRange(new object[] {
"440 - Line 0",
"441 - Line 1",
"442 - Line 2",
"443 - Line 3",
"444 - Line 4 ",
"445 - Line 5",
"446 - Line 5"});
this.ClientSize = new System.Drawing. Size(292, 266);
this.Controls.A dd(this.FourBut ton);
this.Controls.A dd(this.Complet ionComboBox);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayo ut(false);
}
#endregion

[STAThread]
static void Main()
{
Application.Run (new mdtclientForm() );
}

private void NumericPad_Clic k(object sender, System.EventArg s e)
{
foreach (Control controls in this.Controls)
{
if (controls.Name == strLostFocus)
{
if (Object.Referen ceEquals(contro ls.GetType(),
typeof(Completi onComboBox)))
{
CompletionCombo Box mycontrol = new CompletionCombo Box();
Button button = (Button) sender;
if(controls.Can Focus)
{
controls.Focus( );
SendKeys.SendWa it(button.Text) ;
}
}
}
}
}

private void COMBOBOX_LostFo cus (object sender, System.EventArg s e)
{
CompletionCombo Box comboBox = (CompletionComb oBox) sender;
strLostFocus = comboBox.Name;
}
}

public class CompletionCombo Box : ComboBox
{
public event System.Componen tModel.CancelEv entHandler NotInList;

[Category("Behav ior")]
public bool LimitToList
{
get { return _limitToList_; }
set { _limitToList_ = value; }
}

protected virtual void
OnNotInList(Sys tem.ComponentMo del.CancelEvent Args e)
{
if (NotInList != null)
NotInList.Invok e(this, e);
}

protected override void
OnValidating(Sy stem.ComponentM odel.CancelEven tArgs e)
{
if (_limitToList_)
{
int pos = FindStringExact (Text);
if (pos == -1)
OnNotInList(e);
else
this.SelectedIn dex = pos;
} base.OnValidati ng(e);
}

protected override void OnKeyDown(KeyEv entArgs args)
{
_autoComplete_ = args.KeyCode != Keys.Delete && args.KeyCode !=
Keys.Back;
base.OnKeyDown( args);
}

protected override void OnTextChanged(E ventArgs args)
{
if( _autoComplete_ )
{
string textEntered = Text;
int index = FindString(text Entered);
if( index >= 0 )
{
_autoComplete_ = false;
SelectedIndex = index;
_autoComplete_ = true;
Select(textEnte red.Length, Text.Length);
}
} base.OnTextChan ged(args);
}
private bool _autoComplete_ = true;
private bool _limitToList_ = true;
}
}
Nov 16 '05 #1
0 2663

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

Similar topics

0
1626
by: Edvard Majakari | last post by:
Suppose you have a program containing commands and file name parameters. A simple class providing completion could first read all the commands to list, and extend that list later using all file names in given directory. This way a user could tab-complete (using readline.parse_and_bind('tab: complete')) any command and any file. Eg. if a command 'move' is implemented and there are files 'foo.txt' and 'bar.txt', the user could type ...
67
4268
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. Unfortunately these ad hominem rhetorts are frequently introduced into purely technical discussions on the feasibility of supporting such functionality in C++. That usually serves to divert the discussion from the technical subject to a discussion of the...
0
1156
by: duffwilson | last post by:
I have implemented text completion according to the instructions outlined in the following link: http://support.microsoft.com/default.aspx?scid=kb;en-us;320107 This seems to work fine if you type relatively slowly into the combo box, but if you type very fast the text selection doesn't work properly. After the combobox is populated with the matching text, subsequent characters get added to the end.
4
3688
by: Lauren Wilson | last post by:
A2K I have a combo box that shows the content of a last name field from a table. I use it to locate records in the table form. I can open the form and locate several names quickly by placing the cursor inside the drop-down list and typing the first few letters of the name I want to find. Then, for no apparent reason, the list just stops responding to subsequent searches for names that I KNOW are in the list. The list contains no...
3
6022
by: | last post by:
Hello, I try to format the text of a combobox with DropDownStyle "DropDown". I just mean the text which is displayed when the combobox isn't touched. Usually it displays the ToString() method of the SelectedItem. But I want to override the it. Overriding the ToString() of the class of the SelectedItem doesn't help because I can't touch the class. Maybe I have to rewrite the WndProc WM_PAINT. Whatever, I just need an idea. ... Thanks!
4
3532
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The objective in utilizing this new deployment method is to reduce the maintenance overhead as well as making it easier for my users to setup and run the application initially. I have VS 2002, Windows XP, Access XP(2000 format). He is my problem....
0
3056
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The objective in utilizing this new deployment method is to reduce the maintenance overhead as well as making it easier for my users to setup and run the application initially. I have VS 2002, Windows XP, Access XP(2000 format). He is my problem....
5
30046
by: Keith G | last post by:
I am using Visual Studio 2003. In the standard combobox control it would appear that only 1 column of data can be displayed in the list (as stipulated in the DisplayMember property). In VBA it was always possible to specify a column count and then set the width for each column (setting 0 width for columns not to be displayed). The Bound Column property was then specified to set the data to be retrieved from the control (the ValueMember...
3
2465
by: Nebulism | last post by:
Hi everyone! Earlier I asked a question about mouse interaction with a GUI. I have found a pretty comprehensive script that is supposed to work <mod edit: link removed, source inserted>:# This class describes a generic method of drawing rubberbands # on a wxPython canvas object (wxStaticBitmap, wxPanel etc) when # the user presses the left mouse button and drags it over a rectangular # area. It has methods to return the selected area by...
3
1404
by: Academia | last post by:
If the user types into the TextBox of a combobox it works OK. But if he hold a key down so the letter repeats quickly the code runs into trouble. My questions are: Is it true that an event's code is normally run to completion before another event's code is entered (KeyUp in my case)? If that is true and there are exceptions that let another event start do they include:
0
8761
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
9426
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...
0
9281
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
9142
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
8148
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
6722
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
6022
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
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...
2
2680
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.