• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Explenation needed about a methode

Hi,
Can someone translate this for me, the most easiest way.
Because I am terrible in math:

        private void SizeLastColumn(ListView lv)
        {
            int x = lvNotes.Width / 15 == 0 ? 1 : lvNotes.Width / 15;
            lvNotes.Columns[0].Width = x * 2;
            lvNotes.Columns[1].Width = x;
            lvNotes.Columns[2].Width = x * 2;
        }

Peter
0
peterkiers
Asked:
peterkiers
3 Solutions
 
EyalCommented:
put in x 1 if listview width divided to 15 is zero otherwise put the devision result
resize the columns:
0 -> x by 2
1 -> x
2 -> x by 2
0
 
Bill NolanOwner, Lead Technology ProgrammerCommented:
Column 1 will be width 'x', which is 1 unit wide for every 15 of lvNotes.Width, minimum of 1.
Column 0 & 2 will be twice the width of column 1.
0
 
peterkiersAuthor Commented:
What the purpose of the ?-sign. What does that mean?

P.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
EyalCommented:
its a method to write if else in one row

same as writing...
if(lvNotes.Width / 15 == 0)
{
x=1;
}
else
{
x=lvNotes.Width / 15;
}
0
 
peterkiersAuthor Commented:
Oke only thing i don't get is the function of the ? sign.
0
 
jagrut_patelCommented:
?: is like if..else condition

(condition)?(value if condition is true): (value if condition is false);
0
 
peterkiersAuthor Commented:
Thanks for the information.

Peter Kiers
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now