Home     ProductivityTools     Articles     Fun fatcs     How To     C Sharp     Science News     Contact Us     Submit your website     General Blog     Jobs      
c# Keywords
ASP .NET
C# Utopia
How do I add text items t
How to download a file fr
How to print all values i
How to copy text to buffe
How to bind dataset to da
How to parse xml using li
How to launch Bat file
How to launch message box
How to read text file
How to append to text fil
How to set focus on a con
How to generate new GUID
How to bind dataset to data grid view?
 
Drag and drop a DataGridView control on your dialog. Create a class with properties for each column to be displayed in the DataGridView.
 

public class gridData

{

public string PropForCol1 { get; set; }

public string PropForCol2 { get; set; }

public string PropForCol3 { get; set; }

public string PropForCol4 { get; set; }

public gridData(string tagNumber, string tagName, string tagValue, string tagMeaning)

{

this.PropForCol1 = tagNumber;

this.PropForCol2 = tagName;

this.PropForCol3 = tagValue;

this.PropForCol4 = tagMeaning;

}

}

 

In the function where all the datagrid values need to be populated.

 

List<gridData> gridDataList = new List<gridData>();

gridDataList.Add(new gridData("row1Col1"," row1Col2", "row1Col3", "row1Col4"));

gridDataList.Add(new gridData("row2Col1"," row2Col2", "row2Col3", "row2Col4")); 

gridDataList.Add(new gridData("row3Col1"," row3Col2", "row3Col3", "row3Col4"));

 

Now set the datasour to the List.

 

dataGridViewForValidationResult.DataSource = gridDataList;

 

Your are done.