Sathya Narayan

Sathya Narayan

  • NA
  • 155
  • 65.5k

Binding Values From ListView To Textbox and Combobox

Jun 25 2014 3:22 AM
Hi,

I am Loading the values from listview to textbox and combobox,it has just loading for textbox and which has not been loading to combobox.This is what the code, i am using to implement.

Filling To List View
 Public Sub FillList()
        sSql = "SELECT pname as ' Product',rate as 'Rate',ProductGroup as 'Product Group',Vatt as 'Vat',Unit as 'Unit',slno from Product_View where stu='A'"

        With ListView1
            .Clear()
            .View = View.Details
            .FullRowSelect = True
            .GridLines = True

            .Columns.Add("Product Name", 150)
            .Columns.Add("Rate", 50)
            .Columns.Add("Product Group", 150)
            .Columns.Add("Vat", 50)
            .Columns.Add("Unit", 50)
            .Columns.Add("SLNO", 60)
            FillListView(ListView1, GetData(sSql))
        End With
    End Sub

Fetching The Values To ListView to Textbox and Combobox

  Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        If ListView1.SelectedItems.Count > 0 Then

            Product.txtproductname.Text = ListView1.SelectedItems(0).SubItems(0).Text
            Product.txtrate.Text = ListView1.SelectedItems(0).SubItems(1).Text
            Product.cboproductgroup.Text = ListView1.SelectedItems(0).SubItems(2).Text
            Product.cbovat.Text = ListView1.SelectedItems(0).SubItems(3).Text
            Product.cbounits.Text = ListView1.SelectedItems(0).SubItems(4).Text
            Product.Label12.Text = ListView1.SelectedItems(0).SubItems(5).Text
            Product.cmd_save.Text = "Update"
            Product.DataGridView1.Visible = False
            Product.GroupBox3.Visible = False
            Product.Height = 245
        End If
    End Sub

With Regards,
Sathya



Answers (2)