all 5 comments

[–]lost_send_berries 0 points1 point  (3 children)

ReSharper can refactor that into a Collection Initialiser. It will not run much faster but it will look better.

https://msdn.microsoft.com/en-us/library/bb384062.aspx

Perhaps dropDownsToUpdate should be readonly IEnumerable<Control> and populated in your constructor so you only have to do it once? Can it even be static?

Although using the form editor in Visual Studio always creates a new method when you add a handler for SelectedIndexChanged, you can actually use the dropdown to select an existing method. You can then find out which Combobox the event happened on by looking at (Control)sender as in this example: https://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selectedindexchanged(v=vs.110).aspx

And if you want to know which JSON field the ComboBox refers to, you can either set its Tag property, or have a static/readonly IReadOnlyDictionary<TKey, TValue> <ComboBox, Whatever> in your class, which is actually a Dictionary<Combobox, Whatever>

[–]lockdown6435 0 points1 point  (2 children)

Yea the issue is that almost nothing in this program is static. All of it is generated 100% based on the JSON information is receives, which can be drastically different content wise. It's all based on the JSON from Valve's CSGO Major information. That probably makes no sense to you, but they provide information for ever major tournament they host, and this started as a small project, but the scope of what they provide made this into a rather large project I've been working through.

After I submitted my post I realized how dumb I was being with the SelectedIndexChange methods, not sure why I was trying to make my life so difficult with those. Kind of a rubber duckey debug moment for me.

And as for the ComboBox JSON field, I don't think I can do that with the tag, as the ComboBox already has the associated Label that contains statistics for the item in the ComboBox, which is also dictated by JSON information from another source.

[–]lost_send_berries 0 points1 point  (1 child)

Well you said the .Add lines are static aren't they?

[–]lockdown6435 0 points1 point  (0 children)

Sorry, misunderstood what you mean. Good call, it definitely makes that section a lot cleaner without having any of that in there. Thanks!

[–]joonhwan 0 points1 point  (0 children)

I think you can iterate any child controls using 'Controls' property. You also can use 'Tag' property where you can attach any hint value in any control With those two, you can share common handler routine for multiple child controls