Find the index of new row

melody

New member
Joined
Dec 15, 2004
Messages
4
Programming Experience
1-3
Hello,

I posted already a thread about this but i need some more help please.

On a windows form the user enters data in textboxes and when press the button save they are saved and shown on the datagrid which exists also on the form. What i need is that new row entered to be selected as soon as entered in the datagrid. How can i know the index of the new row, when the datagrid is sorted and then i know that i will use the .Select() method of the grid.

thanks in advance!!!
 
Just add on to the post you already made if you need more help...
DId you read my reply to your first post?

TPM
 
no because i couldn't use the key. I didn't understand what you mean.

Here it is again:

on a form the user enters the data in textboxes and when press Save button they are saved and shown in the datagrid which is also on the same form. What i need is the new row entered to be the selected one in the datagrid. How can i do that when the rows are sorted? I don;t know the exact possition so that i can use the .Select() method.

thanks.
 
i have a AddDateSet() Function a a DataAdapter Class ...

VB.NET:
Public Function SetSQL_tblUser(Optional ByVal SQL_where As String = "", Optional ByVal selFields As String = "") As String
		Dim str As String
		Dim strSQL As String
		If selFields = "" Then
			str = "*"
		Else
			str = " Distinct " + selFields
		End If
		strSQL = "Select " & str & " from tbl_PURCHASE "
		strSQL = strSQL + SQL_where
		SetSQL_tblUser = Trim(strSQL) 'Return
	End Function
VB.NET:
Public Function AddDataSet(ByVal strSQL As String, ByVal arrData() As String, ByVal intTotalNumberOfFields As Integer) As Boolean

		Try 'Initialize DataAdapter with SQL and connection string
			SetConnectString()
			mobjDA = New OleDb.OleDbDataAdapter(strSQL, strConnect)
			mobjCB = New OleDb.OleDbCommandBuilder(mobjDA)

			objDS.Clear()
			mobjDA.Fill(objDS)

			'Add new record to local memory

			objRow = objDS.Tables(0).NewRow

			For i = 0 To intTotalNumberOfFields
				objRow(i) = arrData(i)
			Next i

			objDS.Tables(0).Rows.Add(objRow)


			mobjDA.Update(objDS)
			AddDataSet = True

		Catch ex As Exception

			str = "Error in AddDataSet. Error No. " & Err.Number & " : " & Err.Description
			GetErrorMessage(str)

			AddDataSet = False
			Exit Function

		End Try

	End Function


how can i insert data into two table at once ????
 
Back
Top