473,461 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using Double click on data grid to open another form

I have a vb.net datagrid bound to a dataview on a windows form. I want to
use the datagrid to display and filter a list of items, but since the data
is complex, I don't want the user to edit the item using the datagrid. I'd
like to have another form display when the user double clicks the desired
row in the datagrid, and have that form display details for the selected
datagrid row.

I'm having problems figuring out the best way to pass the selected row on
the first form to the second form. All of the data (including data from
related tables,) is already populated in the underlying dataset on the first
form, so I'd like to pass the dataset also. Can anyone recommend the best
and/or easiest way to accomplish this?

Thanks!
Nov 20 '05 #1
3 11884
Cor
Hi Young,

The most easy way I is to make a module and put the variables in that.
(Those are everywhere usable, in you whole project).

I don't do it I would make a class with shared properties
Witt that I can better see what I am doing.

Rough typed and just as an example
\\\
Public Class datagridinfo
private shared mA as string
private shared mB as string
Public shared property A as string
Get
return mA
End Get
Set (byval value as string)
mA = value
End set
Public Shared property B as String
.... same as A
end Class

Now you can say in form1
datagridinfo.A = mylineInFormA

And in form1
mylineInFormB = datagridinfo.A
////

I hope this helps a little bit

Cor


Nov 20 '05 #2
Cor
Mayby confusing the last part therefore this to correct
">
Now you can say in form1
datagridinfo.A = myItemInForm1

And in form2
myItemInForm2 = datagridinfo.A
Cor
Nov 20 '05 #3
Hello Young
Here is some code that does exactly that:

Private Sub DataGrid1_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DataGrid1.DoubleClick

Dim MyGrid As DataGrid = DirectCast(sender, DataGrid)

Dim MyEdit As New UpdateAccountTypes(MyDataSet,
MyGrid.CurrentCell.RowNumber)

MyEdit.ShowDialog()

Me.DataGrid1.Refresh()

End Sub
This passes a dataset, and a row number based on the grid's
CurrentCellRowNumber

The Edit form's constructer (Sub New()) takes these two values as an
argument. Just write the code inthe form to handle your editing chores. Any
edit changes you make in the edit form will be reflected in the grid itself.
To make the changes persist, you'll have to update using the dataadapter for
that dataset.

Ibrahim
"Young J. Putt" <j.****@verizon.net> wrote in message
news:0L***************@nwrdny03.gnilink.net...
I have a vb.net datagrid bound to a dataview on a windows form. I want to
use the datagrid to display and filter a list of items, but since the data
is complex, I don't want the user to edit the item using the datagrid. I'd like to have another form display when the user double clicks the desired
row in the datagrid, and have that form display details for the selected
datagrid row.

I'm having problems figuring out the best way to pass the selected row on
the first form to the second form. All of the data (including data from
related tables,) is already populated in the underlying dataset on the first form, so I'd like to pass the dataset also. Can anyone recommend the best
and/or easiest way to accomplish this?

Thanks!

Nov 20 '05 #4

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

Similar topics

1
by: Dalan | last post by:
I probably just need a simple piece of code to do this as the couple tried so far have failed. I created a new Access 97 Form Filter (frmFilterForm) which displays most of the key data fields from...
3
by: Pete | last post by:
I'm currently doing a database that uses comboboxes to look up records in other tables, whether they be lookup tables or otherwise. When a user needs to add an item to one of these tables, the...
8
by: sara | last post by:
I am learning Access and programming. I wanted to have the user select the departments for an ad from the list of all departments. Found code (that I could understand) on this site, and it works....
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
7
by: Pam | last post by:
When I double click on a event in a form I want it to bring up another form and load the same data so it can be edited. I'm having a hard time doing this. The new form loads;but my file can't...
5
by: Nick | last post by:
Hey guys, I have 2 events on a windows forms datagrid, the mouse move as well as the double click events. What's happening is that when I double click on a row in the grid, the mouse move event...
1
by: kingster | last post by:
Hi, I have a regular dataset and all i want to do is make a pivot table display in a browser with the datasource of the pivot table to be this dataset and then the end-user will be able to do...
1
by: garry.oxnard | last post by:
Can anyone help me to solve a problem which involves switching from Access to Excel (then back to Access) programatically please? I have an Excel template which, on open, also opens an Access...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.