vellaima Posted February 6, 2003 Posted February 6, 2003 Dim dr() As DataRow Dim i As Integer dr = SalesRep1.Tables("sales_representative").Select("ID = '" + searchtxt.Text + "'") For i = 0 To UBound(dr) MsgBox((dr(i)("Name"))) Next In the above program if the user enters the sales_representative id it will search the SalesRep1 DataSet and display the name of the Sales Representative in Message Box. This is what I have done. It works perfectly. I am displaying the Sales Representative Details in the DataGrid in form1 . There is also a search button in the bottom of the form1. Once the search button is clicked the above program gets triggered. If the Sales_representative ID is available in the DataSet then I would like to highlight the details of the particular row in DataGrid say in red color. Can we achieve this. Quote
*Experts* Nerseus Posted February 6, 2003 *Experts* Posted February 6, 2003 You may have to do manually looping to do this. You could try something like: Dim i As Long For i = 0 To SalesRep1.Tables("sales_representative").Rows.Count - 1 If (SalesRep1.Tables("sales_representative").Rows(i)("ID").ToSTring() = searchtxt.Text) Then gridControl1.Select(i) End If Next I'm not sure how you select a row in the grid offhand, but I think it's just Select (might be SelectRow?). -nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
vellaima Posted February 11, 2003 Author Posted February 11, 2003 Thanks for providing me with this code. It worked perfectly. I also added another line. If (SalesRep1.Tables("sales_representative").Rows(i)("ID").ToSTring() = searchtxt.Text) Then gridControl1.currentRowIndex(i) gridControl1.Select(i) End If I have one query though. Whenever i enter the "id" to search it is not deselecting the previous one. How can we avoid multiple selection in grid. Can anyone please tell me how to resolve this. It will be very helpful. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.