W
Will
The code below defines a class FillData. This is used to bind to a
DataGridView. However, the columns on the DataGridView are NOT in the
same order as specified in the class (Start, Sweep, Duration, POW,
Sync) but instead are shown Start, Duration, Sync, Sweep, POW.
Is there any way I can ensure that the columns on the DataGridView are
displayed in a particular order?
Thanks
Will.
private FillData m_data;
grdFill.DataSource = m_data.FillRows;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace MyApp.Objects
{
/// <summary>
/// SourceData breaks down the channel into fill data, tests and
other data
/// </summary>
public class FillData : EditableObject
{
public FillData(XmlNode node)
: base(node)
{
m_maxRows = int.Parse(node.Attributes["maxrows"].Value);
// Create some sample data
m_rows = new FillRow[m_maxRows];
for (int i = 0; i < m_rows.Length; ++i)
{
m_rows = new FillRow(i + 1);
m_rows.Start = rnd.Next(250);
m_rows.Sweep = rnd.Next(100);
m_rows.Duration = rnd.Next(200);
m_rows.POW = rnd.Next(250);
m_rows.Sync = rnd.Next(2) == 1;
}
}
public FillRow[] FillRows
{
get { return m_rows; }
}
public class FillRow
{
public FillRow(int i)
{
index = i;
}
public int Index
{
get { return index; }
}
public double Start
{
get { return start; }
set { start = value; }
}
public double Sweep
{
get { return sweep; }
set { sweep = value; }
}
public double Duration
{
get { return duration; }
set { duration = value; }
}
public double POW
{
get { return pow; }
set { pow = value; }
}
public bool Sync
{
get { return sync; }
set { sync = value; }
}
private int index;
private double start;
private double sweep;
private double duration;
private double pow;
private bool sync;
}
#region Private Data
FillRow[] m_rows;
int m_maxRows;
#endregion
// Random number generator
public static Random rnd = new Random();
}
}
DataGridView. However, the columns on the DataGridView are NOT in the
same order as specified in the class (Start, Sweep, Duration, POW,
Sync) but instead are shown Start, Duration, Sync, Sweep, POW.
Is there any way I can ensure that the columns on the DataGridView are
displayed in a particular order?
Thanks
Will.
private FillData m_data;
grdFill.DataSource = m_data.FillRows;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace MyApp.Objects
{
/// <summary>
/// SourceData breaks down the channel into fill data, tests and
other data
/// </summary>
public class FillData : EditableObject
{
public FillData(XmlNode node)
: base(node)
{
m_maxRows = int.Parse(node.Attributes["maxrows"].Value);
// Create some sample data
m_rows = new FillRow[m_maxRows];
for (int i = 0; i < m_rows.Length; ++i)
{
m_rows = new FillRow(i + 1);
m_rows.Start = rnd.Next(250);
m_rows.Sweep = rnd.Next(100);
m_rows.Duration = rnd.Next(200);
m_rows.POW = rnd.Next(250);
m_rows.Sync = rnd.Next(2) == 1;
}
}
public FillRow[] FillRows
{
get { return m_rows; }
}
public class FillRow
{
public FillRow(int i)
{
index = i;
}
public int Index
{
get { return index; }
}
public double Start
{
get { return start; }
set { start = value; }
}
public double Sweep
{
get { return sweep; }
set { sweep = value; }
}
public double Duration
{
get { return duration; }
set { duration = value; }
}
public double POW
{
get { return pow; }
set { pow = value; }
}
public bool Sync
{
get { return sync; }
set { sync = value; }
}
private int index;
private double start;
private double sweep;
private double duration;
private double pow;
private bool sync;
}
#region Private Data
FillRow[] m_rows;
int m_maxRows;
#endregion
// Random number generator
public static Random rnd = new Random();
}
}