Share via

C# giving me problems

Lloyd Sheen 1,491 Reputation points
2023-09-08T16:35:15.35+00:00

I am in the process of writing my own controls to replace 3rd party controls (paid) and am currently doing fonts. I have added a property DefaultFont to the DataGridTextColumn

public class DataGridTextColumn : DataGridColumn
{
    public string Text { get; set; }
    public string StringFormat { get; set; }
    public string DefaultFont { get; set; } 
}


Now when I attempt to access this property I get a not found error in the following code:

                    if ((DataGridTextColumn)dgc.DefaultFont == string.Empty)
                    {

                    }

Now for some reason the property does not show and it gets even stranger. I put the following lines of code in and they have no errors (this site really needs fixing as not all copy/paste works the same way).

DataGridTextColumn dg = (DataGridTextColumn)dgc;

var x = dg.DefaultFont;

This is very confusing as one simply does not set a variable for later use.

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

Answer accepted by question author

Viorel 127K Reputation points
2023-09-08T16:48:22.4333333+00:00
if (((DataGridTextColumn)dgc).DefaultFont == string.Empty)
{

}

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.