Wrox Programmer Forums
|
BOOK: Visual Basic 2005 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2005 Programmer's Reference by Rod Stephens; ISBN: 9780764571985
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2005 Programmer's Reference 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 April 4th, 2007, 12:36 AM
Authorized User
 
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default More on Datagridview - Edit

hi Rod,

I have some questions

1. I want to shift the focus to the next cell or a particular cell in datagridview while i press the Enter key

2. Is there any way to color the entire row (which the currenct cell is on editing) (that too was temporary, while i left the row the color become tobe its original)

3. How can i remove a particular row

for now, that's all

thanks


 
Old April 4th, 2007, 01:15 AM
Authorized User
 
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default

and one more

how can i set the color of the editing cell . whatever i set the color of the current cell is changed to white while im in edit mode

thanks

 
Old April 4th, 2007, 01:46 AM
Authorized User
 
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default

an another one

how can i trace the text (which was typed by the user) - like in textbox's textchange. all i need is i want to know the each character - the user typed.

 
Old April 4th, 2007, 08:06 AM
Authorized User
 
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default

and the last one (!?)
when i was in edit mode, while i press the ENTER the focus shift to the below cell, i want to shift it to the adjacent cell, any tips?

thanks

 
Old April 5th, 2007, 09:50 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

> 1. I want to shift the focus to the next cell or a
> particular cell in datagridview while i press the Enter key

When you are navigating in the control, intercept the KeyPress event. If the key is Return, select the next cell that you want and set e.Handled = True to tell the control not to process the Return key.

Unfortunately when you are editing a value, the DataGridView control doesn't have focus, the editing control (normally a DataGridViewTextBoxEditingControl--now that's a mouthful!) does so you cannot catch the Return key as easily. When you press Return, the editing control hides and focus moves to the next cell down.

To handle this, catch the EditingControlShowing event that occurs when the editing control is displayed and save the current row number. In the SelectionChanged event handler, restore the row if we were just editing. Here's an example:

    http://www.vb-helper.com/howto_2005_...enter_key.html

> 2. Is there any way to color the entire row
> (which the currenct cell is on editing)

In the SelectionChanged event handler, set the current row's DefaultCellStyle property. If you want it to look just like the selected cell, set BackColor to SystemColors.Highlight and set ForeColor to SystemColors.HighlightText (although then the user won't be able to tell which column is selected). Here's an example:

    http://www.vb-helper.com/howto_2005_...color_row.html

> 3. How can i remove a particular row

Try using the Rows collection's Remove or RemoveAt method. See:

    http://www.vb-helper.com/howto_2005_...elete_row.html

> how can i set the color of the editing cell.

In the EditingControlShowing event handler, set e.Control.ForeColor and e.Control.BackColor. See:

    http://www.vb-helper.com/howto_2005_...ing_color.html

> how can i trace the text (which was typed by the user)
> - like in textbox's textchange. all i need is i want to
> know the each character - the user typed.

In the EditingControlShowing event handler, add an event handler to the editing control. See this example:

    http://www.vb-helper.com/howto_2005_...t_changed.html

> when i was in edit mode, while i press the ENTER the focus
> shift to the below cell, i want to shift it to the adjacent cell, any tips?

See the earlier example:

    http://www.vb-helper.com/howto_2005_...enter_key.html



Rod
RodStephens@vb-helper.com

Check out my latest book:
"Expert One-on-One Visual Basic 2005 Design and Development"
http://www.vb-helper.com/one_on_one.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html
 
Old April 5th, 2007, 11:24 PM
Authorized User
 
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default

thanks Rod,

i ihave one more question

how can i find the caret position in a cell while editing. so that if the position is in first(0) i want to do some process.

thanks for the help


 
Old April 6th, 2007, 04:54 AM
Authorized User
 
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default

is there any to have a footer (like col-header)


 
Old April 6th, 2007, 08:28 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Sorry but I don't know how to do either of these last two. I don't think the editing control has a SelectionChanged event to tell when the caret position has changed. You could poll it with a timer but it would not be very efficient and might miss something.

I also don't think the control provides a footer, although I think you can place labels below the control and line them up when the columns resize.


Rod
RodStephens@vb-helper.com

Check out my latest book:
"Expert One-on-One Visual Basic 2005 Design and Development"
http://www.vb-helper.com/one_on_one.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html
 
Old June 24th, 2007, 11:17 PM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Rod,

   I have similarly one problem while editing a grid. I want to process data when user press UP or DOWN arrow of keyboad. We can handle Left & Right arrow through your mention EditingControlShowing events but How can we handle UP & DOWN Arrow?

Thanks in advance...
Yogesh Shah

 
Old June 29th, 2007, 11:06 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

I think the DataGridView control automatically handles up and down arrows. Try it with this example:

    http://www.vb-helper.com/howto_2005_...datatable.html


Rod
RodStephens@vb-helper.com

Check out my book:
"Expert One-on-One Visual Basic 2005 Design and Development"
http://www.vb-helper.com/one_on_one.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
datagridview help manius VB Databases Basics 1 January 27th, 2008 02:44 AM
DatagridView in C# velan C# 2005 0 June 8th, 2007 09:25 PM
DataGridView Sakkaw C# 2005 1 January 9th, 2007 12:06 PM
Need Help with datagridview maximus101 VB Databases Basics 2 September 19th, 2006 10:49 AM
datagridview ScottSheck Visual Basic 2005 Basics 0 June 14th, 2006 11:07 AM





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