Click here to Skip to main content
15,881,248 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: 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 – ∞)

GeneralRe: When the comment is longer than the code Pin
mcep5f200930-Jul-14 8:36
mcep5f200930-Jul-14 8:36 
GeneralRe: When the comment is longer than the code Pin
Dave Kreskowiak30-Jul-14 8:41
mveDave Kreskowiak30-Jul-14 8:41 
GeneralRe: When the comment is longer than the code Pin
OriginalGriff30-Jul-14 8:58
mveOriginalGriff30-Jul-14 8:58 
GeneralRe: When the comment is longer than the code Pin
Swinkaran30-Jul-14 20:37
professionalSwinkaran30-Jul-14 20:37 
GeneralRe: When the comment is longer than the code Pin
MarkTJohnson1-Aug-14 6:52
professionalMarkTJohnson1-Aug-14 6:52 
GeneralRe: When the comment is longer than the code Pin
Karen Mitchelle30-Jul-14 20:50
professionalKaren Mitchelle30-Jul-14 20:50 
GeneralIts always good to check for nothing..... Pin
Thanks787225-Jul-14 2:32
professionalThanks787225-Jul-14 2:32 
GeneralRe: Its always good to check for nothing..... Pin
Richard Deeming25-Jul-14 2:40
mveRichard Deeming25-Jul-14 2:40 
GeneralRe: Its always good to check for nothing..... Pin
Thanks787225-Jul-14 2:49
professionalThanks787225-Jul-14 2:49 
GeneralRe: Its always good to check for nothing..... Pin
Sentenryu25-Jul-14 3:36
Sentenryu25-Jul-14 3:36 
GeneralRe: Its always good to check for nothing..... Pin
Thanks787225-Jul-14 4:07
professionalThanks787225-Jul-14 4:07 
GeneralRe: Its always good to check for nothing..... Pin
newton.saber25-Jul-14 2:57
newton.saber25-Jul-14 2:57 
GeneralRe: Its always good to check for nothing..... Pin
Stefan_Lang31-Jul-14 3:58
Stefan_Lang31-Jul-14 3:58 
GeneralRe: Its always good to check for nothing..... Pin
PIEBALDconsult25-Jul-14 3:54
mvePIEBALDconsult25-Jul-14 3:54 
GeneralRe: Its always good to check for nothing..... Pin
Brady Kelly3-Aug-14 3:47
Brady Kelly3-Aug-14 3:47 
GeneralRe: Its always good to check for nothing..... Pin
Tim Carmichael25-Jul-14 4:00
Tim Carmichael25-Jul-14 4:00 
GeneralRe: Its always good to check for nothing..... Pin
Thanks787225-Jul-14 4:05
professionalThanks787225-Jul-14 4:05 

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.