|
-
Apr 8th, 2003, 05:44 PM
#1
Thread Starter
Addicted Member
Search Functionaltiy w/ Datagrid
I have a search screen, which is bound to a datatable. I also have a found dialog box, and when the user puts in a value, I want to search the grid and set focus to that row if the search criteria is found. Any ideas on how 2 do this?
-
Apr 8th, 2003, 05:48 PM
#2
Hyperactive Member
I'm still trying to figure out the doubleclick on the datagrid row and get my cell data back
-
Apr 8th, 2003, 05:59 PM
#3
PowerPoster
I'm still trying to figure out the doubleclick on the datagrid row and get my cell data back
Use the current property of the CurrencyManager()
The code is in C#, but if you need me to convert it, let me know...
Code:
private void dataGrid1_DoubleClick(object sender, System.EventArgs e)
{
DataRowView row = (DataRowView) this.BindingContext[dataGrid1.DataSource].Current;
MessageBox.Show(row[0].ToString());
}
-
Apr 8th, 2003, 06:16 PM
#4
PowerPoster
2 smooth...
Code:
private void button1_Click(object sender, System.EventArgs e)
{
DataView view = new DataView(ds.Tables["Orders"]);
view.Sort = "OrderID";
int rowIndex = view.Find(txtSearch.Text);
if(rowIndex != -1) {
this.BindingContext[ds.Tables[0]].Position = rowIndex;
}
else {
MessageBox.Show("Record not found!");
}
}
-
Apr 9th, 2003, 01:26 AM
#5
Frenzied Member
Lethal,
Its not the matter of how to retrive the data from the current cell. Its the problem that Datgarid DoubleClick event is not fired when you click inside a cell, cause the underlying cell gets the click, not the datagrid object. If you click on the cell bounds then its fired. So any answer to the datagrid cell doubleclick should be initialized by the cell itself.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 9th, 2003, 02:31 AM
#6
Frenzied Member
This might help you gollnick:
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim tb As New DataTable("testTBL")
Dim clm As New DataColumn("testCLM", GetType(String))
tb.Columns.Add(clm)
Dim tbs As New DataGridTableStyle()
Dim dgc As New dgcell()
dgc.MappingName = "testCLM"
tbs.MappingName = "testTBL"
tbs.GridColumnStyles.Add(dgc)
DataGrid1.TableStyles.Add(tbs)
DataGrid1.DataSource = tb
End Sub
End Class
Public Class dgcell
Inherits DataGridTextBoxColumn
Public Sub New()
MyBase.New()
AddHandler Me.TextBox.DoubleClick, New System.EventHandler(AddressOf testdbclick)
End Sub
Private Sub testdbclick(ByVal sender As Object, ByVal e As System.EventArgs)
MessageBox.Show(Me.TextBox.Text)
End Sub
End Class
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Apr 9th, 2003, 10:42 AM
#7
Hyperactive Member
Thanks .. I did .. I copied in the code and tried to modify it but with no luck.. I'm a "visual" learner .. Once I see it work.. I never forget it.... This double click thing should not be this hard...
But .. thanks again
-
Apr 9th, 2003, 01:24 PM
#8
Frenzied Member
I just started using the datagrid, someone want to take the time to explain this code?
thanks
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim tb As New DataTable("testTBL")
Dim clm As New DataColumn("testCLM", GetType(String))
tb.Columns.Add(clm)
Dim tbs As New DataGridTableStyle()
Dim dgc As New dgcell()
dgc.MappingName = "testCLM"
tbs.MappingName = "testTBL"
tbs.GridColumnStyles.Add(dgc)
DataGrid1.TableStyles.Add(tbs)
DataGrid1.DataSource = tb
End Sub
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
|