Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On Double click, passing a value from Datagrid to my class

Status
Not open for further replies.

nondrinker

Programmer
Jan 23, 2002
53
US
Hello,

I have a datagrid populated with records, with OrderID being the left most column.
On the Double click event, I am trying to pass the value of the selected orderID to a class. In that class i have my SQL query which i am building based on the orderid passed from the datagrid.

On the double click event, i have this code and in the message box i do see the correct orderid, for each row:
******************************
varOrderid = grdRecordsListing.Item(grdRecordsListing.CurrentRowIndex, 0)
MsgBox(varOrderid)
*******************************
But i am trying to pass this variable, "varOrderid" to my class, by double clicking on a specific datagrid row.

Any suggestions?
Thank you.


 
To your class?
I assume that you have created a class (.vb file) and you want to pass it there.

If you have a constructor, you only do:
dim mc as new myclassmane(varOrderid)

Class example..
Code:
public class myclassname
  private passedvariable as string

  public sub new(passed_argument as string)
    passedvariable=passed_argument
  end sub

end class

If you don't:
dim mc as new myclassmane()
mc.something=varOrderid
 
Hello,

First let me tell you that this is the first time for me to work on a vb.NET project, or even on an OO based project for that matter.

In my vb.NET project currently i have 2 forms and one class file. Form1 (that has the datagrid on it), form2 and my class (MainOrder.vb). What i am trying to achieve here is that when the user double clicks on an order row (datagrid on form1), a second form should open up with the fields populated on it with the details of that order.

The way i have currently set it up is, or trying to set it up is, that the value of the OrderID clicked on the datagrid (on Form1), should be passed on to my class (MainOrder.vb) where i am building a SQL query based on the orderID passed. After i have retrieved all the associated values for that OrderID with that query then i'll assign them to variables in that class (which will become the properties of that class).

Eventually i want to be able to use the same class by instantiating it on different forms (form3, form4..), and then just retrieve the relevant properties of that object to be displayed on that form only.

I do have a constructor in my class and my SQL query is also in that constructor, so that i can retrieve the values from the database and assign them to variables.

Like i said this is my project, so i am not sure if this is the best or most effecient way of doing things or not.

Any help will be appreciated.
Thanks.



 
Noondrinker:

Try looking up datarelation, specifically the constructor.

Hope this helps.

Ron

Ron Repp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top