Solved

Help needed with methode

Posted on 2012-03-14
3
260 Views
Last Modified: 2012-03-14
Hi,
In my methode CustomColumnDisplayText I tried to call
for the function checktype. The purpose of this function
is to check if a string contains a comma (,) or a (.) if so then
false otherwise true. But I don't know how to call for this
function in the customcolumndisplay-event. And the declaration
in the customcolumndisplay-event to devide and multilpy the
value isn't correct either.

 private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.Column.FieldName == "Value")
            {
                if ((Properties.Settings.Default.IsMGDL == false) || (CheckType = true))
                {
                    e.DisplayText = (e.Value / 18).ToString();
                }
                else if ((Properties.Settings.Default.IsMGDL == true) || (CheckType = false))
                {
                    e.DisplayText = (e.Value * 18).ToString();
                }
            }

        }
        //*-------------------------------------------------------------*//
        static bool CheckType(string value)
        {
            return value.Contains(",") || value.Contains(".");
        }
        //*-------------------------------------------------------------*//

Open in new window

     

ERRORS:

1. Cannot assign to 'CheckType' because it is a 'method group'
2. Operator '/' cannot be applied to operands of type 'object' and 'int'      
3. Cannot assign to 'CheckType' because it is a 'method group'
4. Operator '*' cannot be applied to operands of type 'object' and 'int'      


Who can help me?

Peter
0
Comment
Question by:peterkiers
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
lojk earned 500 total points
ID: 37719593
Part 1

I'm guessing that 'CheckType' used to be a procedural scope boolean value and then got moved to a function?

The answer is simpler than it looks and is a common mistake (that I see and make in C#)

if ((Properties.Settings.Default.IsMGDL == false) || (CheckType = true))
                {
                    e.DisplayText = (e.Value / 18).ToString();
                }

Checktype is a Method with parameters but you are calling it as a non-invokable member(property). Also you are using an assignment equals, not a comparison equals.

probably should say something like

if ((Properties.Settings.Default.IsMGDL == false) || (CheckType (SOMESTRINGVALUE) == true))
                {
                 //see part 2
                }



Part 2

                {
                    e.DisplayText = (e.Value / 18).ToString();
                }
 
I am not familiar with the DevExpress control set but I am presume that e.Value is of type object - you cant mulitply an object by an integer, you have to type cast it first.

Something like this should do it..

                {
                 int eValue = Convert.ToInt(e.Value ); // I think you know what this should actually say!
                    e.DisplayText = (eValue / 18).ToString();
                }


Hows that?
0
 
LVL 1

Author Comment

by:peterkiers
ID: 37719636
Super you have helped me alot.

Thanks.


500 p's comming your way...


Peter Kiers
0
 
LVL 9

Expert Comment

by:lojk
ID: 37719662
You are welcome Peter.

Gotta love that stupid "Cannot assign to 'CheckType' because it is a 'method group'" error.

Why they can't just say 'you forgot the brackets, dummy' is beyond me ;-)

Have a good day.

Alan
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Icons and Colors for Terms 3 24
Need help on C# Linq query on object 6 53
Write to file when application closes (by logoff) - VB.NET 1 23
ASP.NET MVC 2 6
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now