1 Replies - 2671 Views - Last Post: 24 July 2013 - 09:21 AM Rate Topic: -----

#1 syedripon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-March 09

Add an String type array list in a Grid in C# in WPF

Posted 23 July 2013 - 07:37 PM

Hi There: I have a project in WPF C#. In my code, I am creating a new object(string object) from a loop and adding that string object in a List. Now in my XAML code I have added a Grid(myGrid). How Can I show the List of my Array objects in this Grid(Like a table). The Grid has 3 columns with heading: "Name", "Old Text", "New Text".
Some thing Like:
Public Class myObj
{
private string mname,mOldV, mNewV;
Class myObj(string name, string OldV, NewV)
{
mname =name;
mOldV=OldV;
mNewV= NewV;
}
}//end of myObj
Public class Mainclass
{
private List<MyObj> lObj=Null;
public sub asub
{
for(i=0, i<3,i++)
{
mObj = new MyObj("a",b","c"); //I will change this value
lObj[i].add =mObj;
}
myGrid.DataContext=mObj;//I dont know this one
}//end of asub
Qustion: I need the code part of the Grid in XAML to bind the List of myObj and also correct code(above) in C#.
Advance thanks
Syed

Is This A Good Question/Topic? 0
  • +

Replies To: Add an String type array list in a Grid in C# in WPF

#2 oyyou  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 190
  • Joined: 26-April 10

Re: Add an String type array list in a Grid in C# in WPF

Posted 24 July 2013 - 09:21 AM

Try using the "ItemSource" for the grid.

myGrid.ItemSource = mObj;


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1