ListView KeyPress event

O

oren

Hello

Is there a way to intercept the KeyPress event for a ListView control ?
Any workaround ?
Any alternative 3rd party controls with this functionality ?

Regards,

Oren.
 
S

Serg Kuryata [MS]

Hello Oren,

The KeyPress event is supported for ListView in the .NET Compact Framework
V1 SP2.

Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "oren" <[email protected]>
| Subject: ListView KeyPress event
| Date: Tue, 7 Dec 2004 14:24:17 +0200
| Lines: 11
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: bzq-219-178-41.dsl.bezeqint.net 62.219.178.41
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09
.phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:66438
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hello
|
| Is there a way to intercept the KeyPress event for a ListView control ?
| Any workaround ?
| Any alternative 3rd party controls with this functionality ?
|
| Regards,
|
| Oren.
|
|
|
 
S

Stuart Celarier

Sergiy said:
The KeyPress event is supported for ListView in the .NET Compact
Framework V1 SP2.

Say, I looked into this. 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?

Cheers,
Stuart Celarier, Fern Creek


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() );
}
}
}
 
S

Serg Kuryata [MS]

Hello Stuart and Fern,


First of all I want to apologize for such a long delay with a reply.

I tried your code on a device that had .NETCF V1 SP2 installed and it
worked just fine as long as the ListView control had focus. In V1, when a
.NETCF application starts, the form is focused (not its children). This has
been changed in V2.

The only thing I had to do to make your application work was to add
listView.Focus() at the end of the constructor.

Hope this helps.
Please let me know if you have any other questions.
Thank you,
Sergiy.

--------------------
| From: "Stuart Celarier" <[email protected]>
| References: <[email protected]>
| Subject: Re: ListView KeyPress event
| Date: Fri, 10 Dec 2004 07:42:03 -0800
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="US-ASCII"
| Content-Transfer-Encoding: 7bit
| X-Mailer: Microsoft Office Outlook, Build 11.0.6353
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Thread-Index: AcTcbR//HD9l1NxhRBW5eaD+Z1EA3QAIoxUaAI88BRA=
| In-Reply-To: <[email protected]>
| X-Transport: MAPILab NNTP v1.2 for Microsoft Outlook,
http://www.mapilab.com/
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: c-67-169-206-96.client.comcast.net 67.169.206.96
| Lines: 1
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
.phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:66678
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Sergiy wrote:
| >The KeyPress event is supported for ListView in the .NET Compact
| Framework V1 SP2.
|
| Say, I looked into this. 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?
|
| Cheers,
| Stuart Celarier, Fern Creek
|
|
| 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() );
| }
| }
| }
|
|

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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