This is a migrated thread and some comments may be shown as answers.

List of 'missing' events

3 Answers 78 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Clive
Top achievements
Rank 1
Clive asked on 27 Oct 2011, 08:36 AM
Hi,

I noticed that the OnKeyPress, OnKeyUp, and OnKeyDown don't 'work' the same as the microsoft text box, it's been documented here in this forum, and there were a few other events that don't work as expected.

Is there a full list of events in this and other controls that I should be wary about when converting all our .net controls to telerik ones?

I'm using version 2011.2.11.831.

Thanks,
Clive

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 31 Oct 2011, 09:51 AM
Hello Clive,

Thank you for writing.

I have just tested those events with our latest version and all three of them are fired correctly:
public Form1()
{
    InitializeComponent();
    radTextBox1.KeyUp += new KeyEventHandler(radTextBox1_KeyUp);
    radTextBox1.KeyDown += new KeyEventHandler(radTextBox1_KeyDown);
    radTextBox1.KeyPress += new KeyPressEventHandler(radTextBox1_KeyPress);
}
 
void radTextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    Console.WriteLine("Press");
}
 
void radTextBox1_KeyDown(object sender, KeyEventArgs e)
{
    Console.WriteLine("Down");
}
 
void radTextBox1_KeyUp(object sender, KeyEventArgs e)
{
    Console.WriteLine("UP");
}

We used to have such an issue with the events in the previous versions of our suite. However, in those versions you can still capture the events, by subscribing to the events of the hosted control:
    radTextBox1.TextBoxElement.TextBoxItem.HostedControl.KeyDown += new KeyEventHandler(HostedControl_KeyDown);
    radTextBox1.TextBoxElement.TextBoxItem.HostedControl.KeyUp += new KeyEventHandler(HostedControl_KeyUp);
    radTextBox1.TextBoxElement.TextBoxItem.HostedControl.KeyPress += new KeyPressEventHandler(HostedControl_KeyPress);
 
void HostedControl_KeyPress(object sender, KeyPressEventArgs e)
{
     
}
 
void HostedControl_KeyUp(object sender, KeyEventArgs e)
{
     
}
 
void HostedControl_KeyDown(object sender, KeyEventArgs e)
{
     
}

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us. 

Regards,
Stefan
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Clive
Top achievements
Rank 1
answered on 01 Nov 2011, 04:17 AM
Hi Stefan,

Sorry I didn't include a code example to what I mean. We have numerous controls that inherit from Microsoft System.Windows.Forms.xyz to Telerix controls. We override many OnEvent methods, and it was concerning that these did not fire when I moved them to Telerik controls. I'm wondering if there is a list of OnEvent methods that don't do what I'd expect, similarly if there is a list of events that do not fire in Telerik controls that would fire in System.Windows.Forms controls.

In the example below typing into the TextBox1 has the following output.

OnEnter TextBox1

Enter TextBox1

OnKeyDown TextBox1

KeyDown TextBox1

OnKeyPress TextBox1

KeyPress TextBox1

OnKeyUp TextBox1

KeyUp TextBox1


This is following a nice pattern. However the RadTextBox1 has the following output, that does not follow a similar pattern.

OnEnter RadTextBox1

KeyDown RadTextBox1

KeyPress RadTextBox1

KeyUp RadTextBox1


It looks like it's a bit of a mess with what I should be overriding, or listening to events.

Imports Telerik.WinControls.UI
  
