473,835 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

selecting a row in vb.Net 2005 datagridview

28 New Member
hello,
I have a datagridview on my form that is populated with thousands of records from a database. When I add a new product, I want the new product to be the one selected. I've tried aot of different things and cant seem to achieve this. The following HIGHLIGHTS the new row but not SELECT it.The first row is still selected (the little arrow cursor in the row header) is set on the first record. The DGV imulti select property is set to true for multiple edit.


[code]

Private Sub setSelectedRow( ByVal data As DataGridView)


Try
Dim counter As Integer = 1
data.ClearSelec tion()

For counter = 1 To data.Rows.Count

If data.Rows(count er - 1).Cells(colNam e).Value.ToStri ng.Trim = colValue Then
data.Rows(count er - 1).Cells(1).Sel ected = True
data.Rows.Item( counter - 1).Selected = True
Exit For
End If
Next

'Scroll to the selected row in case it was hidden.
data.FirstDispl ayedScrollingRo wIndex = counter - 1

Catch ex As Exception
MsgBox("set row error " & ex.Message)
End Try


[code]


Any help is deeply appreciated. Thanks in advance
Aug 18 '08 #1
0 1026

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5619
by: Arvind | last post by:
Hi I edit a cell in a DataGridView, and then would move to another cell in the DataGridView using mouse. Then the DataGridView as of now does scroll down to the last visited cell. But when I try to edit the same last visited cell, focus gets shifted to the first few visible rows as per the dimensions set for the DataGridView. To be exact it goes to the cell in the first row, and the same column. If I can say it this way, I would like...
3
2948
by: David | last post by:
I'm creating a C# (.NET BETA2) Windows application (NOT a Web application, a Windows application), and I would like to programmatically selecting a row inside of a DataGridView. It seems like it should be pretty easy to do, but I'm have a hard time with this. Can anyone give me any guidance? Thanks, David
4
10237
by: dm1608 | last post by:
Hello, I have a DataGridView control in VB.NET 2005 that I would like to iterate thru row by row and parse out the individual columns into variables. Can someone provide me example code or direct me to a document that shows how this can be done? Thank you
2
15170
by: Bob | last post by:
How do I show a calendar control or another appropriate control to pick a date and time for a cell in a column in a datagridview? Thanks for any help. Bob
1
3847
by: ken | last post by:
Hi, Lets say we have a form that displays time card entries based on the calendar control date on the form. So the user clicks on a date and the form filters the table where the time card entries come from to get you proper data. In access I would just filter the query(rewrite its qrydef) and I'd get my answer. My question is, what is the proper way of doing this in ADP and SQL Server 2005. I could filter the data from the view on the...
1
1956
by: romerve | last post by:
Hello, I am interested on how to edit/view an item or record selected from a DataGridView. The SQL queries for some data including the ID which is not visible on the GridView. I want to be able to click on the on a record from the DataGridView then click the View Item and a form come up with information related to that item. The View form with execute a query which will have the (Select ..... Where ID="selectedItem.From.DataGridView")
3
8542
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to add a datagridview control to a Windows Form to display read-only information in visual basic 2005. My understanding is that datareader will be faster for this purpose. I have the following questions: 1. Can DataReader be bound DIRECTLY to DataGridView? 2. If DataReader cannot be bound directly to DataGridView, how can I load a DataReader into a DataTable and bind the DataTable to DataGridView? Can the DataTable be a...
2
1476
by: Dom | last post by:
I posted this before, no takers. Trying again. Is there anyway to cancel the selection of a new cell in a DataGridView? For example, if the user selects a cell with the control key down, then I don't want the selection to change. Dom
4
1906
by: techno58 | last post by:
In my form i want to be able to fill all my controls with a particular record by selecting that record from my datagridview.If i select a particular record after clicking on it all my controls like textbox etc will be filled with that specific record. Can i do this without using binding context?
0
9803
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9652
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10811
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10523
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10560
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5636
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5804
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.