Solved

Help needed with methode

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

747 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

12 Experts available now in Live!

Get 1:1 Help Now