Ibuttoncontrol example

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

can somebody help me out with a (working ) example of the Ibuttoncontrol on
f.i. a textbox, so if the users uses the enter key on the textbox, an event
(msgbox) is showed

Thx!!
 
Please try code below

using System;
using System.Windows.Forms;

namespace CmdShell
{
class TextBoxIButtonControl : TextBox, IButtonControl
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (e.KeyChar == '\n')
{
e.Handled = true;
PerformClick();
}
base.OnKeyPress(e);
}

#region IButtonControl Members

public DialogResult DialogResult
{
get
{
throw new Exception("The method or operation is not
implemented.");
}
set
{
throw new Exception("The method or operation is not
implemented.");
}
}

public void NotifyDefault(bool value)
{
//throw new Exception("The method or operation is not
implemented.");
}

public void PerformClick()
{
MessageBox.Show("Test");
//throw new Exception("The method or operation is not
implemented.");
}

#endregion
}
}


http://www.alvas.net - Audio tools for C# and VB.Net developers
 
Dear Alexander,

Thx for your help so far, but........ since I'm a VB programmmer, do you
have the code in VB?
--
Best regards
Luc

Alexander Vasilevsky said:
Please try code below

using System;
using System.Windows.Forms;

namespace CmdShell
{
class TextBoxIButtonControl : TextBox, IButtonControl
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (e.KeyChar == '\n')
{
e.Handled = true;
PerformClick();
}
base.OnKeyPress(e);
}

#region IButtonControl Members

public DialogResult DialogResult
{
get
{
throw new Exception("The method or operation is not
implemented.");
}
set
{
throw new Exception("The method or operation is not
implemented.");
}
}

public void NotifyDefault(bool value)
{
//throw new Exception("The method or operation is not
implemented.");
}

public void PerformClick()
{
MessageBox.Show("Test");
//throw new Exception("The method or operation is not
implemented.");
}

#endregion
}
}


http://www.alvas.net - Audio tools for C# and VB.Net developers
 
Back
Top