Just to clarify....by MDIParent I mean the MDI frame form. I have found that is a stable base to place parameters that need to be shared between forms. here is a syntax example Private Sub CustSalesOpportunityDataGridView_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles CustSalesOpportunityDataGridView.CellDoubleClick MDIParent1.SalesOppToOpen = Me.CustSalesOpportunityDataGridView.Item(0, CustSalesOpportunityDataGridView.CurrentRow.Index).Value Dim SalesOpportunity As New NewSalesOpportunity() SalesOpportunity.Show() End Sub
This should work for you too
Hansduncan
Posts
-
How to open new form from a datagridview row? -
How to open new form from a datagridview row?OK....I have just been doing the exact same thing and have it working great. Here is what you need to do: 1) Declare a public parameter as integer on the MDIParent form called something like OrderID or whatever 2) on the doubleclick event on the datagridview you need to: -Get the correct orderID from the datagridview by specifying the correct index (column) value on the currentrow. -Set the orderID parameter = ID found on the datagridview 3) on your table adapter that is called on the load event on the new form you need to pick up the MDIParent.OrderID in a parameterized fill query. Let me know if you need some example syntax? Let me know and I'll post some.
-
How to open new form from a datagridview row?Is this a case where you want to have like a list of orders and want to open the specific order on a seperate form when you doubleclick the row on the datagridview or something like that?
-
syntax error executescalarI'm getting a syntax error when debugging the code on the following line. disc1ID = CType(mycmd.ExecuteScalar(), Integer) in the below code. All the error give me to go on is syntax error. ??? Any idea what the problem could be?
Private Sub NewToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripButton.Click Dim mycmd As New SqlCommand("SELECT MAX(DiscountId) AS discID FROM(Discountstructure)", MDIParent1.Conn) mycmd.CommandType = CommandType.Text Dim disc1ID As Integer MDIParent1.Conn.Open() disc1ID = CType(mycmd.ExecuteScalar(), Integer) MDIParent1.Conn.Close() MsgBox(disc1ID.ToString) End Sub
-
Currentrow syntax issueNever mind....found the answer :)
Dim articleID As SqlParameter = myCmd.Parameters.AddWithValue("@articleID", Row.Cells("DataGridViewTextBoxColumn1").Value) 'Me.Article_searchDataGridView.CurrentRow.Index).Value) articleID.Direction = ParameterDirection.Input
-
Currentrow syntax issueI am trying to run an insert for each row on a datagridview that is selected (checkbox on 0 column index). My problem is that the @articleID parameter is not selected from the correct row. I want the to pick up the articleID from the row that is being iterated through. Looks like the currentrow syntax isn't working. Any suggestions?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim myCmd As New SqlCommand("sp_Create_NewPriceListLine", MDIParent1.Conn) myCmd.CommandType = CommandType.StoredProcedure For Each Row As DataGridViewRow In Article_searchDataGridView.Rows Dim include As DataGridViewCheckBoxCell = TryCast(Row.Cells("Select_Article"), DataGridViewCheckBoxCell) If Row.Cells("Select_Article").Value = True Then MDIParent1.Conn.Open() Dim discountID As SqlParameter = myCmd.Parameters.AddWithValue("@discountID", Me.DiscountIdTextBox1.Text) discountID.Direction = ParameterDirection.Input Dim articleID As SqlParameter = myCmd.Parameters.AddWithValue("@articleID", Me.Article_searchDataGridView.Item(7, Me.Article_searchDataGridView.CurrentRow.Index).Value) 'Me.Article_searchDataGridView.CurrentRow.Index).Value) articleID.Direction = ParameterDirection.Input Dim userID As SqlParameter = myCmd.Parameters.AddWithValue("@userID", MDIParent1.userid) userID.Direction = ParameterDirection.Input Dim myReader As SqlDataReader = myCmd.ExecuteReader() myReader.Close() MDIParent1.Conn.Close() End If myCmd.Parameters.Clear() Next End Sub
-
Need help with datagridview problem!Could someone please help me out with this problem I have been struggling with this past week? Some background info: I am trying to insert new row(s) into a datagridview called "CustSalesOpportunityLineDataGridView" (that is databound to a table called "custsalesopportunityline" in a master-detail form that contains includes the header info as well). I have also created a generic product selection form that contains a datagridview called "ArticleDataGridView" that displays all the info and contains the filters that users need to efficiently search and filter out products. The dataset for the "ArticleDataGridView" is based on a view that I have created in the database. On the "ArticleDataGridView" I have created a column called "Select_Article" that is a DataGridViewCheckBoxColumn. (false value = 0, indeterminate = 0, true =1). If the users want to add a particular product to the SalesOpportunityLine datagridview they should be able to check the checkbox for each desired row and then click the AddAndContinueButton. The Select_Article checkbox column is the leftmost column of the datagridview. For each product that they have selected in the articledatagridview a new row in the "CustSalesOpportunityLineDataGridView" should be created and displayed as well as the articleID, name and Salesopportunityheaderid. Is the code below written correctly to: Test for the checkbox.checked=true on the first column of the datagridview Write values to the "CustSalesOpportunityLineDataGridView". Nothing happens when I run the code in debug.....
Private Sub AddAndContinueButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddAndContinueButton.Click For Each dgvRow As DataGridViewRow In Me.ArticleDataGridView.SelectedRows If Me.ArticleDataGridView.Item(1, ArticleDataGridView.CurrentRow.Index).Value = 1 Then Dim dt As DataTable = Me.SalesOpportunity.Tables("custsalesopportunityline") Dim dtRow As DataRow = dt.NewRow() dtRow("Salesopportunityheaderid") = NewSalesOpportunity.SalesoppHeaderID dtRow("articleid") = dgvRow.Cells("ArticleIdDataGridViewTextBoxColumn").Value dtRow("work_articlename") = dgvRow.Cells("ProduktnavnDataGridViewTextBoxColumn").Value dt.Rows.Add(dtRow) End If Next End Sub
-
DATAGRID OF VB.NET 2003 AND 2005Along those lines, could you help me out with this code that isn't working the way I want it to. I am trying to insert new row(s) into a datagridview called "CustSalesOpportunityLineDataGridView" (that is databound to a table called "custsalesopportunityline" in a master-detail form that contains includes the header info as well). I have also created a generic product selection form that contains a datagridview called "ArticleDataGridView" that displays all the info and contains the filters that users need to efficiently search and filter out products. The dataset for the "ArticleDataGridView" is based on a view that I have created in the database. On the "ArticleDataGridView" I have created a column called "Select_Article" that is a DataGridViewCheckBoxColumn. (false value = 0, indeterminate = 0, true =1). If the users want to add a particular product to the SalesOpportunityLine datagridview they should be able to check the checkbox for each desired row and then click the AddAndContinueButton. The Select_Article checkbox column is the leftmost column of the datagridview. For each product that they have selected in the articledatagridview a new row in the "CustSalesOpportunityLineDataGridView" should be created and displayed as well as the articleID, name and Salesopportunityheaderid. Where am I going wrong with the code below? Based on the error messages I am getting I don't think it is reading from the correct column.
Private Sub AddAndContinueButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddAndContinueButton.Click For Each dgvRow As DataGridViewRow In Me.ArticleDataGridView.SelectedRows If Me.ArticleDataGridView.Item(ArticleDataGridView.CurrentRow.Index, 1).Value = 1 Then Dim dt As DataTable = Me.SalesOpportunity.Tables("custsalesopportunityline") Dim dtRow As DataRow = dt.NewRow() dtRow("Salesopportunityheaderid") = NewSalesOpportunity.SalesoppHeaderID dtRow("articleid") = dgvRow.Cells("ArticleIdDataGridViewTextBoxColumn").Value dtRow("work_articlename") = dgvRow.Cells("ProduktnavnDataGridViewTextBoxColumn").Value dt.Rows.Add(dtRow) End If Next End Sub
-
Add rows from one datagridview to anotherHi Dptalt, The last approach seems to be what I have been looking for. I'll give it a shot later today. Appreciate your help.:) best regards, Hans
-
Add rows from one datagridview to anotherI'm not sure, but I don't think what u are suggesting is quite what i am looking for. what i am looking for is the vb.net syntax for how to do something like this: dim aricleid as integer dim productname as string dim productprice as string select articleid, productname, productprice from productsearchform.datagridview where checkboxcolumn.checked=true insert into quoteline.datagridview articleidcolumn, productnamecolumn, productpricecolumn with values (get the declared values from above code) articleid, productname, productprice continue to next row until all rows on the on the productsearch datagrid that have been checked have been inserted as new rows in the quoteline datagridview. Is there a good way to do this?
-
Add rows from one datagridview to anotherI am building a windows app to that will keep track of customers, quotes, orders and so forth using VB in visual studio 2005. I have a master-detail form that contains a Quoteheader and Quoteline datagridview that where the users can add products, price, number and so forth. I have also created another form (product search) that enables users to easily filter and search for products to pick the product(s) they want to add to the quote using a checkbox that I added to each row in the grid. (The data for this datagridview is pulled from a seperate dataset based on a view that contains, among other things, the info I need to transfer to the quoteline datagridview). Specifically I want to insert a new row in the Quoteline datagridview on the Quoteform where I automatically add the following field values (articleID, price per unit and costprice) from the product search datagridview to their respective column cells on the quoteline datagridview. It should insert a new row in the qoteline datagridview for each product that is selected using the checkbox on the product search form. I would like some help and advice on how to best code this operation.