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!!!
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Just add on to the post you already made if you need more help...
DId you read my reply to your first post?

TPM
 

melody

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

yes I've read it. I am new here so forgive any mstakes.
Please can you help me with the issue?

thanks.
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Did you try it?
 

melody

New member
Joined
Dec 15, 2004
Messages
4
Programming Experience
1-3
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.
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
A key is a unique value.
 

rex028

Well-known member
Joined
Nov 18, 2004
Messages
50
Programming Experience
Beginner
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 ????
 
Top Bottom