Results 1 to 7 of 7

Thread: How do i get the value from the list in label?

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    63
    jjjjjjjjjjjjjjjjjjjjjjjjjjj
    Last edited by sharonnet; Apr 2nd, 2008 at 11:44 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How do i get the value from the list in label?

    CSharp Code:
    1. this.BindingSource1.DataSource = myObj.GetDepartmentsByUserID();
    2. this.Label1.DataBindings.Add("Text", this.BindingSource1, "SomeProperty");
    That will then display the value of the SomeProperty property of your list items in the Label. To navigate the list you would set the Position property of the BindingSource or call a method like MoveNext.

    That said, your code makes no sense to me. Why does your method have two arguments that never get used?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    63

    Re: How do i get the value from the list in label?

    My UI code is in VB not in c# where i am binding the lable.Can you please give me the code in vb?

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How do i get the value from the list in label?

    How hard is it to convert that? This becomes Me, remove the semi colons, you're done.

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    63

    Re: How do i get the value from the list in label?

    It's VB.net.We don't have DataBindings and BindingSource in VB.Net

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How do i get the value from the list in label?

    You wouldn't happen to be making a web application, would you?

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How do i get the value from the list in label?

    Quote Originally Posted by sha_shivani
    It's VB.net.We don't have DataBindings and BindingSource in VB.Net
    Of course you do. They're both part of the .NET Framework so they "exist" in every .NET language, whether that be C#, VB, C++, J#, Delphi or whatever.

    That said, they are both specific to Windows Forms, so if you're creating a Web app, as mendhak suggested, then you won't have access to the BindingSource class or the DataBindings property.

    It's important to provide all the relevant information when you post. You've posted in the C# forum so of course people will respond with C# code. If you want VB code then you should either be posting in the VB forum or at least telling us that your using multiple languages and need this code in VB. Given that this site has an ASP.NET forum, if you post in a language forum then people are going to assume that it's Windows Forms in most cases. Please provide a full and proper description of your issue from the start in future to avoid wasting our time and yours.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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