Created
June 28, 2012 20:10
-
-
Save gabrielgreen/3013620 to your computer and use it in GitHub Desktop.
Quick way to display a grid of key/value pairs using LINQ to Objects and WinForms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (EomAppCommon.Settings.DebugEomDatabase) | |
{ | |
var form = new System.Windows.Forms.Form(); | |
var grid = new System.Windows.Forms.DataGridView { | |
AutoGenerateColumns = true, | |
Dock = System.Windows.Forms.DockStyle.Fill, | |
DataSource = | |
(from c in new [] { | |
Tuple.Create("DADatabaseR1ConnectionString", this.DADatabaseR1ConnectionString), | |
Tuple.Create("StatsYear", this.StatsYear.ToString()), | |
Tuple.Create("StatsMonth", this.StatsMonth.ToString()), | |
Tuple.Create("StatsDaysInMonth", this.StatsDaysInMonth.ToString()), | |
Tuple.Create("PubReportSubjectLine", this.PubReportSubjectLine), | |
} select new { | |
Key = c.Item1, | |
Value = c.Item2, | |
}).ToList(), | |
AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill, | |
}; | |
form.Controls.AddRange(new[] { grid, }); | |
form.ShowDialog(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment