HighTechTalks DotNet Forums  

OnClick not working in listbox

Dotnet Framework (Compact Framework) microsoft.public.dotnet.framework.compactframework


Discuss OnClick not working in listbox in the Dotnet Framework (Compact Framework) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Ken Beauchesne
 
Posts: n/a

Default OnClick not working in listbox - 12-02-2004 , 06:41 AM






I have a problem trying to get the OnClick to fire in a listbox,
no matter what method I try to get access to it there is no response.
The doc's say it's supported has anyone had success or can see
what i'm doing wrong?


thanks
Ken

private DisplayListBox.DisplayList DisplayList = new
DisplayListBox.DisplayList();

this.Controls.Add(this.DisplayList);


--------------------------------
list gets filled with items, another event pops up the listbox
and everything is there and when I click on an item the OnClick
never gets called. I use this exact code else where for a non listbox
control and it works perfect.
---------------------------------

namespace DisplayListBox
{
public class DisplayList :System.Windows.Forms.ListBox
{
public delegate void DoubleClickEventHandler( EventArgs e);
public event DoubleClickEventHandler OnDoubleClick;
private int previousClick = SystemInformation.DoubleClickTime + 1;

public DisplayList()
{
this.OnDoubleClick +=new
DoubleClickEventHandler(DisplayList_OnDoubleClick) ;
this.Location = new Point(200,80);
this.Enabled = true;
this.Visible = false;
}


~DisplayList()
{
}

private void DisplayList_OnDoubleClick(EventArgs e)
{
//
int DisplayIndex;

DisplayIndex = 1; // just for debug never gets here
}



protected override void OnClick(EventArgs e)
{
this.Focus();
int now = System.Environment.TickCount;
if(now - previousClick <= SystemInformation.DoubleClickTime)
{
this.OnDoubleClick(e);
}

previousClick = now;

}



Reply With Quote
  #2  
Old   
Stuart Celarier
 
Posts: n/a

Default Re: OnClick not working in listbox - 12-02-2004 , 07:53 AM






Ken wrote:
Quote:
I have a problem trying to get the OnClick to fire in a listbox,
Take a look at docs for System.Windows.Forms.ListBox events [1]. There is no Click event. That would be your problem.

ListBox does have a DoubleClick event, and that's why you were able to register a delegate for the DoubleClick event, but you don't have a similar line of code to register a handler for the Click event.

Cheers,
Stuart Celarier, Fern Creek

[1] http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsforms.asp



Reply With Quote
  #3  
Old   
Ken Beauchesne
 
Posts: n/a

Default Re: OnClick not working in listbox - 12-02-2004 , 08:14 AM



the OnClick (inherited from Control) is supported in .NET CF
the double click is not in CF that was what my control was attempting
to implement. Check out listbox members

Ken

"Stuart Celarier" <stuart (AT) ferncrk (DOT) NOSPAM.com> wrote

Quote:
Ken wrote:
I have a problem trying to get the OnClick to fire in a listbox,

Take a look at docs for System.Windows.Forms.ListBox events [1]. There is
no Click event. That would be your problem.

ListBox does have a DoubleClick event, and that's why you were able to
register a delegate for the DoubleClick event, but you don't have a similar
line of code to register a handler for the Click event.
Quote:
Cheers,
Stuart Celarier, Fern Creek

[1]
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsforms.asp




Reply With Quote
  #4  
Old   
Stuart Celarier
 
Posts: n/a

Default Re: OnClick not working in listbox - 12-02-2004 , 03:31 PM



Ken wrote:
Quote:
the OnClick (inherited from Control) is supported in .NET CF
the double click is not in CF that was what my control was attempting
to implement.
Sorry, I misunderstood your question. The DoubleClick in your sample is what threw me.

Yes, I have confirmed the problem. Below is a minimal sample that illustrates the symptom. You can compile it under both .NET Framework and .NET Compact Framework and confirm that for the latter OnClick is never called.

I will try to investigate further.

Cheers,
Stuart Celarier, Fern Creek

<SampleCode>

// On the .NET Framework a MessageBox is displayed
// when the ListBox is clicked.
//
// On the .NET Compact Framework a MessageBox is NOT displayed
// when the ListBox is clicked.

using System;
using System.Windows.Forms;

namespace OnClickNotCalled
{
public class CustomListBox : ListBox
{
protected override void OnClick(EventArgs e)
{
MessageBox.Show( "Click" );
base.OnClick (e);
}
}

public class Form1 : System.Windows.Forms.Form
{
private CustomListBox listBox1;

public Form1()
{
this.listBox1 = new CustomListBox();
this.listBox1.Location = new System.Drawing.Point(20, 20);
this.listBox1.Size = new System.Drawing.Size(100, 100);

this.Controls.Add(this.listBox1);
this.Text = "Form1";
}

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

</SampleCode>


Reply With Quote
  #5  
Old   
Stuart Celarier
 
Posts: n/a

Default Re: OnClick not working in listbox - 12-02-2004 , 04:01 PM



Here's a little more information: the .NET Compact Framework's Class Library Comparison Tool [1] shows System.Windows.Forms.ListBox.OnClick is only supported on the .NET Framework. That contradicts the .NET Framework Class Library docs for System.Windows.Forms.ListBox members [2]. So maybe this is a documentation error?

Cheers,
Stuart Celarier, Fern Creek

[1] http://msdn.microsoft.com/library/en-us/dv_evtuv/html/etconnetcompactframeworkclasses.asp
[2] http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsformslistboxmemberstopic.asp

Reply With Quote
  #6  
Old   
AT
 
Posts: n/a

Default Re: OnClick not working in listbox - 12-02-2004 , 05:30 PM



Hello Stuart,

Yes, you are right. The Click event is not supported for ListBox in the
.NET Compact Framework.

Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Quote:
From: Stuart Celarier <stuart (AT) ferncrk (DOT) NOSPAM.com
Subject: Re: OnClick not working in listbox
References: <#BBWAZL2EHA.3336 (AT) TK2MSFTNGP11 (DOT) phx.gbl
Content-Type: text/plain; charset=iso-8859-1
X-Newsreader: JetBrains Omea Reader 341.19
Message-ID: <#HSH8pL2EHA.1300 (AT) TK2MSFTNGP14 (DOT) phx.gbl
Newsgroups: microsoft.public.dotnet.framework.compactframework
Date: Thu, 02 Dec 2004 14:01:31 -0800
NNTP-Posting-Host: c-67-169-206-96.client.comcast.net 67.169.206.96
Lines: 1
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP14
.phx.gbl
Quote:
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework :66248
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Here's a little more information: the .NET Compact Framework's Class
Library Comparison Tool [1] shows System.Windows.Forms.ListBox.OnClick is
only supported on the .NET Framework. That contradicts the .NET Framework
Class Library docs for System.Windows.Forms.ListBox members [2]. So maybe
this is a documentation error?
Quote:
Cheers,
Stuart Celarier, Fern Creek

[1]
http://msdn.microsoft.com/library/en-us/dv_evtuv/html/etconnetcompactframewo
rkclasses.asp
Quote:
[2]
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsformsli
stboxmemberstopic.asp
Quote:


Reply With Quote
  #7  
Old   
Chris Tacke, eMVP
 
Posts: n/a

Default Re: OnClick not working in listbox - 12-03-2004 , 10:08 AM



Look at my MouseEventFilter implementation here:
http://blog.opennetcf.org/ctacke/PermaLink,guid,d20eb31b-060d-41ce-9c35-cebbe1bf554e.aspx

It will get you most of the way there.

--
<ctacke/>
www.OpenNETCF.org
Your CF searches start and end here


"Serg Kuryata [MS]" <sergeyk (AT) online (DOT) microsoft.com> wrote

Quote:
Hello Stuart,

Yes, you are right. The Click event is not supported for ListBox in the
NET Compact Framework.

Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
| From: Stuart Celarier <stuart (AT) ferncrk (DOT) NOSPAM.com
| Subject: Re: OnClick not working in listbox
| References: <#BBWAZL2EHA.3336 (AT) TK2MSFTNGP11 (DOT) phx.gbl
| Content-Type: text/plain; charset=iso-8859-1
| X-Newsreader: JetBrains Omea Reader 341.19
| Message-ID: <#HSH8pL2EHA.1300 (AT) TK2MSFTNGP14 (DOT) phx.gbl
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Date: Thu, 02 Dec 2004 14:01:31 -0800
| NNTP-Posting-Host: c-67-169-206-96.client.comcast.net 67.169.206.96
| Lines: 1
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP14
phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework :66248
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Here's a little more information: the .NET Compact Framework's Class
Library Comparison Tool [1] shows System.Windows.Forms.ListBox.OnClick is
only supported on the .NET Framework. That contradicts the .NET Framework
Class Library docs for System.Windows.Forms.ListBox members [2]. So maybe
this is a documentation error?
|
| Cheers,
| Stuart Celarier, Fern Creek
|
| [1]
http://msdn.microsoft.com/library/en-us/dv_evtuv/html/etconnetcompactframewo
rkclasses.asp
| [2]
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsformsli
stboxmemberstopic.asp
|




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.