Click here to Skip to main content
13,792,811 members
Rate this:
Please Sign up or sign in to vote.
See more:
th line of codeI have a DataGridView constructed of selected data from my database. Because of size constraints I have truncated 2 of the columns. When I click on one of the cells in the columns a textbox opens and is supposed to display the complete text in that field. When I do click on the cell the textbox opens, but the text is displayed across the top of the box and nothing in the body. If I press enter or the spacebar the text then appears in the body of the box.
How can I have the text appear in the box when it opens?
I have attached the cell-click subroutine and the textbox routine.

I have also tried the ToolTip tool and it works, but there are two problems. I would like to be able to control the window appearance similar to the CellClick code(the window size, and color, and the font type and size) and have it stay active until released with a close button.
(Basic code attached)

What I have tried:

CellClick Code

Private Sub grdViewMovies_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles grdViewMovies.CellClick
        Dim value As Object = grdViewMovies.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
        Dim colNumb As String = grdViewMovies.CurrentCell.ColumnIndex.ToString

        'Make sure only information in columns 1 or 2 is displayed.

        If colNumb = 1 or colNumb = 2 Then

            'If there is no data in the cell

            If IsDBNull(value) Then
                MessageBox.Show("NO DATA IN THIS CELL", " NOTHING HERE", MessageBoxButtons.OK, MessageBoxIcon.Information)
            ElseIf colNumb = "0" Then
                Form1.again = False
                Exit Sub
            Else         'Open sayitForm and display the text that is in the cell
                displayText = CType(value, String)
                Using sayitForm As New INFORMATION
                    sayitForm.Text = displayText
                End Using
            End If
        End If
    End Sub

    Private Sub closeBtn_Click(sender As Object, e As EventArgs) Handles closeBtn.Click

    End Sub
End ClassPublic Class INFORMATION

    Private Sub txtSayit_TextChanged(sender As Object, e As EventArgs) Handles txtSayit.TextChanged
        txtSayit.Text = SQLForm.displayText
    End Sub

End Class

ToolTip Code

Private Sub grdViewMovies_CellMouseEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles grdViewMovies.CellMouseEnter

        Dim myRow As Integer = e.RowIndex
        Dim myCol As Integer = e.ColumnIndex

        If myCol = 1 Or myCol = 2 And myRow > 0 Then
            Me.grdViewMovies.Rows(myRow).Cells(myCol).ToolTipText = Me.grdViewMovies.Rows(myRow).Cells(myCol).Value
        End If

    End Sub
Posted 1-Jan-18 9:36am
Updated 3-Jan-18 7:31am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.181207.3 | Last Updated 3 Jan 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100