void tbInput_GotFocus(object sender, EventArgs e) { CTextBox tSender = ((CTextBox)sender); string sTagToLookFor = (tSender).AccessibleDescription; if (sTagToLookFor != "NULL") { for (int i = 0; i < ibArray.Length; i++) { if (ibArray[i].sTag == sTagToLookFor) { AddMessage(sTagToLookFor + "_HELPMSG", ibArray[i].sHelpMessage, new Point(tSender.Left + tSender.Width + 10, tSender.Top)); } } } ((CTextBox)sender).SelectionStart = ((CTextBox)sender).Text.Length; }
void tbInputKeyup(object sender, KeyEventArgs e) { CTextBox tbSender = (CTextBox)sender; if (tbSender.MaxCharCount != 0) { string sLeft = "[" + tbSender.Text.Length + " / " + tbSender.MaxCharCount + "]"; int nPos = 0; for (nPos = 0; nPos < MessageLabel(tbSender.AccessibleDescription).Text.Length; nPos++) { if (MessageLabel(tbSender.AccessibleDescription).Text[nPos] == '[') { break; } } string sNewText = ""; if (nPos < MessageLabel(tbSender.AccessibleDescription).Text.Length) { sNewText = MessageLabel(tbSender.AccessibleDescription).Text.Remove(nPos) + sLeft; } else { sNewText = MessageLabel(tbSender.AccessibleDescription).Text + " " + sLeft; } MessageLabel(tbSender.AccessibleDescription).Text = sNewText; } if (Convert.ToInt32(tbSender.CreateGraphics().MeasureString(tbSender.Text, tbSender.Font).Width) > tbSender.Width) { tbSender.Width = Convert.ToInt32(tbSender.CreateGraphics().MeasureString(tbSender.Text, tbSender.Font).Width); int nCurrentCursorPos = tbSender.SelectionStart; tbSender.SelectionStart = 0; tbSender.SelectionStart = nCurrentCursorPos; } else if (tbSender.OriginalWidth < tbSender.Width && tbSender.Width > Convert.ToInt32(tbSender.CreateGraphics().MeasureString(tbSender.Text, tbSender.Font).Width)) { if (Convert.ToInt32(tbSender.CreateGraphics().MeasureString(tbSender.Text, tbSender.Font).Width) < tbSender.OriginalWidth) { tbSender.Width = tbSender.OriginalWidth; } else { tbSender.Width = Convert.ToInt32(tbSender.CreateGraphics().MeasureString(tbSender.Text, tbSender.Font).Width); } } MessageLabel(tbSender.AccessibleDescription).Location = new Point(tbSender.Left + tbSender.Width + 10, tbSender.Top); }
void tbInputKeyDown(object sender, KeyEventArgs e) { CTextBox tbSender = (CTextBox)sender; /* * if (tbSender.AccessibleDescription.Contains("£")) * { * if (e.KeyCode == Keys.Enter) * { * try * { * tbSender.Text = FormatMoneyForDisplay(tbSender.Text); * } * catch * { * ; * } * } * }*/ if (tbSender.MaxCharCount != 0 && tbSender.Text.Length == tbSender.MaxCharCount && e.KeyCode != Keys.Delete && e.KeyCode != Keys.Back && e.KeyCode != Keys.Escape && e.KeyCode != Keys.Enter && e.KeyCode != Keys.Left && e.KeyCode != Keys.Right) { e.SuppressKeyPress = true; } }