Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2004

Tip: Looking for answers? Try searching our database.

AcceptsReturn For a listView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mat - 21 Jul 2004 11:38 GMT
Hello!

Okay, I have a ListView (contained inside a USerControl) on a form
with an accept button. However, I want something to happen when the
User hits Enter/Return with focus on the ListView. Problem is this
doesn't work when an accept button is set for the form.

The TextBox has a AcceptsReturn property but Listviews do not. Does
anyone know
how I can acheive similer functionality.

Catching the KeyDown in a subclassed Listview does not work.
Neither does OnKeyDown...

any ideas would be gratefully recieved :-)

thanks,

mat
Claes Bergefall - 22 Jul 2004 09:59 GMT
So don't set the AcceptButton property then!
Or turn it off when the ListView gets focus
(and back on when it looses focus)

   /claes

> Hello!
>
[quoted text clipped - 15 lines]
>
> mat
mat - 22 Jul 2004 16:40 GMT
Not a very clever response that really, is it?!

Obviously I want the functionality of the AcceptButton!

I have figured it out now anyway:

I implemented an AcceptsReturn property in a subclassed ListView.
I then overrode the ProcessDialogKey:

protected override bool ProcessDialogKey(System.Windows.Forms.Keys keyData)
{
    if(keyData == Keys.Enter && this.AcceptsReturn)
        keyData = 0;

    return base.ProcessDialogKey(keyData);
}

I can then pick up the Return Button from a listView using the old KeyDown event!

Fantastic eh?

mat

> So don't set the AcceptButton property then!
> Or turn it off when the ListView gets focus
[quoted text clipped - 21 lines]
> >
> > mat
Claes Bergefall - 23 Jul 2004 08:12 GMT
> Not a very clever response that really, is it?!

Actually, the second part should work (turn it of when the
listview gets focus and turn it back on when it looses it)

   /claes
mat holton - 23 Jul 2004 10:09 GMT
>Actually, the second part should work (turn it of when the
>listview gets focus and turn it back on when it looses it)

Yeah, you are right, sorry about my flippent reply. Unfortunatly your
proposed method would have to be implemented for all uses of a listview,
whilst my method only need to be done once!

Thanks for the help anyway!

mat

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.