Solved

Help needed with methode

Posted on 2012-03-14
3
264 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 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