|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
datagridview/delegatesEssentially, I have 2 datagridview's on 2 different forms. I want one of the datagridviews to change based on what the user clicks of the other one.. On the form which the user is clicking I have this: Private Sub dgvSkuView_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvSkuView.CellClick Dim irow As Integer Dim Skup As Integer Dim del As frmSkuData.SkuChange irow = dgvSkuView.CurrentRow.Index dgvSkuView.CurrentCell = dgvSkuView(4, irow) Skup = dgvSkuView.CurrentCell.Value del = New frmSkuData.SkuChange(AddressOf frmSkuData.ProcessSkuChange) del.Invoke(Skup) End Sub And the on the form I want to change I have this Public Delegate Sub SkuChange(ByVal value As Integer) Public Sub ProcessSkuChange(ByVal Value As Integer) Dim skut As Integer skut = Value Dim dv As New DataView Dim SQL As String = "SELECT * FROM tblSkuData WHERE sku = " & skut & ";" Dim Con As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data Source=C:\Argus\ArgusMain.mdb;") Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(SQL, Con) Dim ds As New DataSet da.Fill(ds, "skudata") dv.Table = ds.Tables("skudata") Me.dgvSkuData.DataSource = dv MsgBox(skut) End Sub The message box at the end shows the correct value, but the datagridview itself doesn't do anything.. This might be the completely wrong way to go about this... any suggestions? -- mike604 ------------------------------------------------------------------------ mike604's Profile: http://www.hightechtalks.com/m289 View this thread: http://www.hightechtalks.com/t363665 Mike,
I seldom use delegates, better almost never. Why would I. You should not try to process something as it is already done for you. That datasource will be changed at a bindingsource.endedit The only thing you need is that both the datagridviews have the same datasource and that the datagridviews are refresed when you want. Because that you want to share the datasource, is the simplest solution to make from your datasource (datatable) a shared class. I hope this helps, Cor Show quoteHide quote "mike604" <mike604.26a***@no-mx.forums.yourdomain.com.au> schreef in bericht news:mike604.26aetz@no-mx.forums.yourdomain.com.au... > > I am learning vb.net but having trouble with this....: > Essentially, I have 2 datagridview's on 2 different forms. I want one > of the datagridviews to change based on what the user clicks of the > other one.. > > On the form which the user is clicking I have this: > > Private Sub dgvSkuView_CellClick(ByVal sender As Object, ByVal e As > System.Windows.Forms.DataGridViewCellEventArgs) Handles > dgvSkuView.CellClick > Dim irow As Integer > Dim Skup As Integer > Dim del As frmSkuData.SkuChange > irow = dgvSkuView.CurrentRow.Index > dgvSkuView.CurrentCell = dgvSkuView(4, irow) > Skup = dgvSkuView.CurrentCell.Value > del = New frmSkuData.SkuChange(AddressOf > frmSkuData.ProcessSkuChange) > del.Invoke(Skup) > End Sub > > > And the on the form I want to change I have this > > Public Delegate Sub SkuChange(ByVal value As Integer) > > Public Sub ProcessSkuChange(ByVal Value As Integer) > Dim skut As Integer > skut = Value > Dim dv As New DataView > Dim SQL As String = "SELECT * FROM tblSkuData WHERE sku = " & > skut & ";" > Dim Con As OleDb.OleDbConnection = New > OleDb.OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data > Source=C:\Argus\ArgusMain.mdb;") > Dim da As OleDb.OleDbDataAdapter = New > OleDb.OleDbDataAdapter(SQL, Con) > Dim ds As New DataSet > da.Fill(ds, "skudata") > dv.Table = ds.Tables("skudata") > Me.dgvSkuData.DataSource = dv > MsgBox(skut) > > End Sub > > > The message box at the end shows the correct value, but the > datagridview itself doesn't do anything.. > > This might be the completely wrong way to go about this... any > suggestions? > > > -- > mike604 > ------------------------------------------------------------------------ > mike604's Profile: http://www.hightechtalks.com/m289 > View this thread: http://www.hightechtalks.com/t363665 > Actually Mike, if this is like an order details scenario when the details
are common to an order. IE Parent, Child record, then your best bet is to add your two tables and then create a relation between them. Bind your first table to the table and your second to the relation, this way when the first changes, the second reflects it. Show quoteHide quote "mike604" <mike604.26a***@no-mx.forums.yourdomain.com.au> wrote in message news:mike604.26aetz@no-mx.forums.yourdomain.com.au... > > I am learning vb.net but having trouble with this....: > Essentially, I have 2 datagridview's on 2 different forms. I want one > of the datagridviews to change based on what the user clicks of the > other one.. > > On the form which the user is clicking I have this: > > Private Sub dgvSkuView_CellClick(ByVal sender As Object, ByVal e As > System.Windows.Forms.DataGridViewCellEventArgs) Handles > dgvSkuView.CellClick > Dim irow As Integer > Dim Skup As Integer > Dim del As frmSkuData.SkuChange > irow = dgvSkuView.CurrentRow.Index > dgvSkuView.CurrentCell = dgvSkuView(4, irow) > Skup = dgvSkuView.CurrentCell.Value > del = New frmSkuData.SkuChange(AddressOf > frmSkuData.ProcessSkuChange) > del.Invoke(Skup) > End Sub > > > And the on the form I want to change I have this > > Public Delegate Sub SkuChange(ByVal value As Integer) > > Public Sub ProcessSkuChange(ByVal Value As Integer) > Dim skut As Integer > skut = Value > Dim dv As New DataView > Dim SQL As String = "SELECT * FROM tblSkuData WHERE sku = " & > skut & ";" > Dim Con As OleDb.OleDbConnection = New > OleDb.OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data > Source=C:\Argus\ArgusMain.mdb;") > Dim da As OleDb.OleDbDataAdapter = New > OleDb.OleDbDataAdapter(SQL, Con) > Dim ds As New DataSet > da.Fill(ds, "skudata") > dv.Table = ds.Tables("skudata") > Me.dgvSkuData.DataSource = dv > MsgBox(skut) > > End Sub > > > The message box at the end shows the correct value, but the > datagridview itself doesn't do anything.. > > This might be the completely wrong way to go about this... any > suggestions? > > > -- > mike604 > ------------------------------------------------------------------------ > mike604's Profile: http://www.hightechtalks.com/m289 > View this thread: http://www.hightechtalks.com/t363665 >
Anyone to help Newbie?
Dynamically-created menus and mdi children Nothing as a char of a string Outlook MSG file reading Copywriting or protecting your program Threading a Create Dataset method Timer fires inconsistantely VB and Mem Usage is there a way to do this How to show a form of c# in VB.Net from ? |
|||||||||||||||||||||||