CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2012
    Posts
    1

    error:cannot implicity string to label

    i want to show my result on a lable which i want to use in a method of book class

    Code:
    class Book
    {
    Form1 newform = new Form1();
    public string BookTitle;
    public string BookAuthor;
    public string PublishDate;
    public const string Publisher = "MICROSOFT";
     
    
    public void GetDetails()
    {
    // showing error here cannot implicity string to lable
    newform.lbl_view_title = this.BookTitle;
    }
     
    }
    private void btnMain_Click(object sender, EventArgs e)
    {
     
    CSharp.BookTitle = textBox1.Text;
    CSharp.BookAuthor = textBox2.Text;
    CSharp.PublishDate = textBox3.Text;
     
    
    CSharp.GetDetails();
    }

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: error:cannot implicity string to label

    I don't have access to look this up in msdn right now, but the label should have a Text property.

    Code:
    newform.lbl_view_title.Text = this.BookTitle;

  3. #3

    Re: error:cannot implicity string to label

    lol clearly you can only set it to its Text property. Label is a COntrol object.

    Try pressing the . key next to the labelfield name. It shows you the Text property.
    Last edited by CM2013; April 30th, 2013 at 12:48 PM.

Tags for this Thread

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

Featured