Click here to Skip to main content
15,918,976 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Who cares? Pin
ColborneGreg4-Aug-14 8:15
ColborneGreg4-Aug-14 8:15 
GeneralRe: Who cares? Pin
Stefan_Lang11-Aug-14 20:56
Stefan_Lang11-Aug-14 20:56 
GeneralRe: Who cares? Pin
ColborneGreg11-Aug-14 21:00
ColborneGreg11-Aug-14 21:00 
GeneralRe: Who cares? Pin
Stefan_Lang11-Aug-14 21:03
Stefan_Lang11-Aug-14 21:03 
GeneralRe: Who cares? Pin
ColborneGreg12-Aug-14 5:11
ColborneGreg12-Aug-14 5:11 
GeneralDebugging pain Pin
Dave Kreskowiak31-Jul-14 4:38
mveDave Kreskowiak31-Jul-14 4:38 
GeneralRe: Debugging pain Pin
ZurdoDev31-Jul-14 4:51
professionalZurdoDev31-Jul-14 4:51 
GeneralRe: Debugging pain Pin
Nguyen.H.H.Dang31-Jul-14 17:57
professionalNguyen.H.H.Dang31-Jul-14 17:57 
GeneralRe: Debugging pain Pin
MarkTJohnson1-Aug-14 6:45
professionalMarkTJohnson1-Aug-14 6:45 
GeneralFloorwise appplication Pin
Thanks787231-Jul-14 0:10
professionalThanks787231-Jul-14 0:10 
GeneralRe: Floorwise appplication Pin
Eddy Vluggen31-Jul-14 1:36
professionalEddy Vluggen31-Jul-14 1:36 
GeneralRe: Floorwise appplication Pin
Duncan Edwards Jones31-Jul-14 3:03
professionalDuncan Edwards Jones31-Jul-14 3:03 
GeneralRe: Floorwise appplication Pin
ZurdoDev31-Jul-14 4:05
professionalZurdoDev31-Jul-14 4:05 
GeneralRe: Floorwise appplication Pin
Richard Deeming31-Jul-14 4:14
mveRichard Deeming31-Jul-14 4:14 
GeneralRe: Floorwise appplication Pin
Thanks787231-Jul-14 4:29
professionalThanks787231-Jul-14 4:29 
GeneralRe: Floorwise appplication Pin
VICK12-Aug-14 0:48
professional VICK12-Aug-14 0:48 
GeneralRe: Floorwise appplication Pin
PIEBALDconsult31-Jul-14 4:31
mvePIEBALDconsult31-Jul-14 4:31 
GeneralRe: Floorwise appplication Pin
Thanks787231-Jul-14 4:33
professionalThanks787231-Jul-14 4:33 
GeneralRe: Floorwise appplication Pin
PIEBALDconsult31-Jul-14 4:38
mvePIEBALDconsult31-Jul-14 4:38 
GeneralRe: Floorwise appplication Pin
Bernhard Hiller31-Jul-14 20:54
Bernhard Hiller31-Jul-14 20:54 
GeneralRe: Floorwise appplication Pin
Richard Deeming1-Aug-14 2:08
mveRichard Deeming1-Aug-14 2:08 
GeneralRe: Floorwise appplication Pin
PIEBALDconsult4-Aug-14 12:45
mvePIEBALDconsult4-Aug-14 12:45 
GeneralRe: Floorwise appplication Pin
GuyThiebaut5-Aug-14 1:51
professionalGuyThiebaut5-Aug-14 1:51 
GeneralRe: Floorwise appplication Pin
Johnny J.23-Jan-15 1:00
professionalJohnny J.23-Jan-15 1:00 
GeneralWhen the comment is longer than the code Pin
OriginalGriff30-Jul-14 5:51
mveOriginalGriff30-Jul-14 5:51 
Five or six times longer...
C#
/// <summary>
/// Gets and sets the selected indexes
/// </summary>
/// <remarks>
/// This is necessarily complicated.
/// Remember, the data comes from a DataTable (DT) - (or a list from which the DT data
/// was derived) and the outside world expects indexes to to relative to that DT.
/// But...we display the data in a DataGridView (DGV) via a DataView (DV) and apply
/// filtering and sorting to the DV according to the user input.
/// So the selected rows we get from the DGV are in last-selected-by-user order, (which
/// if fine and dandy), but are relative to the DGV rather than the underlying DV or
/// DT data source, as the DGV is subject to the sorting and filtering applied to the DV.
///
/// So, we get the selected items from the DGV (only place we can, the DV doesn't know
/// about selection), then have to convert that to the DataRow and get the index of that
/// from the DT. But (of course) the DGV returns a DataGridViewRow object just to be
/// annoying...
/// And that's just Get!
/// </remarks>
[Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public IEnumerable<int> SelectedIndexes
    {
    get { return dgvData.SelectedRows.Cast<DataGridViewRow>().Select(r => _DataSource.Rows.IndexOf(((DataRowView)r.DataBoundItem).Row)); }
    set { ... }
    }

I almost wish I'd written it longhand instead of using Linq methods... Laugh | :laugh:
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.