English 中文(简体)
方框中选入案文箱中但未使用的项目
原标题:listbox selected items into textbox not working

my vb.net will not use listbox1.selecteditems it always comes up with a blue line underneath even though when i search online everyone is using this.

我的目标是将选定的项目列入案文箱。

    Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim li As ListItem
        For Each li In ListBox1.Items
            If li.Selected Then
                TextBox1.Text &= li.Text & vbCrLf
            End If
            UpdatePanel2.Update()
        Next
    End Sub
End Class
最佳回答

确定多选举名单控制中的甄选

通过控制项目收集和测试每个项目的选定财产。

For Each li In ListBox1.Items
   If li.Selected Then
      TextBox1.Text &= li.Text & vbCrLf
   End If
Next

伙伴关系没有选定项目。 净额:exists only for Winforms-List Box Controls。

问题回答

I think the problem here is that you re binding to the control immediately prior to trying to retrieve a selected value from it. When the control is initially bound to the datasource it won t have any selected items.

你们需要将其分开,以便你在装满该页时对清单箱进行约束,然后用户在该箱中选择某些东西,点击你的布顿2,文本箱的价值在后继时得到更新。

第一,页载:

Protected Sub Page_Load(object sender, EventArgs, e)
        listcmd.Connection = conn1
        conn1.Open()


        listcmd.CommandText = "SELECT distinct B603SalesAsOFMASTER.SDESCR FROM B603SalesAsOFMASTER"

        listda.Fill(saolist, "listboxtext")
        Dim dt As DataTable = saolist.Tables("listboxtext")

        ListBox1.DataSource = dt
        ListBox1.DataValueField = "SDESCR"
        ListBox1.DataMember = "SDESCR"
        ListBox1.DataBind()


        conn1.Close()
    End Sub

接着,当用户点击Button2时,该代码即行。

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

        For i As Integer = 0 To ListBox1.SelectedItems.Count - 1
            TextBox1.Text &= DirectCast(ListBox1.SelectedItems(i), DataRowView)(1).ToString & vbCrLf
        Next

        CheckBox1.Visible = True
        TextBox1.Visible = True

    End Sub

www.un.org/Depts/DGACM/index_spanish.htm 查阅(文本框中的项目)

文本箱3.Text = 清单Box1.GetItemText(listBox1.S selectedItem);





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签