I suspect that your problem is because you're setting the .Text property of the TextBox of one Form from a different Form. That's typically not a good way to handle this sort of scenario (using custom events would be preferable).
But, that said, you can probably have the behavior you want by calling the Application.DoEvents() method after setting the .Text property.
~~Bonnie
>Hi, Bonnie,
>
>In Mdi
> Dim frm As New Form1
> frm.MdiParent = Me
> frm.Show()
>
>
>In form 1
>
>Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
> If e.KeyChar = Convert.ToChar(13) Then
> If conn.State = ConnectionState.Open Then conn.Close()
> conn.Open()
> Dim frmdgvsearch As New form2
> cmd = New SqlCommand("select coll_short_name,coll_id from collegeinfo order by coll_short_name", conn)
> da = New SqlDataAdapter
> da.SelectCommand = cmd
> ds = New Data.DataSet
> da.Fill(ds, "collegeinfo")
>
> frmdgvsearch.DataGridView1.DataSource = ds.Tables("collegeinfo")
> frmdgvsearch.DataGridView1.Columns(0).HeaderText = UCase(frmdgvsearch.DataGridView1.Columns(0).HeaderText)
> frmdgvsearch.DataGridView1.Columns(0).Width = 250 'Len(UCase(frmdgvsearch.DataGridView1.Columns(1).HeaderText))
> frmdgvsearch.DataGridView1.Columns(1).HeaderText = UCase(frmdgvsearch.DataGridView1.Columns(1).HeaderText)
> frmdgvsearch.DataGridView1.Columns(1).Width = 130
> frmdgvsearch.DataGridView1.AdjustedTopLeftHeaderBorderStyle.Right = DataGridViewAdvancedCellBorderStyle.Outset
> frmdgvsearch.DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
> frmdgvsearch.ShowInTaskbar = False
> frmdgvsearch.MdiParent = Me.MdiParent
> frmdgvsearch.Show()
> conn.Close()
> End If
>
> End Sub
>
>
>In form2
>
>Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
> Try
>
> If e.KeyCode = Keys.Enter Then
> Form1.TextBox1.Text = (DataGridView1.Item(0, DataGridView1.CurrentRow.Index).Value)
>
> Me.Close()
>
> End If
>
>
>
> If e.KeyCode = Keys.Escape Then
> Me.Close()
> End If
> '----------------------------------------------------------------------------------
> Catch ex As Exception
> MsgBox(ex.Message)
> End Try
>
> End Sub