RE: Data error DataGridView DataGridViewComboBoxColumn

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

I performed a test based on your sample code but didn't reproduce the
problem on my side.

I create a WinForm application project and add a DataGridView on the form.
The following is the code in the form.

public partial class Form1 : Form
{
List<ViewData> m_DataList;
private void Form1_Load(object sender, EventArgs e)
{
DataSet regions = new DataSet("Regions");
DataSet territories = new DataSet("Territories");

DataTable regiontable = new DataTable();
DataColumn col = new DataColumn("RegionID", typeof(int));
regiontable.Columns.Add(col);
col = new DataColumn("RegionDescription");
regiontable.Columns.Add(col);
regions.Tables.Add(regiontable);

DataTable territorytable = new DataTable();
col = new DataColumn("TerritoryID", typeof(int));
territorytable.Columns.Add(col);
col = new DataColumn("TerritoryDescription");
territorytable.Columns.Add(col);
col = new DataColumn("RegionID", typeof(int));
territorytable.Columns.Add(col);
territories.Tables.Add(territorytable);

DataRow row = regions.Tables[0].NewRow();
row[0] = 3;
row[1] = "region 3";
regions.Tables[0].Rows.Add(row);

row = regions.Tables[0].NewRow();
row[0] = 2;
row[1] = "region 2";
regions.Tables[0].Rows.Add(row);


row = territories.Tables[0].NewRow();
row[0] = 44122;
row[1] = "terri 44122";
row[2] = 3;
territories.Tables[0].Rows.Add(row);

row = territories.Tables[0].NewRow();
row[0] = 53404;
row[1] = "terri 53404";
row[2] = 3;
territories.Tables[0].Rows.Add(row);

row = territories.Tables[0].NewRow();
row[0] = 60601;
row[1] = "terri 60601";
row[2] = 2;
territories.Tables[0].Rows.Add(row);

row = territories.Tables[0].NewRow();
row[0] = 94105;
row[1] = "terri 94105";
row[2] = 2;
territories.Tables[0].Rows.Add(row);

this.RegionsColumn.DataSource = regions.Tables[0];
this.RegionsColumn.DisplayMember = "RegionDescription";
this.RegionsColumn.ValueMember = "RegionID";

this.TerritoriesColumn.DataSource = territories.Tables[0];
this.TerritoriesColumn.DisplayMember = "TerritoryDescription";
this.TerritoriesColumn.ValueMember = "TerritoryID";

m_DataList = new List<ViewData>();
m_DataList.Add(new ViewData(3, 44122));
m_DataList.Add(new ViewData(3, 53404));
m_DataList.Add(new ViewData(2, 60601));
m_DataList.Add(new ViewData(2, 94105));

dataGridView1.AutoGenerateColumns = false;
dataGridView1.DataSource = m_DataList;
dataGridView1.Columns[0].DataPropertyName = "RegionID";
dataGridView1.Columns[1].DataPropertyName = "TerritoryID";
}
}
public class ViewData
{
private int m_Region;
private int m_Territory;

public ViewData(int Region, int Territory)
{
m_Region = Region;
m_Territory = Territory;
}

public int RegionID
{
get { return m_Region; }
set { m_Region = value; }
}

public int TerritoryID
{
get { return m_Territory; }
set { m_Territory = value; }
}
}
}

If possible, could you please create a simple project that could just
reproduce the problem and send it to me? To get my actual email address,
remove 'online' from my displayed email address.

I look forward to your reply!

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

.



Relevant Pages

  • Re: query-based update failed
    ... Yes, we can reproduce it every time for a specific record, not randomly. ... Look forward to your response. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.sqlserver.odbc)
  • RE: ShowinTaskBar -- Backwards Question
    ... public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.windowsforms)
  • RE: Data error DataGridView DataGridViewComboBoxColumn
    ... I performed a test based on your sample code but didn't reproduce the ... private int m_Territory; ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.general)
  • RE: Getbytes usage from VS 2003 to VS2005
    ... private bool GetImageSeq(ref byteSeqImage, string PatId, string AdmDate, ... int ImgSeq, int SeqSz) ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Dont want to debug web service
    ... so I need more information from you to reproduce this ... If you create a little sample project to call the Web Services, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vsnet.debugging)