Solved

Help needed with methode

Posted on 2012-03-14
3
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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