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

  • SEARCH
  • Home
  • 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 1009617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:57:21+00:00 2026-05-16T08:57:21+00:00

I have problem with databinding in the Win.Forms DataGridView control. Example: public class A

  • 0

I have problem with databinding in the Win.Forms DataGridView control.
Example:

public class A
{
      public String Title {get; set; }
      public B BField { get; set; }
}

public class B
{
      public String Name { get; set; }
}

I want to see in my column value from B. (BField.Name).
I tried to use the next way for data key, just fill with BField.Name value, but it doesn’t work for me. Else I want to have opportunity for chaning this field value via DataGridView.

Also I tried to create:

class A 
{
...

       public String BField_Name 
       {
           get{return BField.Name;} 
           set{BField.Name = value;}
       }
}

But it doesn’t work too.
Can you help me to fix this problem?

Thanks!

With The Best Regards,
Alexander.

  • 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-16T08:57:22+00:00Added an answer on May 16, 2026 at 8:57 am

    To have the “B” class value show correctly in the Grid, override the ToString method to return the Title property.

    You can then create a TypeConvertor for the “B” class so the Grid knows how to translate the string cell value into a “B” class type, i.e.

       public class BStringConvertor : TypeConverter
       {
          public BStringConvertor()
             : base()
          {
          }
    
          public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
          {
             // Allow conversion from a String type
             if (sourceType == typeof(string))
                return true;
    
             return base.CanConvertFrom(context, sourceType);
          }
    
          public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
          {
             // If the source value is a String, convert it to the "B" class type
             if (value is string)
             {
                B item = new B();
                item.Title = value.ToString();
                return item;
             }
             return base.ConvertFrom(context, culture, value);
          }
    
          public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
          {
             // If the destination type is a String, convert the "B" class to a string
             if (destinationType == typeof(string))
                return value.ToString();
    
             return base.ConvertTo(context, culture, value, destinationType);
          }
       }
    

    Then you can apply the converter to the “B” class property of your “A” class, i.e.

       public class A
       {
          public string Title { get; set; }
    
          [TypeConverter(typeof(BStringConvertor))]
          public B BField { get; set; }
       }
    
       public class B
       {
          public string Title { get; set; }
    
          public override string ToString()
          {
             return this.Title;
          }
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer clsMRDateTime::tmClassMainTimeTM is a pointer to a struct tm, so when… May 16, 2026 at 4:01 pm
  • Editorial Team
    Editorial Team added an answer It is worth noting, that strtotime() accepts ISO week date… May 16, 2026 at 4:01 pm
  • Editorial Team
    Editorial Team added an answer I had similar problem on RHEL server, turned out my… May 16, 2026 at 4:01 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a problem with databinding on a style in WPF. The basic setup
I have some problem on databinding to Image 's Source Property. I have a
I have a databinding problem in WPF. I would like to customise a slider
I have problem with refering to special symbol in string: I have: path='C:\dir\dir1\dir2\filename.doc' and
Problem 1: I have a simple winforms app and I want to DataBind my
I have problem concerning translations in qt. All translations in my porject work fine,
I have problem with a css menu. It is correct on firefox,chrome,opera,safari and ie8.
I have problem with uploading image to SQL database. i have Methods Upload in
i have problem with showing an UIView on app delegate ... there is no
I have problem with reflection, dynamic invoking objects and reading collection values. In Referenced

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.