Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • *Experts*
Posted

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

"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
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...