I created user control which has datagridview control. And datagridview is getting data from textfile to create row and columns dynamically. I added that user control to panel. One column of dgv is editable. I want that editable column values in a list. I am getting all the values except last row value.
Code for main Form
public static List<string> testValue = new List<string>();
private void SavetoolStripMenuItem1_Click(object sender, EventArgs e)
{
List<string> dummy = new List<string>();
foreach (Control p in panelUC.Controls)
{
if (p is uc_protectionTbl1)
{
dummy = ((((uc_protectionTbl1)p).obsValue));
testValue.AddRange(dummy); //here I want all values
}
if (p is uc_performResult)
{
}
}
Code for userControl
private List<string> listObs = new List<string>();
private string obs = null;
public List<string> obsValue
{
get
{
foreach (DataGridViewRow row in dgv_uc.Rows)
{
obs = row.Cells["Observed(Sec)"].Value.ToString();
listObs.Add(obs);
}
return listObs;
}
}
In testValue list index I am getting these values
[0] = "1";
[1] = "2";
[2] = "3";
[3] = ""; //here I want "4"
And listObs list I am getting following values
[0] = "3";
[1] = ""; //here I also want "4"
My TextFile from where I designed dgv
TestType=Phase Loset Over Current Protection Test (I>)
Heading=SrNo||Injected Current||Rated
Current||Char||Pickup(xIp)||TMS||STD]||Observed(Sec)
Value=Test-1||0.4||1||NINV3.0||0.2||0.1||0.95-1.00-1.05
Value=Test-2||7.0||1||NINV3.0||1.0||0.5||1.68-1.76-1.85
TestType=Earth Lowset Over Current Protection Test (Ie>)
Heading=SrNo||Injected Current||Rated
Current||Char||Pickup(xIn)||TMS||STD||Observed(Sec)
Value=Test-3||0.2||1||NINV3.0||0.1||0.1||0.95-1.00-1.05
Value=Test-4||7.0||1||NINV3.0||1.0||0.5||1.68-1.76-1.85
When I read "SrNo" column instead of "Observed(Sec)" column I got all the value from SrNo column. Then why i am not able to read "Observed(Sec)" column which is editable?
I am not able to understand what I am missing. Please help me to resolve this issue. Thanks in advance!!