reading this How to loop through a multidimensional list i do not really find a way for my specific wanted thing.
Let me describe in words and with example code hoping it illustrate it as expected.
Description or goal is: a function that is able to create a control and set/configure itself with provided attributes as you will find below ?
TableLayoutPanel _tlp = new TableLayoutPanel();
_tlp.Name = "_tlp";
_tlp.TabStop = false;
_tlp.Dock = DockStyle.Fill;
_mytlp = (TableLayoutPanel)_func(TableLayoutPanel,new List<string,object>(){{TabStop,false},{Dock,fill}});
private _func(object _ctrl, List<string,object> _attribs) {
_ctrl.getType() _tmpobj = new _ctrl.getType();
foreach (KeyValuePair<string,object> _elem in _attribts ) {
_tmpobj.(_elem.Key) = _elem.Value;
}
return _tmpobj;
}
if this is not enough illustration I do not know how to describe it better than this. I know this is not exact or correct c# code but it only should help to understand what my goal is. so first part of example code is standard creation of that specific control. next to it i would like to call the function that helps to create specified object by providing its type and wanted attributes that should be set for it.
thinking of attribute part another thing is unclear:
is following possible ?
List<string> _mL = new List<string>(){"TabStop|false"};
foreach ( string item in _mL ) {
tmp = item.split('|');
_tlp.tmp[0] = tmp[1];
if ( tmp[0].equals("TabStop")) _tlp.TabStop = tmp[1];
}