Hello developers, again here with new problem !!
In my thread program I was facing problem when I was changing a value of control.
Problem was: Cross-thread operation not valid.
Yes..I got solution with below function that let me allow to access control in threading.
delegate void SetControlValueCallback(Control oControl, string propName, object propValue);
private void SetControlPropertyValue(Control oControl, string propName, object propValue)
{
if (oControl.InvokeRequired)
{
SetControlValueCallback d = new SetControlValueCallback(SetControlPropertyValue);
oControl.Invoke(d, new object[] { oControl, propName, propValue });
}
else
{
Type t = oControl.GetType();
System.Reflection.PropertyInfo[] props = t.GetProperties();
foreach (System.Reflection.PropertyInfo p in props)
{
if (p.Name.ToUpper() == propName.ToUpper())
{
p.SetValue(oControl, propValue, null);
}
}
}
}
when I need to change value of control(like change text of lable) I use that function
SetControlPropertyValue(_form.lblImportFiles, “Text”, “Importing…”); like this and its change the value.
Now..I want to change value of grid cell or need to play with its Rows property..etc..
How can I do that? I am totally blind here..Take me out of this problem.
If You want to set value in Datagridview, then try this,