Results 1 to 3 of 3

Thread: How to show record from multiple fields in table to richtextbox in VB.net 2010.

  1. #1

    Thread Starter
    Registered User
    Join Date
    Aug 2018
    Posts
    1

    Post How to show record from multiple fields in table to richtextbox in VB.net 2010.

    Dear Members

    I want to create a Dictionary English Khmer. on the form have
    1 textbox= txtText 1
    2 Listbox= lbxList
    3 Richtextbox=rtxMeaning

    in table have
    1-ID
    2-Words
    3-Type
    4-Meaning
    5-Example
    so I want to show in rtxMeaning: Type of word, meaning of word and example of word.

    Thank you
    Sambo

  2. #2
    Fanatic Member kpmc's Avatar
    Join Date
    Sep 2017
    Posts
    1,012

    Re: How to show record from multiple fields in table to richtextbox in VB.net 2010.

    Do you have no code to show at all?

    Looking at your post, there isn't even a question...

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: How to show record from multiple fields in table to richtextbox in VB.net 2010.

    Using a DataTable with an Expression column, you can create a searching TextBox which shows any output in a RichTextBox. This is a barebones solution, but it demonstrates the method in a short example...

    Code:
    Public Class Form1
    
        Dim dt As DataTable
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            dt = New DataTable
            dt.Columns.Add("ID", GetType(Integer))
            dt.Columns.Add("Word")
            dt.Columns.Add("Type")
            dt.Columns.Add("Meaning")
            dt.Columns.Add("Example")
            dt.Columns.Add("Output")
    
            dt.Columns("Output").Expression = "'Type of word: ' + Type + '" & Environment.NewLine & Environment.NewLine & _
                                                "' + 'Meaning: ' + Meaning + '" & Environment.NewLine & Environment.NewLine & _
                                                "' + 'Example: ' + Example"
    
            dt.Rows.Add(0, "house", "noun", "A building for human habitation", "Many people own and live in a house")
            dt.Rows.Add(1, "dog", "noun", "A domesticated carnivorous mammal probably descended from the wolf", "The domesticated dog is a common pet in the western world")
    
        End Sub
    
        Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
            Dim dv As New DataView(dt, "Word = '" + TextBox1.Text + "'", "", DataViewRowState.CurrentRows)
            If dv.Count > 0 Then
                RichTextBox1.Text = dv.Item(0).Item("Output").ToString
            Else
                RichTextBox1.Text = ""
            End If
        End Sub
    
    End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width