I know that this was asked million times but I do not how to define my search,so please have patience.
I want to make method which is going to set some proprieties on control dynamical refer to sting sent to method.
something like this
public void SetGridColumnProperty(ref DataGridView grid,string columnName, string propretyName, string propertyValue )
{
grid.Columns[columnName].("I know this can't be done as this") = propertyValue;
}
I apologize if my question is hard to understand,
Here what I want to do
I am making WinForms app whic is using lot od Data Grid Views for displaying and editing data.
As I have needs to often change looks of my girds, add columns edit order and other My idea was to hold some kind of metadata for each DataGird on form, And when I showing form to user I want before I load
my form set properties of grid by join metadata and properties of specific grid.
I want to have config files separated of real code in XML or in DataBase so when I do edits on my application I do not have to recompile new code, Just change my xml and at next loding forom it looks as I like
First of all, There is no need to use
refkeyword, becauseDataGridViewis a reference type. Second, here is the solution:Sample:
Update: Check the
CanWriteproperty of thePropertyInfoclass before invoking the SetValue method.