Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 5th, 2004, 11:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default DataGrid & Keyboard

Hi there:
I wanna assign some shortcut keys in my grid, but it doesnt fire! How can I make a shortcut in DataGrid?!

Always:),
Hovik Melkomian.
__________________
Always,
Hovik Melkomian.
 
Old September 6th, 2004, 01:02 AM
Kep Kep is offline
Authorized User
 
Join Date: Aug 2003
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How do you assign the shortcut to the grid?
What does the shortcut have to do?
Is the shortcut defined at design time or run-time?

I'm not sure what you're trying to do.


Kep.
 
Old September 7th, 2004, 12:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Acctually I set it in Form_KeyDown as:
Code:
private void MorDeliver_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
    switch(e.KeyCode)
    {
        case Keys.Escape:
            DO_SOME_THING
            break;
        case Keys.F2 ://Save
            DO_SOME_THING
            break;
        case Keys.F3://Edit ...


& set for all conrols as well, but in grid even I can contol press_Key or any.
Any IDEA?!?!

Always:),
Hovik Melkomian.
 
Old September 7th, 2004, 09:33 PM
Authorized User
 
Join Date: Jul 2004
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
Default

What I believe is happening to you is that the textbox that is in the current cell is catching the event for the keypress and not the DataGrid. Try the OnCellChange event for the datagrid, clear the controls for the CurrentCell, and add a new Textbox that Fills the cell. Then add a KeyDown event to the new textbox and handle it. Sounds kinda complicated, but I betcha it would work. You can also use this technique to add a dropdownlist to a datagrid. If you need more info just ask. :)

Hope this helps

www.CoderForRent.com
Get A Computer Job!
 
Old September 8th, 2004, 12:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Ok I got it! but as u said its complicated! Anyway...
Yes sure I'll be glad if u tell me about Combobox on DataGrid:)

Looking to hear from u ASAP.

Always:),
Hovik Melkomian.
 
Old September 13th, 2004, 06:46 PM
Authorized User
 
Join Date: Jul 2004
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
Default

Basically it is the same principle.

On the cellchanged event:

1. Clear the controls in the Current cell.
2. Create a new DropDownList.
3. Populate the DropDownList from the database with the options.
4. Set the OnChange EventHandler
5. Add it to the CurrentCell Control library

On the OnChange Event:
1. Use the CurrentCell.Row (May be DataGrid.CurrentRow, can't remember off the top of my head).
2. Update the DataTable/DataSet that is associated with the row with the selected info from the drop down list.

NOTE: You must make sure that the datagrid is not ordered by a non-default field or when the selection is made you will update the wrong record in the DataTable.

I found this to be a pretty good article: http://www.codeproject.com/cs/miscctrl/DataGridZen.asp

Hope this helps,


www.CoderForRent.com
Get A Computer Job!
 
Old September 15th, 2004, 12:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

tnx dear, let me work on ;)

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
WebPart & DataGrid AlexGetman SharePoint Development 1 June 12th, 2006 11:29 AM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM
Capturing Keyup & KeyDown in a Datagrid SupaHoopsa General .NET 3 October 11th, 2004 03:40 PM
Looking for Datagrid Cols&Columns reyboy Pro VB.NET 2002/2003 1 May 25th, 2004 08:12 AM
Problem with DataGrid & JavaScript qadeer05 Classic ASP Basics 2 April 19th, 2004 10:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.