Public Class Form5
    Inherits System.Windows.Forms.Form
  
    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub
  
    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer
  
    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.RadTextBox1 = New RadicalTextBox()
        Me.ListBox1 = New System.Windows.Forms.ListBox()
        Me.TextBox1 = New BoringTextBox()
        CType(Me.RadTextBox1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'RadTextBox1
        '
        Me.RadTextBox1.Location = New System.Drawing.Point(41, 25)
        Me.RadTextBox1.Name = "RadTextBox1"
        Me.RadTextBox1.Size = New System.Drawing.Size(100, 20)
        Me.RadTextBox1.TabIndex = 1
        Me.RadTextBox1.TabStop = False
        Me.RadTextBox1.Text = "RadTextBox1"
        '
        'ListBox1
        '
        Me.ListBox1.FormattingEnabled = True
        Me.ListBox1.Location = New System.Drawing.Point(21, 51)
        Me.ListBox1.Name = "ListBox1"
        Me.ListBox1.Size = New System.Drawing.Size(234, 186)
        Me.ListBox1.TabIndex = 0
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(155, 25)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(100, 20)
        Me.TextBox1.TabIndex = 2
        Me.TextBox1.TabStop = False
        Me.TextBox1.Text = "TextBox1"
        '
        'Form5
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.Add(Me.ListBox1)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.RadTextBox1)
        Me.Name = "Form5"
        Me.Text = "Form5"
        CType(Me.RadTextBox1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()
  
    End Sub
    Friend WithEvents RadTextBox1 As RadicalTextBox
    Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
    Friend WithEvents TextBox1 As BoringTextBox
    Public Shared lb As ListBox
  
    Private Sub Form5_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        lb = ListBox1
        lb.Focus()
    End Sub
  
End Class
  
Public Class RadicalTextBox
    Inherits RadTextBox
  
    Public Overrides Property ThemeClassName As String
        Get
            Return GetType(RadTextBox).FullName
        End Get
        Set(value As String)
            MyBase.ThemeClassName = value
        End Set
    End Property
  
    Protected Overrides Sub OnKeyUp(e As System.Windows.Forms.KeyEventArgs)
        Form5.lb.Items.Add("OnKeyUp " + Me.Name)
        System.Console.WriteLine("OnKeyUp " + Me.Name)
        MyBase.OnKeyUp(e)
    End Sub
  
    Protected Overrides Sub OnKeyDown(e As System.Windows.Forms.KeyEventArgs)
        Form5.lb.Items.Add("OnKeyDown " + Me.Name)
        System.Console.WriteLine("OnKeyDown " + Me.Name)
        MyBase.OnKeyDown(e)
    End Sub
  
    Protected Overrides Sub OnKeyPress(e As System.Windows.Forms.KeyPressEventArgs)
        Form5.lb.Items.Add("OnKeyPress " + Me.Name)
        System.Console.WriteLine("OnKeyPress " + Me.Name)
        MyBase.OnKeyPress(e)
    End Sub
  
    Protected Overrides Sub OnEnter(e As System.EventArgs)
        Form5.lb.Items.Add("OnEnter " + Me.Name)
        System.Console.WriteLine("OnEnter " + Me.Name)
        MyBase.OnEnter(e)
    End Sub
  
    Private Sub RadicalTextBox_Enter(sender As Object, e As System.EventArgs) Handles Me.Enter
        Form5.lb.Items.Add("Enter " + Me.Name)
    End Sub
  
    Private Sub RadicalTextBox_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Form5.lb.Items.Add("KeyDown " + Me.Name)
        System.Console.WriteLine("KeyDown " + Me.Name)
    End Sub
  
    Private Sub RadicalTextBox_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
        Form5.lb.Items.Add("KeyPress " + Me.Name)
        System.Console.WriteLine("KeyPress " + Me.Name)
    End Sub
  
    Private Sub RadicalTextBox_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        Form5.lb.Items.Add("KeyUp " + Me.Name)
        System.Console.WriteLine("KeyUp " + Me.Name)
    End Sub
End Class
  
  
Public Class BoringTextBox
    Inherits TextBox
  
    Protected Overrides Sub OnKeyUp(e As System.Windows.Forms.KeyEventArgs)
        Form5.lb.Items.Add("OnKeyUp " + Me.Name)
        System.Console.WriteLine("OnKeyUp " + Me.Name)
        MyBase.OnKeyUp(e)
    End Sub
  
    Protected Overrides Sub OnKeyDown(e As System.Windows.Forms.KeyEventArgs)
        Form5.lb.Items.Add("OnKeyDown " + Me.Name)
        System.Console.WriteLine("OnKeyDown " + Me.Name)
        MyBase.OnKeyDown(e)
    End Sub
  
    Protected Overrides Sub OnKeyPress(e As System.Windows.Forms.KeyPressEventArgs)
        Form5.lb.Items.Add("OnKeyPress " + Me.Name)
        System.Console.WriteLine("OnKeyPress " + Me.Name)
        MyBase.OnKeyPress(e)
    End Sub
  
    Protected Overrides Sub OnEnter(e As System.EventArgs)
        Form5.lb.Items.Add("OnEnter " + Me.Name)
        System.Console.WriteLine("OnEnter " + Me.Name)
        MyBase.OnEnter(e)
    End Sub
  
    Private Sub BoringTextBox_Enter(sender As Object, e As System.EventArgs) Handles Me.Enter
        Form5.lb.Items.Add("Enter " + Me.Name)
        System.Console.WriteLine("Enter " + Me.Name)
    End Sub
  
    Private Sub BoringTextBox_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        Form5.lb.Items.Add("KeyDown " + Me.Name)
        System.Console.WriteLine("KeyDown " + Me.Name)
    End Sub
  
    Private Sub BoringTextBox_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
        Form5.lb.Items.Add("KeyPress " + Me.Name)
        System.Console.WriteLine("KeyPress " + Me.Name)
    End Sub
  
    Private Sub BoringTextBox_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        Form5.lb.Items.Add("KeyUp " + Me.Name)
        System.Console.WriteLine("KeyUp " + Me.Name)
    End Sub
End Class


My experience with .Net is 7 years. My experience with Rad is about 2 weeks.

  • OS version and applied service packs

Microsoft Windows Server 2003, Standard Edition, Service Pack 2

  • Regional and language settings, if different from En-US

English (Australia)

  • .NET version (.NET2, .NET3, .NET3.5)

.NET 4.0.30319 SP1Rel, Visual Studio 2010 Version 10.0.40219.1 SP1Rel

  • Exact version of the Telerik product 

Runtime Version v2.0.50727, Version 2011.2.11.831


0
Stefan
Telerik team
answered on 03 Nov 2011, 04:06 PM
Hi Clive,

Thank you for writing.

In order to have the exact events as in the standard text box, you should replace the default RadTextBoxItem of RadTextBox. In the attachment, you can find a sample application demonstrating this approach. If this solution does not satisfy your needs, please describe your scenario and why you need to override the methods (OnKeyDown, OnKeyPress and OnKeyUp). This will allow us to think of a possible solution that matches your case.

All the best,
Stefan
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Tags
TextBox
Asked by
Clive
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Clive
Top achievements
Rank 1
Share this question
or