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 / March 2007

Tip: Looking for answers? Try searching our database.

DataGridView - catching a delete key in a Calendar cell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard Lewis Haggard - 23 Mar 2007 17:55 GMT
How would one catch a delete key, backspace key, control X or other
indication that a user wants to delete the contents of a cell?

I used the example code in MSDN's "How to: Host Controls in Windows Forms
DataGridView Cells" as the basis for a GridDate column, I've created a
column that hosts a calendar control. However, there are times when this
cell must have no date specified and I do that by displaying a blank cell.
So far so good. What I can't figure out is how to go from some value to no
value. What if my user wants to get rid of the entered cell value? I can't
quite seem to figure out how to catch a delete key, backspace or control X
event on this cell. Any suggestions would be appreciated.
Signature

Richard Lewis Haggard
www.Haggard-And-Associates.com

ClayB - 23 Mar 2007 22:30 GMT
You might try the grid's PreviewKeyDown event. This code was hit for
me in that sample when Delete was pressed on a non-editing cell.

void dataGridView1_PreviewKeyDown(object sender,
PreviewKeyDownEventArgs e)
   {
       if (e.KeyCode == Keys.Delete)
       {
           this.dataGridView1.CurrentCell.Value = null;
       }
   }
==================
Clay Burch
Syncfusion, Inc.

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.