[LISTVIEW] Keypress event

G

Guest

The ListView.KeyPress event is exposed in the
...NET Compact Framework, but maybe I am using it incorrectly. A complete
program is included below: I never get the MessageBox from
listView_KeyPress. This approach works on the .NET Framework. What am I
missing?

using System.Drawing;
using System.Windows.Forms;

namespace SmartDeviceApplication6
{
public class Form1 : Form
{
private ListView listView;

public Form1()
{
listView = new ListView();
listView.Location = new Point(10 , 10);
ListViewItem lvi = new ListViewItem( "Item" );
listView.Items.Add( lvi );

Controls.Add( listView );
Text = "Form1";

listView.KeyPress += new KeyPressEventHandler( listView_KeyPress
);
}

private void listView_KeyPress( object sender, KeyPressEventArgs e )
{
MessageBox.Show( "Key pressed" );
}

static void Main()
{
Application.Run( new Form1() );
}
}
}

Rogerio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top