Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# question - how to tell if checkbox is checked?
Message
De
24/03/2008 18:01:26
 
 
À
24/03/2008 17:58:34
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01305128
Message ID:
01305156
Vues:
5
To bring back memories of the big old fights here.......
I don't think he's talking bout the () for methods. He's questioning the need for () surrounding the boolean expression after the keyword if.

>Victor,
>A () indicates you are calling a method (a sub or function). The () gives you a space to supply parameters if need be. No () indicates you are calling a property of the form. You do not use parameters with properties.
>
>>This worked:
>> if (this.chkAutoRequery.Checked == true)
>>
>>...interesting. I don't quite grasp the reason for the ( ) having to be like that but I'll get used to it (I hope...ha).
>>
>>
>>
>>>Try
>>>
>>>
if (this.checkbox.checked == true) {... }
>>>
>>>BTW, I was going to suggest value property without checking Help first.
>>>
>>>This is if chkAutoRequery.Checked() = true VFP code. In C# you need == to check for value equal something. And () for checking conditions.
>>>
>>>Got me couple of times too, BTW :)
>>>
>>>
>>>>Actually I tried that and I get a syntax error '(' expected....
>>>>
>>>>maybe I need a THIS for THISFORM or something like that in front of it?
>>>>
>>>>>Sooooooooooooooooooo close!
>>>>>
>>>>>"Checked" is a property. So no "()". Parentheses necessary for method calls.
>>>>>
>>>>>
>>>>>>Yippie! My first .NET question! (and yeah its realllly lame too .. haha)
>>>>>>
>>>>>>I have a checkbox I put on a form, and I'm trying to tell if it's been checked or not. I have something like this:
>>>>>>
>>>>>>if (dlgOpen.ShowDialog() == DialogResult.OK)
>>>>>> {
>>>>>> // Console.Write(dlgOpen.FileName);
>>>>>> crystalReportViewer1.ReportSource = dlgOpen.FileName;
>>>>>> if chkAutoRequery.Checked() = true
>>>>>> {
>>>>>> crystalReportViewer1.RefreshReport();
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>>chkAutoRequery is the name of my checkbox - so its this line:
>>>>>> if chkAutoRequery.Checked() = true
>>>>>>..that I'm doing wrong. Anyone clue me in on the correct syntax?
>>>>>>
>>>>>>Thanks!

(On an infant's shirt): Already smarter than Bush
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform