Click here to Skip to main content
15,895,370 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi friends,

In my program i want a datagrid cell value,. but i got the hole value of the row,. so i need help for how to get datagrid particular cell value in wpf ?. unfortunately i didnt get help.

now i got the output,

{ name = tuutusdydfh, code = cs11 }


but i want only ,

cs11


In alternate thing i ready to cut the output string., pls help,.
Posted
Updated 27-Feb-11 23:38pm
v2

C#
string code = "";

string myString = "{ name = tuutusdydfh, code = cs11 }";
myString = myString.Replace("{", "").Replace("}", "").Replace(" ", "");

string[] parts = myString.Split(',');
foreach(string part in parts)
{
    if (part.StartsWith("code="))
    {
        code = part.Replace("code=", "");
        break;
    }
}


At this point, code should be equal to "cs11".
 
Share this answer
 
Comments
Sagotharan Jagadeeswaran 28-Feb-11 23:28pm    
wow, i got it!. thank u very much John.

Are you have any idea about how to get datagrid particular cell value in wpf ?
Rather than parsing cell value out of a string, try to get the cell value directly as discussed here[^].
 
Share this answer
 
Comments
Sagotharan Jagadeeswaran 28-Feb-11 7:31am    
thank u friend,. but that code not work properly,. it ask presentation assembly. but i already add that one,. its very difficult to me,.

is any easy way is there, like
DataGridView1.CurrentCell = DataGridView1.Rows(1).Cells(0)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900