Heads-down data entry into a list

This is a concise, user-friendly way to add intuitive functionality to a form that controls one or more lists of entries. It is optimized for 10-Key operators but will also work for QWERTY-mode users.

Drop a Textbox and a Listbox onto the UI; place them close together and name them similarly. For example, txtSerialNumber and lbSerialNumber. Add a ToolTip to the form, toolTip1.

 Create event handlers for:

* KeyDown on the Textbox.

* DragDrop, DragOver, KeyDown, and SelectedIndexChanged on the Listbox.

private void txtSerialNumber_KeyDown(object sender, KeyEventArgs e)

{

UnifiedTextboxAndListbox_Keydown(lbSerialNumbers, txtSerialNumber, e);

}

private void lbSerialNumbers_KeyDown(object sender, KeyEventArgs e)

{

UnifiedTextboxAndListbox_Keydown(lbSerialNumbers, txtSerialNumber, e);

}

private void lbSerialNumbers_SelectedIndexChanged(object sender, EventArgs e)

{

if (lbSerialNumbers.SelectedIndex >= 0)

{

txtSerialNumber.Text = lbSerialNumbers.SelectedItem.ToString();

}

}

privatevoid lbSerialNumbers_DragDrop(object sender, DragEventArgs e)

{

HandleDragDrop(e,lbSerialNumbers);

mq.FillGridWithMeoInformation(lbSerialNumbers, lbShopOrders, dgvMesInfo);

}

privatevoid HandleDragDrop(DragEventArgs e, ListBox lb)

{

if (e.Effect == DragDropEffects.Copy)

{

if (e.Data.GetDataPresent(DataFormats.CommaSeparatedValue))

{

char[] sep = {‘\r’};string droppedData = e.Data.GetData(DataFormats.StringFormat, true).ToString();

droppedData = droppedData.Replace(

“\n”,“”);foreach (String s in droppedData.Split(sep))

{

if (s.Length > 0)

{

lb.Items.Add(s);

}

}

}

}

}

private void lbSerialNumbers_DragOver(object sender, DragEventArgs e)

{

HandleDragOver(e);

Kamagra Jelly usually starts working around 15 to 30 reps. http://www.glacialridgebyway.com/windows/Fort%20Lake%20Johanna.html order 50mg viagra Fast, simple infant sitting service, appropriate? Right! You have probably currently found that absolutely nothing is ever before “quick and easy” when “G……and G……” are involved. cheapest viagra tablets http://www.glacialridgebyway.com/windows/Kandiyohi%20County%20Museum.html After a while you viagra viagra sildenafil might also see a reduction of it now. Sildenafil citrate, the first: Sildenafil citrate was the first drug that has been created purchase viagra online to address erectile dysfunction. }

private void HandleDragOver(DragEventArgs e)

{

if (e.Data.GetDataPresent(DataFormats.CommaSeparatedValue))

{

e.Effect =

DragDropEffects.Copy;

}

else

{

e.Effect =

DragDropEffects.None;

}

}

 

private void UnifiedTextboxAndListbox_Keydown(ListBox lb, TextBox txt, KeyEventArgs e)

{

if ((e.KeyCode == Keys.Enter) | (e.KeyCode == Keys.Subtract) | (e.KeyCode == Keys.OemMinus) | (e.KeyCode == Keys.Add) | (e.KeyCode == Keys.Oemplus) | (e.KeyCode == Keys.M))

{

//Process listbox.switch (e.KeyCode)

{

caseKeys.Add:

lb.Items.Add(txt.Text);

break;caseKeys.Oemplus:

lb.Items.Add(txt.Text);

break;caseKeys.Enter:

lb.Items.Add(txt.Text);

break;caseKeys.Subtract:

lb.Items.Remove(txt.Text);

break;caseKeys.OemMinus:

lb.Items.Remove(txt.Text);

break;

}

 

//Process textbox.

txt.Clear();

//Update UI.

mq.FillGridWithMeoInformation(lbSerialNumbers, lbShopOrders, dgvMesInfo);

//Done.

e.SuppressKeyPress =

true;

e.Handled =

true;

}

}

 

This entry was posted in C#, Programming. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.