|
-
Jul 24th, 2004, 04:16 AM
#1
Thread Starter
Junior Member
double click on datagrid
Hi there,
I m a beginner in VB.Net.
I have created a form with a datagrid. What i would like to do is double click on a row within the datagrid to open another form displaying the contents of that record to the textbox.
What is the coding in the datagrid_double click even ??
any help or examples appreciated
Thanks,
viv
-
Jul 24th, 2004, 04:46 AM
#2
this one maybe could help you
VB Code:
Private Sub DataGrid1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.DoubleClick
TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, DataGrid1.CurrentCell.ColumnNumber)
End Sub
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
DataGrid1.Select(DataGrid1.CurrentCell.RowNumber)
End Sub
-
Jul 24th, 2004, 11:05 PM
#3
Thread Starter
Junior Member
Mar_zim,
thank you very much for your quick reply.
I am facing 2 problems now.
1. if I selected <ALL> from the cboCustomer and click search button, all sorted records display. BUT when I double click on the first record on that grid, the records is not fill into the textbox in Form1. This only happen in first record on that grid , other records are working fine.
2. if I selected any alphabet instead of <ALL> from the cboCustomer and click search button, the records display is ok. BUT when I double click on the specific record on that grid, is not the selected record will fill into the textbox in Form1.
Here¡¯s the code :
In Form1
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim Search As New frmCustSearch
Search.DataSource = DataSet11
Search.DataMember = DataSet11.Customers.TableName
Search.CM = Me.BindingContext(DataSet11, DataSet11.Customers.TableName)
Search.ShowDialog()
End Sub
In Form2(frnCustSearch)
Private Sub frmCustSearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dvCustomer = New DataView(Me.DataSet11.Tables("Customers"), "CustLName like '%'", "", DataViewRowState.OriginalRows)
cboCustomer.Items.AddRange(New Object() {"<ALL>", "A", "B", "C", "D", "E", "F", "G", _
"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"})
cboCustomer.Text = "<ALL>"
Me.SqlDataAdapter1.Fill(Me.DataSet11.Customers)
End Sub
Private Sub DataGrid1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.DoubleClick
Dim CM1 As CurrencyManager = CType(Me.BindingContext(Me.DataGrid1.DataSource, Me.DataGrid1.DataMember), CurrencyManager)
If CM1.Position > -1 Then
Me._CM.Position = CM1.Position
Me.DialogResult = DialogResult.OK
End If
End Sub
Thank again,
viv
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|