Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3428136
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:55:22+00:00 2026-05-18T06:55:22+00:00

I am abit new in C# and i am trying to insert an object

  • 0

I am abit new in C# and i am trying to insert an object to a CheckedListBox,
so this inserted item will have a title inside the checked list (my object contains a string field inside it which I want to be displayed in the CheckedListBox).
for example this is my class:

 public class InfoLayer
{
    private string LayerName;
    private List<GeoInfo> GeoInfos;
    public InfoLayer()
    {
        LayerName = "New Empty Layer";
        GeoInfos = new List<GeoInfo>();
    }
    public InfoLayer(string LayerName)
    {
        this.LayerName = LayerName;
        GeoInfos = new List<GeoInfo>();
    }
    public InfoLayer(string LayerName,List<GeoInfo> GeoInfosToClone):this(LayerName)
    {
        foreach (GeoInfo item in GeoInfosToClone)
        { 
             GeoInfos.Add((GeoInfo)((ICloneable)item).Clone());
        }
    }
    public GeoInfo SearchElement(long id)
    {
        foreach (GeoInfo info in GeoInfos) // foreach loop running on the list 
        {
            if (info.INFOID == id) 
                return info; // return the item if we found it
        }
        return null;
    }

    public GeoInfo SearchElement(string name)
    {
        foreach (GeoInfo info in GeoInfos)
        {
            if (info.INFONAME.CompareTo(name)==0)
                return info;
        }
        return null;
    }

    public override string ToString()
    {
        string toReturn = "";
        for (int i = 0; i < GeoInfos.Count; i++) // for loop running on the list 
        {
            toReturn += String.Format("{0}\n",GeoInfos[i].ToString()); // piping another geoinfo 
        }
        return toReturn;
    }

    public string LAYERNAME{get{return LayerName;}}

my class also contains a tostring overrider inside her (not what i want to display)

thanks in advance for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:55:22+00:00Added an answer on May 18, 2026 at 6:55 am

    Override ToString() in your class, the class that the object is an instance of.

    Edit:

    You don’t want to display the contents of ToString(). You want to display the LayerName, don’t you? Perhaps you should display the values with Databinding instead. Then you can set DisplayMember to your new LAYERNAME property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bit of code that looks like this: text = reg.Replace(text, new
I'm a bit new to reflection in c#. I'm trying to generate a list
Thanks for reading. I'm a bit new to jQuery, and am trying to make
I have a lengthy number-crunching process which takes advantage of quite abit of OpenGL
I'm trying to get an insert to work using LINQ and am having some
I'm having problems trying to pass an Integer object from a driver class as
I am trying to modify a list and since my modifications were getting a
I am trying to populate the list of an <h:selectOneMenu> . However, the list
Kind of new to C# and trying to broaden my abilities a bit. I
Here's the response I keep getting when trying to create a new activity: {error:{errors:[{message:Unknown

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.