Solved

# Explenation needed about a methode

Posted on 2011-09-27
Medium Priority
211 Views
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
Question by:peterkiers

LVL 15

Expert Comment

ID: 36708492
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

LVL 7

Assisted Solution

Bill Nolan earned 800 total points
ID: 36708510
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

LVL 1

Author Comment

ID: 36708520
What the purpose of the ?-sign. What does that mean?

P.
0

LVL 15

Accepted Solution

Eyal earned 800 total points
ID: 36708537
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

LVL 1

Author Comment

ID: 36708555
Oke only thing i don't get is the function of the ? sign.
0

LVL 8

Assisted Solution

jagrut_patel earned 400 total points
ID: 36708561
?: is like if..else condition

(condition)?(value if condition is true): (value if condition is false);
0

LVL 1

Author Comment

ID: 36708571
Thanks for the information.

Peter Kiers
0

## Featured Post

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.