string filer

  • Thread starter Thread starter JoseLuis
  • Start date Start date
J

JoseLuis

Hi , Please help me

I'm making a table with subtables

like this 001000 States
001001 Florida
001002 CAlifornia
001003 Virginia
002000 Tax %

What I need is show it in a listbox with a filter the three first
characters is the table id and the las three is the subtableID

I try to do it but I can't please anyone can show me the code for do it


thanks
joseluis
 
Jose, could you tell me a little more about what you're trying to do? For
instance, with those values, what is it that you want to appear in the
Listbox for the user to see?
 
Jose,

This is not the exact answer, however maybe you can use it for your problem,
I made it some minutes ago for another question in the language.vb
newsgroup. For the sample with the states in a listbox and using that in an
object array are I thought thousands of samples on Internet.

When this sample beneath does not fit, remember than that you have to cast
the object in the selected arrayitem to datarowview to use it.

Cor

\\\needs a form with 2 listboxes and one textbox
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim countries() As String = {"US", "EU"}
ListBox1.Items.AddRange(countries)
Dim table As New DataTable("Sample")
CreateTable(table)
Dim dv As New DataView(table)
ListBox2.DataSource = dv
dv.Sort = "Name"
ListBox2.DisplayMember = "Name"
TextBox1.DataBindings.Add(New Binding("Text", dv, "Id"))
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender _
As Object, ByVal e As System.EventArgs) Handles
ListBox1.SelectedIndexChanged
DirectCast(ListBox2.DataSource, DataView).RowFilter = _
"Country = '" & ListBox1.SelectedItem.ToString & "'"
End Sub
Private Sub CreateTable(ByVal Table As DataTable)
Table.Columns.Add("Id")
Table.Columns.Add("Name")
Table.Columns.Add("Country")
For i As Integer = 0 To 7
Dim dr As DataRow = Table.NewRow
dr(0) = i.ToString
Table.Rows.Add(dr)
Next
Table.Rows(0)(1) = "Herfried K. Wagner"
Table.Rows(1)(1) = "Armin Zingler"
Table.Rows(2)(1) = "Ken Tucker"
Table.Rows(3)(1) = "CJ Taylor"
Table.Rows(4)(1) = "Jay B Harlow"
Table.Rows(5)(1) = "Terry Burns"
Table.Rows(6)(1) = "Tom Shelton"
Table.Rows(7)(1) = "Cor Ligthert"
Table.Rows(0)(2) = "EU"
Table.Rows(1)(2) = "EU"
Table.Rows(2)(2) = "US"
Table.Rows(3)(2) = "US"
Table.Rows(4)(2) = "US"
Table.Rows(5)(2) = "EU"
Table.Rows(6)(2) = "US"
Table.Rows(7)(2) = "EU"
End Sub
///

I hope this helps?

Cor
 
Back
Top