473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Same CurrentRow in Datagrid as before...

Hello,
I'm using a datagrid to show data (ok, what else...), and
by doubleclick on a row I first hide the Datagrid-Form
and start another form to work with the data.
After returníng to the Datagrid-Form and reload the data I
would like to jump to the same row as i was before.

To get the actual row before leave the form, I use

aktID = dvProt(Me.dgProt.CurrentRowIndex)!naqs_ID.toString
Sort = dvProt.Sort
where dgprot is the datagrid and dvprot the dataview of
the dataset.table("prot")

then
me.hide
frmEditData.showdialog

LoadDataNew() 'to load the data again from the database

and now?
to set the same sort-sequence as before,
dvprot.sort=sort is good,
but how can i find the row?
dvprot.find searches the sort-column, but sort-column and
ID must not be the same:-(

Thanks for help!

Peter

Nov 20 '05 #1
1 2143
Hello Peter,

since DataView.Find only searches the sorted columns, you could implement
the search yourself by going through the rows in the DataView. Here's a
simple example (you can improve it for your needs):

Private Function FindRow(ByVal dataView as DataView, ByVal columnName
As String, ByVal value As Object) As Integer
Dim index As Integer = 0
For Each drv As DataRowView In dataView
If drv(columnName) = value Then
Return index
End If

index += 1
Next

Return -1
End Function

This function will search the given column of the given dataView for a
value that matches what you're interested into. This assumes that your IDs
are unique else there might be more than one row that will match. The you
can user it like this:

Dim rowIndex = FindRow(myDataView, "ID", 1051)

HTH

Antoine
Microsoft Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "P Dietz" <an*******@discussions.microsoft.com>
Sender: "P Dietz" <an*******@discussions.microsoft.com>
Subject: Same CurrentRow in Datagrid as before...
Date: Tue, 21 Oct 2003 05:57:53 -0700
Lines: 31
Message-ID: <0a****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcOX0vEFL0hxaEGWSsO4gc1srb71KA==
Newsgroups: microsoft.public.dotnet.languages.vb
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:148638
NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hello,
I'm using a datagrid to show data (ok, what else...), and
by doubleclick on a row I first hide the Datagrid-Form
and start another form to work with the data.
After returníng to the Datagrid-Form and reload the data I
would like to jump to the same row as i was before.
To get the actual row before leave the form, I use
aktID = dvProt(Me.dgProt.CurrentRowIndex)!naqs_ID.toString
Sort = dvProt.Sort
where dgprot is the datagrid and dvprot the dataview of
the dataset.table("prot")
then
me.hide
frmEditData.showdialog
LoadDataNew() 'to load the data again from the database
and now?
to set the same sort-sequence as before,
dvprot.sort=sort is good,
but how can i find the row?
dvprot.find searches the sort-column, but sort-column and
ID must not be the same:-(
Thanks for help!
Peter

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Frnak McKenney | last post by:
I have a (small) multi-table database application which allows edits, print reports, and has two scrolling screen displays which show information merged from multiple tables. I'm having trouble...
11
by: Junkguy | last post by:
I need some help programmatically causing a row in a DataGrid to "flush" its contents to its bound data (in Visual Studio 6 using Windows Forms with C#). My issue is I want to send an update to...
0
by: Emerson | last post by:
The following assumes a System.Windows.Forms.DataGrid with a System.Data.DataTable set as the DataSource. I'm programming in C# Here's my scenario I click in a cell on a DataGrid. I enter some...
0
by: Just D | last post by:
Hi All, Does anybody know how to write the following code? I have a database table with a few columns including: ID , "Task" , ForceRun . I need to show the DataGrid on the ASPX page with...
8
by: Chad Z. Hower aka Kudzu | last post by:
CurrentSelectedIndex of course wont work - user can resort rows by clicking on a column title and then index of the grid won't reflect the same order as the bound data table. Currently the code...
5
by: AC | last post by:
Any reason i'm having trouble with: DataGrid1.Columns(7).ItemStyle.HorizontalAlign = HorizontalAlign.Right I'm trying to directly set the column alignment of a datagrid created at runtime.. ...
1
by: deepika | last post by:
Hi, I have a datagrid with 200 rows and an iframe adjacent to it. When I click on the row, the details of that row show up in the iframe. Now suppose I click on the 150th row, the postback occurs...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
2
by: Flack | last post by:
I have a DataGrid and a DataTable. When my form loads I create the DataTable with the appropriate columns and use it for the DataGrids.DataSource. Later on in my app, I alter the DataTable: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.