0

hie
i have 3 columns in the data table.
id, name, telno.
i want to display only specific names and telno. depending on the charactes the users inputs in the text box.
this part has been taken care of.
wht i need to do now is, i want to display only name and telno. and i do not want to display id.
is this possible in dataview

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by __avd
0

Add TextBox1 and DataGridView1 Control.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dt As New DataTable
        dt.Columns.Add("No", GetType(Int32))
        dt.Columns.Add("Name")
        dt.Columns.Add("Age")

        dt.Rows.Add(1, "A", 11)
        dt.Rows.Add(2, "B", 22)
        dt.Rows.Add(3, "C", 33)
        DataGridView1.AutoGenerateColumns = False

        Dim t1 As New DataGridViewTextBoxColumn()
        t1.DataPropertyName = "Name"
        t1.HeaderText = "Name"
        DataGridView1.Columns.Add(t1)

        Dim t2 As New DataGridViewTextBoxColumn()
        t2.DataPropertyName = "Age"
        t2.HeaderText = "Age"
        DataGridView1.Columns.Add(t2)

        DataGridView1.DataSource = dt.DefaultView
    End Sub
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        CType(DataGridView1.DataSource, DataView).RowFilter = "Name like '%" & TextBox1.Text & "%'"
    End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.