473,473 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Create 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.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace keypad
{
public class mdtclientForm : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Button FourButton;
private CompletionComboBox CompletionComboBox;

private string strLostFocus;

public mdtclientForm()
{

InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
} base.Dispose( disposing );
}

#region Windows Form Designer generated code

private void InitializeComponent()
{
this.FourButton = new System.Windows.Forms.Button();
this.CompletionComboBox = new keypad.CompletionComboBox();
this.SuspendLayout();

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.EventHandler(this.NumericPad_Click);

this.CompletionComboBox.Location = new System.Drawing.Point(32,
88);
this.CompletionComboBox.Name = "CompletionComboBox";
this.CompletionComboBox.Size = new System.Drawing.Size(200, 21);
this.CompletionComboBox.TabIndex = 3;
this.CompletionComboBox.LostFocus += new
System.EventHandler(this.COMBOBOX_LostFocus);
this.CompletionComboBox.Text = "<Press Keys or Buttons>";
this.CompletionComboBox.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.Add(this.FourButton);
this.Controls.Add(this.CompletionComboBox);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion

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

private void NumericPad_Click(object sender, System.EventArgs e)
{
foreach (Control controls in this.Controls)
{
if (controls.Name == strLostFocus)
{
if (Object.ReferenceEquals(controls.GetType(),
typeof(CompletionComboBox)))
{
CompletionComboBox mycontrol = new CompletionComboBox();
Button button = (Button) sender;
if(controls.CanFocus)
{
controls.Focus();
SendKeys.SendWait(button.Text);
}
}
}
}
}

private void COMBOBOX_LostFocus (object sender, System.EventArgs e)
{
CompletionComboBox comboBox = (CompletionComboBox) sender;
strLostFocus = comboBox.Name;
}
}

public class CompletionComboBox : ComboBox
{
public event System.ComponentModel.CancelEventHandler NotInList;

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

protected virtual void
OnNotInList(System.ComponentModel.CancelEventArgs e)
{
if (NotInList != null)
NotInList.Invoke(this, e);
}

protected override void
OnValidating(System.ComponentModel.CancelEventArgs e)
{
if (_limitToList_)
{
int pos = FindStringExact(Text);
if (pos == -1)
OnNotInList(e);
else
this.SelectedIndex = pos;
} base.OnValidating(e);
}

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

protected override void OnTextChanged(EventArgs args)
{
if( _autoComplete_ )
{
string textEntered = Text;
int index = FindString(textEntered);
if( index >= 0 )
{
_autoComplete_ = false;
SelectedIndex = index;
_autoComplete_ = true;
Select(textEntered.Length, Text.Length);
}
} base.OnTextChanged(args);
}
private bool _autoComplete_ = true;
private bool _limitToList_ = true;
}
}
Nov 16 '05 #1
0 2649

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

Similar topics

0
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...
67
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. ...
0
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...
4
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...
3
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...
4
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...
0
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...
5
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...
3
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...
3
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...
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
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...
1
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...
1
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...
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: 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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.