I'm having problems with the DataGrid

  • Thread starter Thread starter Csharper95
  • Start date Start date
C

Csharper95

I'm working on a program that will display a modal form containing 2
datagrids (but might as well focus on just one for now). These
datagrids display read-only information that is stored in arrays.

I'm completely new to datagrids, so I don't know what I am doing wrong
as I'm getting runtime errors. Please help


namespace ZZZ
{
............
public struct ProViewStr
{
public string[] LineNameArr;
public int[] LineStatusArr;
..................
}
........
public class ProForm : System.Windows.Forms.Form
{
.......
protected ProViewStr proViewStr;
.......
.......
private void menu_DataInfo_Click(object
sender,System.EventArgs e)
{
DataInfo dataInfo = new DataInfo();
int L = proViewStr.LineStatusArr.Length;
string[] Lname = proViewStr.LineNameArr;

dataInfo.DatSetup(proViewStr);
dataInfo.PopulateSurveyLineGrid();

dataInfo.ShowDialog();
}
} //end of class
}//end of namepace

.......................................................................................
.........................................................................................
namespace ZZZ
{
...........
public class DataInfo : System.Windows.Forms.Form
{
.........
private ProViewStr prov;
private int InfoArrsize;
..........
public void DatSetup(ProViewStr prv)
{
prov.LineNameArr = prv.LineNameArr;
InfoArrsize = prov.LineNameArr.Length;
prov.LineStatusArr = prv.LineStatusArr;
}
..........
public void PopulateSurveyLineGrid()
{
DataTable dt = new
DataTable("SurveyLineGrid");
DataRow myRow;

for(int i=0; i < InfoArrsize; i++)
{
myRow = dt.NewRow();
myRow["Line Name"] =
prov.LineNameArr;
dt.Rows.Add(myRow);
}
}
.........
}//end of class
}// end of namespace


*---------------------------------*
Posted at: http://www.GroupSrv.com
Check: http://wwww.HotCodecs.com
*---------------------------------*
 
Hi:

Please post the errors. If is difficult to figure out what's going on
without the benefit of compiler output.

John

Csharper95 said:
I'm working on a program that will display a modal form containing 2
datagrids (but might as well focus on just one for now). These
datagrids display read-only information that is stored in arrays.

I'm completely new to datagrids, so I don't know what I am doing wrong
as I'm getting runtime errors. Please help


namespace ZZZ
{
............
public struct ProViewStr
{
public string[] LineNameArr;
public int[] LineStatusArr;
..................
}
........
public class ProForm : System.Windows.Forms.Form
{
.......
protected ProViewStr proViewStr;
.......
.......
private void menu_DataInfo_Click(object
sender,System.EventArgs e)
{
DataInfo dataInfo = new DataInfo();
int L = proViewStr.LineStatusArr.Length;
string[] Lname = proViewStr.LineNameArr;

dataInfo.DatSetup(proViewStr);
dataInfo.PopulateSurveyLineGrid();

dataInfo.ShowDialog();
}
} //end of class
}//end of namepace

.............................................................................
........................................................................................
.............
namespace ZZZ
{
...........
public class DataInfo : System.Windows.Forms.Form
{
.........
private ProViewStr prov;
private int InfoArrsize;
..........
public void DatSetup(ProViewStr prv)
{
prov.LineNameArr = prv.LineNameArr;
InfoArrsize = prov.LineNameArr.Length;
prov.LineStatusArr = prv.LineStatusArr;
}
..........
public void PopulateSurveyLineGrid()
{
DataTable dt = new
DataTable("SurveyLineGrid");
DataRow myRow;

for(int i=0; i < InfoArrsize; i++)
{
myRow = dt.NewRow();
myRow["Line Name"] =
prov.LineNameArr;
dt.Rows.Add(myRow);
}
}
.........
}//end of class
}// end of namespace


*---------------------------------*
Posted at: http://www.GroupSrv.com
Check: http://wwww.HotCodecs.com
*---------------------------------*
 
I am getting:

An unhandled exception of type 'System.ArgumentException' occurred in
system.data.dll

Additional information: Column 'Line Name' does not belong to table
SurveyLineGrid.

Basically the reason I posted is because I am completely lost with
DataGrids. And I was wondering if the code above is correct. If
there is something missing or something I did not include.
Am I by chance supposed to put something in under the 'TableStyles
(Collections)' property for the DataGrid
along with my code ?

I really need to get this working. I've looked through a few different
C# text books, MSDN library, and the like but I still can't figure out
how to apply -- what is mostly shown as coding for database
applications, to a simple DataGrid with information stored in
arrays.

Please help.
*---------------------------------*
Posted at: http://www.GroupSrv.com
Check: http://www.HotCodecs.com
*---------------------------------*
 
Back
Top