I tried posting this in the WinForm forum and got no hits so I am
trying it here.
After inserting a new data row to a DataTable that is bound to a
datagrid, I am unable to change data in a row that is after the newly
added row without getting bizarre results.
I have added the full code for the test below. Create a project drop
in the code and run. There is nothing crazy about the code. I used
the designer to add the dataset and to do the binding.
Any help would be appreciated.
Cheers,
Dave
Test #1
======================
1) Click on the row where ID = 1
2) Click "Add Row" button
3) Click on the cell ID = 2 Number = 4
4) Change the number from 4 to 5
5) Move off the row (i.e. hit the down arrow key)
6) Notice there are 2 rows with ID = 2 now
2, 5, 6
2, 4, 6
Test #2
======================
1) Click on the row where ID = 1
2) Click "Add Row" button
3) Click "Remove Binding"
4) Click "Add Binding"
5) Click on the cell ID = 2 Number = 4
6) Change the number from 4 to 5
7) Move off the row (i.e. hit the down arrow key)
8) Notice there are 2 rows with ID = 2 now
2, 5, 6
2, 4, 6
==========================
using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Controls
{
/// <summary>
/// Summary description for TestDataGrid.
/// </summary>
public class TestDataGrid : System.Windows.Forms.Form
{
private int idCounter = 100;
#region Unimportant Window stuff
private System.Windows.Forms.DataGrid theGrid;
private System.Windows.Forms.Button addButton;
private System.Data.DataSet myDataSet;
private System.Data.DataTable rateTable;
private System.Data.DataColumn dataColumn1;
private System.Data.DataColumn dataColumn2;
private System.Data.DataColumn dataColumn3;
private System.Windows.Forms.Button removeBinding;
private System.Windows.Forms.Button addBinding;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components =
null;
public TestDataGrid()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after
InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not
modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.theGrid = new
System.Windows.Forms.DataGrid();
this.myDataSet = new System.Data.DataSet();
this.rateTable = new System.Data.DataTable();
this.dataColumn1 = new
System.Data.DataColumn();
this.dataColumn2 = new
System.Data.DataColumn();
this.dataColumn3 = new
System.Data.DataColumn();
this.addButton = new
System.Windows.Forms.Button();
this.removeBinding = new
System.Windows.Forms.Button();
this.addBinding = new
System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.t heGrid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.m yDataSet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.r ateTable)).BeginInit();
this.SuspendLayout();
//
// theGrid
//
this.theGrid.Anchor =
((System.Windows.Forms.AnchorStyles)((((System.Win dows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Bottom)
|
System.Windows.Forms.AnchorStyles.Left)
|
System.Windows.Forms.AnchorStyles.Right)));
this.theGrid.DataMember = "RateTable";
this.theGrid.DataSource = this.myDataSet;
this.theGrid.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.theGrid.Location = new
System.Drawing.Point(8, 40);
this.theGrid.Name = "theGrid";
this.theGrid.Size = new
System.Drawing.Size(368, 184);
this.theGrid.TabIndex = 0;
//
// myDataSet
//
this.myDataSet.DataSetName = "NewDataSet";
this.myDataSet.Locale = new
System.Globalization.CultureInfo("en-US");
this.myDataSet.Tables.AddRange(new
System.Data.DataTable[] {
this.rateTable});
//
// rateTable
//
this.rateTable.Columns.AddRange(new
System.Data.DataColumn[] {
this.dataColumn1,
this.dataColumn2,
this.dataColumn3});
this.rateTable.TableName = "RateTable";
//
// dataColumn1
//
this.dataColumn1.ColumnName = "ID";
this.dataColumn1.DataType = typeof(int);
//
// dataColumn2
//
this.dataColumn2.ColumnName = "Number";
this.dataColumn2.DataType = typeof(int);
//
// dataColumn3
//
this.dataColumn3.ColumnName = "Price";
this.dataColumn3.DataType = typeof(int);
//
// addButton
//
this.addButton.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windo ws.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
this.addButton.Location = new
System.Drawing.Point(16, 256);
this.addButton.Name = "addButton";
this.addButton.TabIndex = 1;
this.addButton.Text = "Add Row";
this.addButton.Click += new
System.EventHandler(this.addButton_Click);
//
// removeBinding
//
this.removeBinding.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windo ws.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
this.removeBinding.Location = new
System.Drawing.Point(136, 256);
this.removeBinding.Name = "removeBinding";
this.removeBinding.Size = new
System.Drawing.Size(104, 23);
this.removeBinding.TabIndex = 3;
this.removeBinding.Text = "Remove Binding";
this.removeBinding.Click += new
System.EventHandler(this.removeBinding_Click);
//
// addBinding
//
this.addBinding.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windo ws.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
this.addBinding.Location = new
System.Drawing.Point(288, 256);
this.addBinding.Name = "addBinding";
this.addBinding.Size = new
System.Drawing.Size(104, 23);
this.addBinding.TabIndex = 4;
this.addBinding.Text = "Add Binding";
this.addBinding.Click += new
System.EventHandler(this.addBinding_Click);
//
// TestDataGrid
//
this.AutoScaleBaseSize = new
System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(400,
293);
this.Controls.Add(this.addBinding);
this.Controls.Add(this.removeBinding);
this.Controls.Add(this.addButton);
this.Controls.Add(this.theGrid);
this.Name = "TestDataGrid";
this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScree n;
this.Text = "TestDataGrid";
this.Load += new
System.EventHandler(this.TestDataGrid_Load);
((System.ComponentModel.ISupportInitialize)(this.t heGrid)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.m yDataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.r ateTable)).EndInit();
this.ResumeLayout(false);
}
#endregion
#endregion
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void addButton_Click(object sender,
System.EventArgs e)
{
Random random = new
Random(idCounter);
DataRow row = rateTable.NewRow();
int position = theGrid.CurrentRowIndex + 1;
row[0] = idCounter++;
row[1] = (int)( random.NextDouble() * 100 );
row[2] = (int)( random.NextDouble() * 10 );
rateTable.Rows.InsertAt( row, position );
rateTable.AcceptChanges();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void removeBinding_Click(object sender,
System.EventArgs e)
{
this.theGrid.DataSource = null;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void addBinding_Click(object sender,
System.EventArgs e)
{
this.theGrid.DataMember = "RateTable";
this.theGrid.DataSource = this.myDataSet;
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TestDataGrid_Load(object sender,
System.EventArgs e)
{
int numRows = 5;
DataRow row;
for (int i = 0; i < numRows; i++)
{
row = rateTable.NewRow();
row[0] = i * 1;
row[1] = i * 2;
row[2] = i * 3;
rateTable.Rows.Add( row );
}
}
}
} 5 2925
From your description (I haven't run the code or looked at it closely), the
issue is that even if the new row is added to the middle of the list, it
always shows up in the end.
This is a known bug with the DataView (when you bind to a DataTable, you are
really binding to its DefaultView property which is a DataView). I believe
it should be resolved with the 2.0 framework.
"Dave" <Da**@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.com... I tried posting this in the WinForm forum and got no hits so I am trying it here.
After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is after the newly added row without getting bizarre results.
I have added the full code for the test below. Create a project drop in the code and run. There is nothing crazy about the code. I used the designer to add the dataset and to do the binding.
Any help would be appreciated.
Cheers, Dave
Test #1 ====================== 1) Click on the row where ID = 1 2) Click "Add Row" button 3) Click on the cell ID = 2 Number = 4 4) Change the number from 4 to 5 5) Move off the row (i.e. hit the down arrow key) 6) Notice there are 2 rows with ID = 2 now 2, 5, 6 2, 4, 6
Test #2 ====================== 1) Click on the row where ID = 1 2) Click "Add Row" button 3) Click "Remove Binding" 4) Click "Add Binding" 5) Click on the cell ID = 2 Number = 4 6) Change the number from 4 to 5 7) Move off the row (i.e. hit the down arrow key) 8) Notice there are 2 rows with ID = 2 now 2, 5, 6 2, 4, 6
==========================
using System; using System.Data; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms;
namespace Controls { /// <summary> /// Summary description for TestDataGrid. /// </summary> public class TestDataGrid : System.Windows.Forms.Form { private int idCounter = 100;
#region Unimportant Window stuff
private System.Windows.Forms.DataGrid theGrid; private System.Windows.Forms.Button addButton; private System.Data.DataSet myDataSet; private System.Data.DataTable rateTable; private System.Data.DataColumn dataColumn1; private System.Data.DataColumn dataColumn2; private System.Data.DataColumn dataColumn3; private System.Windows.Forms.Button removeBinding; private System.Windows.Forms.Button addBinding; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null;
public TestDataGrid() { // // Required for Windows Form Designer support // InitializeComponent();
// // TODO: Add any constructor code after InitializeComponent call // }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); }
#region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.theGrid = new System.Windows.Forms.DataGrid(); this.myDataSet = new System.Data.DataSet(); this.rateTable = new System.Data.DataTable(); this.dataColumn1 = new System.Data.DataColumn(); this.dataColumn2 = new System.Data.DataColumn(); this.dataColumn3 = new System.Data.DataColumn(); this.addButton = new System.Windows.Forms.Button(); this.removeBinding = new System.Windows.Forms.Button(); this.addBinding = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.t heGrid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.m yDataSet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.r ateTable)).BeginInit(); this.SuspendLayout(); // // theGrid // this.theGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Win dows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.theGrid.DataMember = "RateTable"; this.theGrid.DataSource = this.myDataSet; this.theGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.theGrid.Location = new System.Drawing.Point(8, 40); this.theGrid.Name = "theGrid"; this.theGrid.Size = new System.Drawing.Size(368, 184); this.theGrid.TabIndex = 0; // // myDataSet // this.myDataSet.DataSetName = "NewDataSet"; this.myDataSet.Locale = new System.Globalization.CultureInfo("en-US"); this.myDataSet.Tables.AddRange(new System.Data.DataTable[] {
this.rateTable}); // // rateTable // this.rateTable.Columns.AddRange(new System.Data.DataColumn[] {
this.dataColumn1,
this.dataColumn2,
this.dataColumn3}); this.rateTable.TableName = "RateTable"; // // dataColumn1 // this.dataColumn1.ColumnName = "ID"; this.dataColumn1.DataType = typeof(int); // // dataColumn2 // this.dataColumn2.ColumnName = "Number"; this.dataColumn2.DataType = typeof(int); // // dataColumn3 // this.dataColumn3.ColumnName = "Price"; this.dataColumn3.DataType = typeof(int); // // addButton // this.addButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windo ws.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.addButton.Location = new System.Drawing.Point(16, 256); this.addButton.Name = "addButton"; this.addButton.TabIndex = 1; this.addButton.Text = "Add Row"; this.addButton.Click += new System.EventHandler(this.addButton_Click); // // removeBinding // this.removeBinding.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windo ws.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.removeBinding.Location = new System.Drawing.Point(136, 256); this.removeBinding.Name = "removeBinding"; this.removeBinding.Size = new System.Drawing.Size(104, 23); this.removeBinding.TabIndex = 3; this.removeBinding.Text = "Remove Binding"; this.removeBinding.Click += new System.EventHandler(this.removeBinding_Click); // // addBinding // this.addBinding.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windo ws.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.addBinding.Location = new System.Drawing.Point(288, 256); this.addBinding.Name = "addBinding"; this.addBinding.Size = new System.Drawing.Size(104, 23); this.addBinding.TabIndex = 4; this.addBinding.Text = "Add Binding"; this.addBinding.Click += new System.EventHandler(this.addBinding_Click); // // TestDataGrid // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(400, 293); this.Controls.Add(this.addBinding); this.Controls.Add(this.removeBinding); this.Controls.Add(this.addButton); this.Controls.Add(this.theGrid); this.Name = "TestDataGrid"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScree n; this.Text = "TestDataGrid"; this.Load += new System.EventHandler(this.TestDataGrid_Load);
((System.ComponentModel.ISupportInitialize)(this.t heGrid)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.m yDataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.r ateTable)).EndInit(); this.ResumeLayout(false);
} #endregion
#endregion
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addButton_Click(object sender, System.EventArgs e) { Random random = new Random(idCounter);
DataRow row = rateTable.NewRow(); int position = theGrid.CurrentRowIndex + 1;
row[0] = idCounter++; row[1] = (int)( random.NextDouble() * 100 ); row[2] = (int)( random.NextDouble() * 10 );
rateTable.Rows.InsertAt( row, position ); rateTable.AcceptChanges(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void removeBinding_Click(object sender, System.EventArgs e) { this.theGrid.DataSource = null; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addBinding_Click(object sender, System.EventArgs e) { this.theGrid.DataMember = "RateTable"; this.theGrid.DataSource = this.myDataSet; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TestDataGrid_Load(object sender, System.EventArgs e) { int numRows = 5; DataRow row;
for (int i = 0; i < numRows; i++) { row = rateTable.NewRow(); row[0] = i * 1; row[1] = i * 2; row[2] = i * 3;
rateTable.Rows.Add( row ); } } } }
Dave,
In my opinion do you show us to much code.
The change that you get an answer on this is probably very small.
Try to give the essential part of your problem
In addition, because that you are using C# code you have probably even a
better change on an answer in the newsgroup
microsoft.public.dotnet.languages.csharp
Which does not mean that you cannot get an answer here, however take my
advice make it in a way that we can understand the problem quick.
By instance is it for your problem really not important how the datagrid is
anchored on the form.
I hope this helps,
Cor
Marina, This is a known bug with the DataView (when you bind to a DataTable,
Do you mean DataGrid, in that case I know it?
Cor
90% of the code is generated by dragging controls on the form.
From addButton_Click down is code that I manually typed, some
20 lines of code altogether.
To the best of my ability there is no possible way of providing a
demo that is smaller.
The barest way to describe the problem is I have
1) Dragged a DataGrid, DataSet, and 3 buttons onto the form
2) Added columns to the DataSet
3) Bound DataSet to DataGrid
4) Double clicked each button "Add Row" "Remove Binding" "Add Binding"
and added appropriate 5-8 lines of code
5) Added default data to Form Load
6) Start App
7) Position cursor on row 1
8) Click "Add Row" Button
9) Modify row after new row and it BLOWS UP
Cheers,
Dave
Cheers,
Dave
"Cor Ligthert [MVP]" wrote: Dave,
In my opinion do you show us to much code. The change that you get an answer on this is probably very small.
Try to give the essential part of your problem
In addition, because that you are using C# code you have probably even a better change on an answer in the newsgroup
microsoft.public.dotnet.languages.csharp
Which does not mean that you cannot get an answer here, however take my advice make it in a way that we can understand the problem quick.
By instance is it for your problem really not important how the datagrid is anchored on the form.
I hope this helps,
Cor
You said, "From your description (I haven't run the code or looked at it
closely), the issue is that even if the new row is added to the middle of the
list, it always shows up in the end."
I say: NO. Either a CurrencyManger.Refresh or AcceptChanges will put it in
the correct position. This is not the problem. The problem is after I do
either of these methods above and try to modify a row AFTER the new row that
was added, I get null and duplicat rows and then the app crashes and burns.
Cheers,
Dave
"Marina" wrote: From your description (I haven't run the code or looked at it closely), the issue is that even if the new row is added to the middle of the list, it always shows up in the end.
This is a known bug with the DataView (when you bind to a DataTable, you are really binding to its DefaultView property which is a DataView). I believe it should be resolved with the 2.0 framework.
"Dave" <Da**@discussions.microsoft.com> wrote in message news:38**********************************@microsof t.com...I tried posting this in the WinForm forum and got no hits so I am trying it here.
After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is after the newly added row without getting bizarre results.
I have added the full code for the test below. Create a project drop in the code and run. There is nothing crazy about the code. I used the designer to add the dataset and to do the binding.
Any help would be appreciated.
Cheers, Dave
Test #1 ====================== 1) Click on the row where ID = 1 2) Click "Add Row" button 3) Click on the cell ID = 2 Number = 4 4) Change the number from 4 to 5 5) Move off the row (i.e. hit the down arrow key) 6) Notice there are 2 rows with ID = 2 now 2, 5, 6 2, 4, 6
Test #2 ====================== 1) Click on the row where ID = 1 2) Click "Add Row" button 3) Click "Remove Binding" 4) Click "Add Binding" 5) Click on the cell ID = 2 Number = 4 6) Change the number from 4 to 5 7) Move off the row (i.e. hit the down arrow key) 8) Notice there are 2 rows with ID = 2 now 2, 5, 6 2, 4, 6
==========================
using System; using System.Data; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms;
namespace Controls { /// <summary> /// Summary description for TestDataGrid. /// </summary> public class TestDataGrid : System.Windows.Forms.Form { private int idCounter = 100;
#region Unimportant Window stuff
private System.Windows.Forms.DataGrid theGrid; private System.Windows.Forms.Button addButton; private System.Data.DataSet myDataSet; private System.Data.DataTable rateTable; private System.Data.DataColumn dataColumn1; private System.Data.DataColumn dataColumn2; private System.Data.DataColumn dataColumn3; private System.Windows.Forms.Button removeBinding; private System.Windows.Forms.Button addBinding; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null;
public TestDataGrid() { // // Required for Windows Form Designer support // InitializeComponent();
// // TODO: Add any constructor code after InitializeComponent call // }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); }
#region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.theGrid = new System.Windows.Forms.DataGrid(); this.myDataSet = new System.Data.DataSet(); this.rateTable = new System.Data.DataTable(); this.dataColumn1 = new System.Data.DataColumn(); this.dataColumn2 = new System.Data.DataColumn(); this.dataColumn3 = new System.Data.DataColumn(); this.addButton = new System.Windows.Forms.Button(); this.removeBinding = new System.Windows.Forms.Button(); this.addBinding = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.t heGrid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.m yDataSet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.r ateTable)).BeginInit(); this.SuspendLayout(); // // theGrid // this.theGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Win dows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.theGrid.DataMember = "RateTable"; this.theGrid.DataSource = this.myDataSet; this.theGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.theGrid.Location = new System.Drawing.Point(8, 40); this.theGrid.Name = "theGrid"; this.theGrid.Size = new System.Drawing.Size(368, 184); this.theGrid.TabIndex = 0; // // myDataSet // this.myDataSet.DataSetName = "NewDataSet"; this.myDataSet.Locale = new System.Globalization.CultureInfo("en-US"); this.myDataSet.Tables.AddRange(new System.Data.DataTable[] {
this.rateTable}); // // rateTable // this.rateTable.Columns.AddRange(new System.Data.DataColumn[] {
this.dataColumn1,
this.dataColumn2,
this.dataColumn3}); this.rateTable.TableName = "RateTable"; // // dataColumn1 // this.dataColumn1.ColumnName = "ID"; this.dataColumn1.DataType = typeof(int); // // dataColumn2 // this.dataColumn2.ColumnName = "Number"; this.dataColumn2.DataType = typeof(int); // // dataColumn3 // this.dataColumn3.ColumnName = "Price"; this.dataColumn3.DataType = typeof(int); // // addButton // this.addButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windo ws.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.addButton.Location = new System.Drawing.Point(16, 256); this.addButton.Name = "addButton"; this.addButton.TabIndex = 1; this.addButton.Text = "Add Row"; this.addButton.Click += new System.EventHandler(this.addButton_Click); // // removeBinding // this.removeBinding.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windo ws.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.removeBinding.Location = new System.Drawing.Point(136, 256); this.removeBinding.Name = "removeBinding"; this.removeBinding.Size = new System.Drawing.Size(104, 23); this.removeBinding.TabIndex = 3; this.removeBinding.Text = "Remove Binding"; this.removeBinding.Click += new System.EventHandler(this.removeBinding_Click); // // addBinding // this.addBinding.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windo ws.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.addBinding.Location = new System.Drawing.Point(288, 256); this.addBinding.Name = "addBinding"; this.addBinding.Size = new System.Drawing.Size(104, 23); this.addBinding.TabIndex = 4; this.addBinding.Text = "Add Binding"; this.addBinding.Click += new System.EventHandler(this.addBinding_Click); // // TestDataGrid // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(400, 293); this.Controls.Add(this.addBinding); this.Controls.Add(this.removeBinding); this.Controls.Add(this.addButton); this.Controls.Add(this.theGrid); this.Name = "TestDataGrid"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScree n; this.Text = "TestDataGrid"; this.Load += new System.EventHandler(this.TestDataGrid_Load);
((System.ComponentModel.ISupportInitialize)(this.t heGrid)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.m yDataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.r ateTable)).EndInit(); this.ResumeLayout(false);
} #endregion
#endregion
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addButton_Click(object sender, System.EventArgs e) { Random random = new Random(idCounter);
DataRow row = rateTable.NewRow(); int position = theGrid.CurrentRowIndex + 1;
row[0] = idCounter++; row[1] = (int)( random.NextDouble() * 100 ); row[2] = (int)( random.NextDouble() * 10 );
rateTable.Rows.InsertAt( row, position ); rateTable.AcceptChanges(); }
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Frosty |
last post by:
Hi
I am using the VS xsd designer to create a strongly typed dataset. The dataset is apparently successfully created, with no warnings or errors given. Is it not then to be expected that this...
|
by: Diego TERCERO |
last post by:
Hi...
I'm working on a tool for editing text resources for a family of software
product my company produces.
These text resources are found in a SQL Server database, in a table called...
|
by: David |
last post by:
Hello.
I have some little problem with DataSet and I hope somebody will help me.
So what's my problem:
I have DataSet with some table in it lets say table name is "Suppliers", I
have DataGrid...
|
by: Dave |
last post by:
Tried posting in the Winform Forum without much luck, so posting here...
After inserting a new data row to a DataTable that is bound to a
datagrid, I am unable to change data in a row that is...
|
by: Alpha |
last post by:
Hi, I have a window based program. One of the form has several textboxes and
a datagrid. The textboxes are bind to the same dataset table as the datagrid
and the text changes to reflect different...
|
by: John Holmes |
last post by:
I have a web interface where the user types in ID's one at a time. After an
ID is typed in, a button is clicked and the button click event has code that
does a query and returns a data reader and...
|
by: Bishoy George |
last post by:
I have a dataset called ds1 filled with 2 tables Employees and Customers
from Northwind database.
I have dropdownList called ddLastName with the following properties:
ddLastName.DataSource =...
|
by: jaYPee |
last post by:
does anyone experienced slowness when updating a dataset using
AcceptChanges?
when calling this code it takes many seconds to update the database
SqlDataAdapter1.Update(DsStudentCourse1)...
|
by: paulhux174 |
last post by:
Hi,
I've a dataGrid set up (the standard msdn example) with a
SqlDataAdapter, and DataSet.
The problem is that after inserting a new row using the
LinkButton1_Click() (code below)
then edit...
|
by: Abby |
last post by:
Hi all,
I have a datagrid which i am using for updating the data to the database. It
works fine for single row data however when i have multiple rows(records)
associated with the same...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |