14. Februar 2020 00:33
namespace My.CtrlAddIn.TextBox
{
public delegate void TransactionEventHandler(string refNo);
[ControlAddInExport("My.CtrlAddIn.TextBox")]
public class MyFieldPopupAddin : StringControlAddInBase,IEventControlAddInDefinition
{
private System.Windows.Forms.TextBox _textBox;
//Exposes an event
[ApplicationVisible]
public event EventHandler ControlAddInReady;
[ApplicationVisible]
public event EventHandler TextValueChanged;
public delegate void MyEventHandler(string refNo);
[ApplicationVisible]
public event MyEventHandler TextGeaendert;
[ApplicationVisible]
public Color BackgroundColor
{
get { return _textBox.BackColor; }
set { _textBox.BackColor = value; }
}
[ApplicationVisible]
public void SetFocus()
{
_textBox.Text = "Bitte Text eingeben ";
_textBox.Focus();
}
[ApplicationVisible]
public void ChangeText(string textin)
{
_textBox.Text = textin;
_textBox.Focus();
}
[ApplicationVisible]
public string MyText
{
get { return _textBox.Text; }
set { _textBox.Text = value; _textBox.Focus(); _textBox.Select(); }
}
/// Defines the text box control.
protected override Control CreateControl()
{
_textBox = new System.Windows.Forms.TextBox();
_textBox.BackColor = Color.LightBlue;
_textBox.Font = new Font("Arial", 9, FontStyle.Bold);
//_textBox.Text = "Hallo addIn";
//_textBox.DoubleClick += control_DoubleClick;
_textBox.BackColor = Color.LightSteelBlue;
_textBox.Select();
_textBox.Focus();
_textBox.AcceptsReturn = true;
_textBox.PreviewKeyDown += _textBox_PreviewKeyDown;
_textBox.ParentChanged += OnTextBoxOnParentChanged;
return _textBox;
}
private void OnTextBoxOnParentChanged(object sender, EventArgs e)
{
if(ControlAddInReady != null)
{
ControlAddInReady(_textBox, null);
_textBox.Select();
_textBox.Focus();
}
_textBox.Select();
_textBox.Focus();
}
private void _textBox_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
TextGeaendert(_textBox.Text);
}
}
private void OnTextChanged(object sender, EventArgs e)
{
TextGeaendert(_textBox.Text);
}
/// Raises an event when the user double-clicks the text box.
private void control_DoubleClick(object sender, EventArgs e)
{
int index = 0;
string data = this.Control.Text;
this.RaiseControlAddInEvent(index, data);
TextGeaendert(_textBox.Text);
}
}
}
CASE InputPage.RUNMODAL OF
ACTION::OK: BEGIN...