Guys,
In the sub below I am adding a new row to a datagrid on screen. Instead of showing the msgbox at the end of the code, I would like to ensure that the row just added has focus and is visible on screen. This row is always added at the bottom, and sometimes this is off screen if I already have 20 rows in the grid. How can I ensure that the row added is focused and scrolled to if required ?
Thanks
Bob
VB Code:
Friend Sub AddDirectoryItem(ByVal item As cls_icontact) Dim row As DataRow If displaytype = ContractDirectoryDisplay.Staff Then Dim dt As DataTable = CType(dg_contacts.DataSource, DataTable) For Each row In dt.Rows If row.RowState = DataRowState.Deleted Then ElseIf row("id") = item.row("id") Then MsgBox("User is already assigned !", MsgBoxStyle.Information, "Duplicate Item") dt.Dispose() dt = Nothing Return End If Next dt.Dispose() dt = Nothing End If row = CType(dg_contacts.DataSource, DataTable).NewRow row.ItemArray = item.row.ItemArray row("Contract") = CurrentContract.ID If displaytype <> ContractDirectoryDisplay.Staff Then row("ContactPhone") = item.row("Phone") row("ContactFax") = item.row("Fax") End If mdtContacts.Rows.Add(row) MsgBox("New Contact assigned !", MsgBoxStyle.Information, "Assigned") End Sub




Reply With Quote