티스토리 뷰
Code/C#
[C#] DataSet, BindingSource, BindingNavigator, DataGridView.DataError, BindingSource.AddNew
Hide Code 2008. 12. 21. 19:47
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DataSetSample
{
public partial class Form1 : Form
{
private DataSet ourDataSet;
private DataTable ourDataTable;
private BindingSource ourBindingSource;
public Form1()
{
InitializeComponent();
InitializeMyComponent();
}
private void InitializeMyComponent()
{
ourDataSet = new DataSet("Memorizer");
ourDataTable = new DataTable("Cards");
ourDataSet.Tables.Add(ourDataTable);
ourDataTable.Columns.Add("Page", typeof(string));
ourDataTable.Columns["Page"].AllowDBNull = false;
this.components = new System.ComponentModel.Container();
ourBindingSource = new System.Windows.Forms.BindingSource(this.components);
ourBindingSource.DataSource = ourDataSet;
ourBindingSource.DataMember = "Cards";
this.dataGridView1.DataSource = ourBindingSource;
this.bindingNavigator1.BindingSource = ourBindingSource;
}
private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
MessageBox.Show(e.Exception.Message);
}
private void buttonNew_Click(object sender, EventArgs e)
{
try
{
ourBindingSource.AddNew();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DataSetSample
{
public partial class Form1 : Form
{
private DataSet ourDataSet;
private DataTable ourDataTable;
private BindingSource ourBindingSource;
public Form1()
{
InitializeComponent();
InitializeMyComponent();
}
private void InitializeMyComponent()
{
ourDataSet = new DataSet("Memorizer");
ourDataTable = new DataTable("Cards");
ourDataSet.Tables.Add(ourDataTable);
ourDataTable.Columns.Add("Page", typeof(string));
ourDataTable.Columns["Page"].AllowDBNull = false;
this.components = new System.ComponentModel.Container();
ourBindingSource = new System.Windows.Forms.BindingSource(this.components);
ourBindingSource.DataSource = ourDataSet;
ourBindingSource.DataMember = "Cards";
this.dataGridView1.DataSource = ourBindingSource;
this.bindingNavigator1.BindingSource = ourBindingSource;
}
private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
MessageBox.Show(e.Exception.Message);
}
private void buttonNew_Click(object sender, EventArgs e)
{
try
{
ourBindingSource.AddNew();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
'Code > C#' 카테고리의 다른 글
| [C#] SqlCeDataAdapter, SqlCeCommandBuilder (0) | 2009.01.01 |
|---|---|
| [C#] DataSet, Primary Key, Foreign Key Constraint (0) | 2008.12.22 |
| [C#] SQL Compact & DataGridView Binding Sample (0) | 2008.12.20 |
| [C#] Object Binding Sample Project (0) | 2008.12.20 |
| [C#] ADO.NET XML and DataGridView Binding Sample Project (0) | 2008.12.20 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- WinAutomation
- Microsoft
- registry
- java
- c#
- READYSTATE_COMPLETE
- iTextSharp
- download.com
- Service pack
- AdSense감추기
- Phalanger
- 스크린캡쳐
- iText
- 애드센스감추기
- AdSense숨기기
- windows
- .net framework
- DotNetMagic
- tagREADYSTATE
- Automation
- 애드센스숨기기
- AxWebBrowser
- Regular Expressions
- Rollback Rx
- Sample Code
- ScreenHunter
- jre
- autohotkey
- 유틸리티
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
글 보관함
WindowsApplication2.zip