Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Tuesday, March 10, 2009

C#, VB.NET, ListView Groups are not showing


Listview not showing groups? This could be your problem.

Scenarios:
  • I have done everything to display groups but they refuse to display!
  • Cannot see groups in listview
  • Listview has groupings but no groups at runtime
  • listview does not show groups
  • listview not showng groups
Solution:
Application.EnableVisualStyles()

Call it at the beginning of your App, this will only effect people who decide to add this to an older app in most cases.

I ripped my hair out for a while before finding this in the documentation. Grats googlers I did the work for you.

ListView groups are available only on Windows XP Home Edition, Windows XP Professional, Windows Server 2003 when your application calls the Application..::.EnableVisualStyles method. On earlier operating systems, any code relating to groups has no effect and the groups will not appear. For more information, see ListView..::.Groups.

p.s. - Another possibility is you are viewing in details but do not have a column added.
p.p.s. - Another possibility is you do not have listview1.showgroups = true.
p.p.p.s. - You can also set this in the properties rather than calling it. (Picture below p.p.p.p.s.)
p.p.p.p.s. - If you are running anything older than XP, Server 2003, etc you cannot view visual styles and are screwed until you update.

Wednesday, June 11, 2008

Do you ever look at it...

And go, “Sweet cheese who came up with that syntax, I think if I could write a compiler I would come up with something more elegant than that load of crap.” I do.

For i As Integer = 0 To msgids.Length - 1

‘Do some crap

Next



I hate the for loops in VB, they are something totally different and crappy than any other for loop I have crossed in my life. I was thinking about this while coding and just had to share and see if anyone else out there agrees. VB.NET For loops go like this:

For i As Integer = 0 To msgids.Length - 1
'Do some crap
Next


The "To" is just so dumb, so assumptive and stupid! Now lets look at C++ derived for loops.


for(int i = 0; i < msgids.Length; i++)
{
//Do some crap
}

(In case it stays like that pretend < is actually a less than sign /shrug)

Is it just me or is the C++ style so much more elegant and so much more clear. You do not have to make assumptions you know that what we compare to each time is i but you also know you could change that at anytime to be j*i or whatever, robust and clear vs. odd and assumptive.

After programming in VB.NET for oever a Year (company forced) I have to say I missed the hell out of C++ based languages, luckily my current projects which I will reveal eventually have gotten me back into C#, Javascript, etc where the For loop actually seems logical again.

Rant over and out.