Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > BOOK: Visual Basic 2005 Programmer's Reference
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 4th, 2007, 01:36 AM
Authorized User
Points: 208, Level: 4
Points: 208, Level: 4 Points: 208, Level: 4 Points: 208, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
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


Reply With Quote
  #2 (permalink)  
Old April 4th, 2007, 02:15 AM
Authorized User
Points: 208, Level: 4
Points: 208, Level: 4 Points: 208, Level: 4 Points: 208, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
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

Reply With Quote
  #3 (permalink)  
Old April 4th, 2007, 02:46 AM
Authorized User
Points: 208, Level: 4
Points: 208, Level: 4 Points: 208, Level: 4 Points: 208, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
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.

Reply With Quote
  #4 (permalink)  
Old April 4th, 2007, 09:06 AM
Authorized User
Points: 208, Level: 4
Points: 208, Level: 4 Points: 208, Level: 4 Points: 208, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
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

Reply With Quote
  #5 (permalink)  
Old April 5th, 2007, 10:50 AM
Rod Stephens's Avatar
Wrox Author
Points: 2,999, Level: 22
Points: 2,999, Level: 22 Points: 2,999, Level: 22 Points: 2,999, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 601
Thanks: 1
Thanked 84 Times in 83 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
Reply With Quote
  #6 (permalink)  
Old April 6th, 2007, 12:24 AM
Authorized User
Points: 208, Level: 4
Points: 208, Level: 4 Points: 208, Level: 4 Points: 208, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
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


Reply With Quote
  #7 (permalink)  
Old April 6th, 2007, 05:54 AM
Authorized User
Points: 208, Level: 4
Points: 208, Level: 4 Points: 208, Level: 4 Points: 208, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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


Reply With Quote
  #8 (permalink)  
Old April 6th, 2007, 09:28 AM
Rod Stephens's Avatar
Wrox Author
Points: 2,999, Level: 22
Points: 2,999, Level: 22 Points: 2,999, Level: 22 Points: 2,999, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 601
Thanks: 1
Thanked 84 Times in 83 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
Reply With Quote
  #9 (permalink)  
Old June 25th, 2007, 12:17 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
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

Reply With Quote
  #10 (permalink)  
Old June 29th, 2007, 12:06 PM
Rod Stephens's Avatar
Wrox Author
Points: 2,999, Level: 22
Points: 2,999, Level: 22 Points: 2,999, Level: 22 Points: 2,999, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 601
Thanks: 1
Thanked 84 Times in 83 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
Reply With Quote
Reply


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 10: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 11:49 AM
datagridview ScottSheck Visual Basic 2005 Basics 0 June 14th, 2006 12:07 PM



All times are GMT -4. The time now is 07:40 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.