I have a readonly UltraGrid that is bound to a datasource that contains an ID column as the PK for the collection. I would like to select a specific row based upon the ID and highlight/activate it programmatically. The grid should scroll to the proper location if the selected row is not visible.
QUESTION: Is there an example of how I can do this?
I am having difficulty setting a row to active pro grammatically as well. I am trying:
For i As Int32 = 0 To ugrdSearch.Rows.Count - 1
If Convert.ToInt64(ugrdSearch.Rows(i).Cells(strColName).Value) = ImgID Then
ugrdSearch.ActiveRow = i
Exit Sub
End If
Next
But I get intellisense that "Value of type integer cannot be converted to UltraGridRow.
New to Infragistics...
Hi,
In order to investigate this, I'd need a small sample that I can run and debug which demonstrates the problem. This code snippet isn't really enough, because I don't know exactly which tables you are modifying, which row you are editing, what band it's in, etc.
I tried using your code snippet to duplicate the problem, but I don't see anything like what you describe happening in my test. The code you have here doesn't really even do anything. The DataSet you are creating isn't even used, so the only significant part is the MessageBox. I have attached my sample here so you can see if you get the same results. Or maybe you can modify the sample so that it shows the problem occurring.
I should mention, I moved the MessageBox.Show into the AfterRowActivate event (so it prompts after the new row gets selected) and then it seems to work fine. As of now this seems to take care of my issue.
Thanks for the quick reply.
It seems that if the MessageBox.Show is in the BeforeRowActivate then
this is where the issue is happening. It is prompting to save
(MessageBox.Show) before changing rows and if the user chooses
yes then it resets the dataview for the grid. At the point of
the prompt coming up, it looks as if the current row is no longer
selected.
Private Sub grdRequisitions_BeforeRowActivate(sender As Object, e As Infragistics.Win.UltraWinGrid.RowEventArgs) Handles grdRequisitions.BeforeRowActivate Try Dim dsEmail As New DataSet dsEmail.Tables.Add("dsEmailOptions") dsEmail.Tables("dsEmailOptions").Columns.Add(New DataColumn("AttachmentPath", GetType(String))) dsEmail.Tables("dsEmailOptions").Columns.Add(New DataColumn("DisplayName", GetType(String))) Dim drNew As DataRow = dsEmail.Tables("dsEmailOptions").NewRow drNew.Item("AttachmentPath") = "Path" drNew.Item("DisplayName") = "Display" dsEmail.Tables(0).Rows.Add(drNew) drNew = dsEmail.Tables("dsEmailOptions").NewRow drNew.Item("AttachmentPath") = "Path2" drNew.Item("DisplayName") = "Display2" dsEmail.Tables(0).Rows.Add(drNew) Dim dv As New DataView(dsEmail.Tables(0)) If Me.DesignMode OrElse Me.FormIsBusy Then Exit Sub Dim intanswer As DialogResult
'The line below is where the grid is seeming to lose focus intanswer = MessageBox.Show("save changes before continuing?", SuGlobal.SystemSettings.ApplicationTitle, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) If intanswer = Windows.Forms.DialogResult.Yes Then 'This would normally be where the data gets refreshed for the grid if the row has changed End If Catch ex As Exception LogError(ex, System.Reflection.MethodInfo.GetCurrentMethod().Name, "") End Try End Sub
Well, the bug I was referring to was fixed years ago, so that's not it.
Can you reproduce the issue in a small sample and post it here so we can investigate?