本文整理汇总了C#中System.Windows.Forms.BindingSource类的典型用法代码示例。如果您正苦于以下问题:C# BindingSource类的具体用法?C# BindingSource怎么用?C# BindingSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BindingSource类属于System.Windows.Forms命名空间,在下文中一共展示了BindingSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button1_Click
private void button1_Click(object sender, EventArgs e)
{
try
{
MySqlConnection myConn = new MySqlConnection();
myConn.Host = "192.168.69.8";
myConn.Port = 3306;
myConn.UserId = "cody";
myConn.Password = "greenstreetelite";
myConn.Open();
MySqlCommand myCommand = new MySqlCommand(" SELECT * FROM registration.regUser ;", myConn);
MySqlDataAdapter myDataAdapter = new MySqlDataAdapter();
myDataAdapter.SelectCommand = myCommand;
DataTable dbDataSet = new DataTable();
myDataAdapter.Fill(dbDataSet);
BindingSource bSource = new BindingSource();
bSource.DataSource = dbDataSet;
dataGridView1.DataSource = bSource;
myDataAdapter.Update(dbDataSet);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例2: ArticleModifierPresenter
public ArticleModifierPresenter(IArticleModifierView view)
{
_view = view;
listeArticlesToDisplay.AddRange(listeArticles);
source = new BindingSource(listeArticlesToDisplay, null);
}
示例3: frmSales
public frmSales()
{
InitializeComponent();
bsSales = new BindingSource();
dgvSales.AutoGenerateColumns = false;
BindSalesData();
}
示例4: fillgridDef
private void fillgridDef()
{
id = -1;
buttonDel.Visible = false;
buttonEdit.Visible = false;
buttonIns.Visible = false;
buttonCancel.Visible = false;
DBConnect NewcConnection = new DBConnect();
NewcConnection.dbConnection();
MySqlCommand querysql = new MySqlCommand("Select * From deficiencias", DBConnect.db);
try
{
MySqlDataAdapter dados = new MySqlDataAdapter();
dados.SelectCommand = querysql;
DataTable tabela = new DataTable();
dados.Fill(tabela);
BindingSource fonte = new BindingSource();
fonte.DataSource = tabela;
dataGridView1.DataSource = fonte;
this.dataGridView1.Columns[0].Visible = false;
dataGridView1.Columns[1].HeaderText = "Deficiencia";
dados.Update(tabela);
dataGridView1.AutoResizeColumns();
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
DBConnect.db.Close();
textBoxDef.Clear();
}
示例5: Cliente_Load
private void Cliente_Load(object sender, EventArgs e)
{
cmbTipo.DataSource = _billData.GetIdentificationType();
cmbTipo.ValueMember = "Id";
cmbTipo.DisplayMember = "Description";
if (cmbTipo.Items.Count > 0)
{
cmbTipo.SelectedIndex = 0;
}
else
{
MessageBox.Show("Error - revise la configuración del sistema");
}
BindingSource clientSource = new BindingSource();
clientSource.DataSource = new List<ClientModel>();
dtgCliente.DataSource = clientSource;
((DataGridViewComboBoxColumn)dtgCliente.Columns["TypeList"])
.DataSource = _billData.GetIdentificationType();
((DataGridViewComboBoxColumn)dtgCliente.Columns["TypeList"])
.DisplayMember = "Description";
((DataGridViewComboBoxColumn)dtgCliente.Columns["TypeList"])
.ValueMember = "Id";
((DataGridViewComboBoxColumn)dtgCliente.Columns["TypeList"])
.DataPropertyName = "IdIdentificationType";
}
示例6: BindModel
private void BindModel()
{
var mod = this.Manager.ActiveModel;
BindingSource bsMod = new BindingSource();
bsMod.DataSource = mod;
BindingSource bsPermits = new BindingSource();
bsPermits.DataSource = this.Manager.Permits;
Permits.DataSource = bsPermits;
BindingSource bsReminders = new BindingSource();
bsReminders.DataSource = mod.Reminders;
gridControlReminders.DataSource = bsReminders;
DriverID.DataBindings.Clear();
DriverID.DataBindings.Add("DriverID", bsMod, mod.GetName(p => p.DriverID), true, DataSourceUpdateMode.OnPropertyChanged);
LicenseID.DataBindings.Clear();
LicenseID.DataBindings.Add("EditValue", bsMod, mod.GetName(p => p.LicenseID), true, DataSourceUpdateMode.OnPropertyChanged);
IssueDate.DataBindings.Clear();
IssueDate.DataBindings.Add("EditValue", bsMod, mod.GetName(p => p.IssueDate), true, DataSourceUpdateMode.OnPropertyChanged);
ExpirationDate.DataBindings.Clear();
ExpirationDate.DataBindings.Add("EditValue", bsMod, mod.GetName(p => p.ExpirationDate), true, DataSourceUpdateMode.OnPropertyChanged);
MVRReviewDate.DataBindings.Clear();
MVRReviewDate.DataBindings.Add("EditValue", bsMod, mod.GetName(p => p.MVRReviewDate), true, DataSourceUpdateMode.OnPropertyChanged);
for (int i = 0; i < this.Manager.Permits.Count; i++)
{
var per = this.Manager.Permits[i];
Permits.SetItemChecked(i, per.IsCheck);
}
}
示例7: button3_Click
private void button3_Click(object sender, EventArgs e)
{
this.webBrowser1.ScriptErrorsSuppressed = true;
this.webBrowser2.ScriptErrorsSuppressed = true;
XDocument docRss = XDocument.Load("http://tw.news.yahoo.com/rss/weather");
this.webBrowser1.DocumentText = docRss.ToString();
var query = from item in docRss.Descendants("item")
select new
{
標題 = item.Element("title").Value,
說明 = item.Element("description").Value,
發佈日期 = item.Element("pubDate").Value
};
dataGridView1.DataSource = query.ToList();
//for BindingSource====================
BindingSource bs = new BindingSource();
dataGridView4.DataSource = bs;
bs.DataSource = query.ToList();
this.webBrowser2.DataBindings.Add("DocumentText", bs, "說明");
//this.dataRepeater2.DataSource = query.ToList();
}
示例8: loadHeroDiary
private void loadHeroDiary()
{
// Load the latest Hero Diary entries
using (SQLiteConnection conn = new SQLiteConnection(@"Data Source=" + dbPath + @"\gv.db;Version=3;New=False;Compress=True;"))
{
conn.Open();
using (SQLiteCommand cmd = conn.CreateCommand())
{
string commandText = "select Diary_ID as ID, Updated, EntryTime, Entry from Diary where [email protected] order by Diary_ID desc limit 1000";
cmd.CommandText = commandText;
cmd.Parameters.AddWithValue("@HeroName", this.HeroName);
SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
DataSet ds = new DataSet();
da = new SQLiteDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
BindingSource bindingSource = new BindingSource();
bindingSource.DataSource = ds.Tables[0];
grdDiary.DataSource = bindingSource;
grdDiary.AutoGenerateColumns = true;
grdDiary.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
grdDiary.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
}
}
}
示例9: LoadAllBook
public void LoadAllBook()
{
try
{
DBManager manager = new DBManager();
SqlConnection connection = manager.Connection();
string selectQuery = "SELECT * From Books";
SqlCommand cmd = new SqlCommand(selectQuery, connection);
//connection.Open();
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = cmd;
dataTable = new DataTable();
adapter.Fill(dataTable);
BindingSource binding = new BindingSource();
binding.DataSource = dataTable;
dataGridView1.DataSource = dataTable;
adapter.Update(dataTable);
}
catch ( SqlException exception)
{
MessageBox.Show(exception.Message);
}
}
示例10: FatuSemana_Load
private void FatuSemana_Load(object sender, EventArgs e)
{
this.label4.DataBindings.Clear();
dataSistema = DateTime.Now.ToShortDateString();
string data="",sDataF="";
data = dataSistema;
DateTime d = Convert.ToDateTime(data);
sDataF = d.ToString("yyyyMMdd");
try
{
MySqlConnection con = new MySqlConnection("SERVER=localhost;" + " DATABASE=banco_rr_sacoles;" + " UID=root;" + "PASSWORD=12345;");
MySqlDataAdapter sql = new MySqlDataAdapter("SELECT SUM( total ) AS total FROM faturamento WHERE data BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) and '" + sDataF + "'", con);
//SELECT DATE_SUB(CURDATE(), INTERVAL 7 DAY);
DataTable dt = new DataTable();
sql.Fill(dt);
BindingSource source = new BindingSource();
source.DataSource = dt;
this.label4.DataBindings.Add("Text", source, "total", true);
string total = label4.Text;
Decimal tt = Convert.ToDecimal(total);
String tot = tt.ToString("N", new CultureInfo("pt-BR"));
tbxFaturamento.Text = ("R$ " + (String.Format("{0:0.00}",tt))).ToString();
con.Close();
}
catch (Exception ex)
{
ex.Message.ToString();
//throw new Exception("Erro de comandos: " + ex.Message);
}
}
示例11: OknoGlowne
public OknoGlowne()
{
InitializeComponent();
Dane = new DataTable();
for (int i = 0; i < 80; i++) Dane.Columns.Add();
//Dane.Columns.
for (int i = 0; i < 79; i++) Dane.Rows.Add();
Mapa.RowTemplate.Height = 5;
BindingSource bindingSource = new BindingSource();
bindingSource.DataSource = Dane;
Mapa.DataSource = bindingSource;
for (int i = 0; i < 80; i++) Mapa.Columns[i].Width = 5;
BaudRateBox.Items.Add("250000");
BaudRateBox.Items.Add("9600");
BaudRateBox.SelectedIndex = 0;
COMPortBox.Items.Add("COM7");
COMPortBox.SelectedIndex = 0;
USART.BaudRate = 250000;
USART.PortName = "COM7";
}
示例12: SetCmbBoxBindingSrc
//void bs_AddingNew(object sender, AddingNewEventArgs e)
//{
// // check if client full name already exists
// if (((List<Client>)(bs.DataSource)).
// Any(x => x.FullName == ((Client)(e.NewObject)).FullName))
// {
// }
//}
public void SetCmbBoxBindingSrc(List<Client> clients)
{
bs = new BindingSource(clients, null);
// bs.AddingNew += new AddingNewEventHandler(bs_AddingNew);
//bs.
cmbBox_existingClients.DisplayMember = "FullName";
}
示例13: HistoryPresenterModel
public HistoryPresenterModel(IUnitInfoDatabase database)
{
if (database == null) throw new ArgumentNullException("database");
_database = database;
Debug.Assert(_database.Connected);
_queryList = new List<QueryParameters>();
_queryList.Add(new QueryParameters());
_queryList.Sort();
_queryBindingSource = new BindingSource();
_queryBindingSource.DataSource = _queryList;
_queryBindingSource.CurrentItemChanged += (s, e) =>
{
OnPropertyChanged("EditAndDeleteButtonsEnabled");
_currentPage = 1;
ResetBindings(true);
};
_historyList = new HistoryEntrySortableBindingList();
_historyList.Sorted += (s, e) =>
{
SortColumnName = e.Name;
SortOrder = e.Direction;
};
_historyBindingSource = new BindingSource();
_historyBindingSource.DataSource = _historyList;
_page = new PetaPoco.Page<HistoryEntry> { Items = new List<HistoryEntry>() };
}
示例14: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
viewPorts = new BindingSource();
windows = new BindingSource();
viewPorts.DataSource = typeof(ViewPort);
windows.DataSource = typeof(ViewPortForm);
if (File.Exists(configFile))
{
loadedCfg = Helpers.LoadConfig(configFile);
viewPorts.DataSource = (BindingList<ViewPort>)loadedCfg.ViewPorts;
}
else
{// should move this to helper
MessageBox.Show(configFile + " not found! Please create a config File", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1
, MessageBoxOptions.ServiceNotification);
this.Close();
}
foreach (ViewPort vp in viewPorts)
{
ViewPortForm vpWindow = new ViewPortForm(vp);
vpWindow.Size = new Size(vp.SizeX, vp.SizeY);
vpWindow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
vpWindow.Text = vp.Name;
vpWindow.Show();
vpWindow.DesktopLocation = new Point(vp.ScreenPositionX, vp.ScreenPositionY);
windows.Add(vpWindow);
}
}
示例15: AddData
private void AddData(string sPathEn, string sPathVi)
{
try
{
string[] filePathEn = Directory.GetFiles(sPathEn, "*.ini");
string[] filePathVi = Directory.GetFiles(sPathVi, "*.ini");
var bindingSource = new BindingSource();
data = new List<SimpleDataFile>();
for (int i = 0; i < filePathEn.Length; i++)
{
string[] aPathVi = filePathVi.Where(w => (Path.GetFileName(w).Remove(0, 6) == Path.GetFileName(filePathEn[i]).Remove(0, 6))).ToArray();
string pathvi = "";
string Tenfilevi = "";
if (aPathVi.Length > 0)
{
pathvi = aPathVi[0];
Tenfilevi = Path.GetFileName(aPathVi[0]);
keyLang = Tenfilevi.Split('.')[0];
}
bindingSource.Add(new SimpleDataFile { Chon = false, TenFileEn = Path.GetFileName(filePathEn[i]), TenFileVi = Tenfilevi, PathEn = filePathEn[i], PathVi = pathvi });
data.Add(new SimpleDataFile { Chon = false, TenFileEn = Path.GetFileName(filePathEn[i]), TenFileVi = Tenfilevi, PathEn = filePathEn[i], PathVi = pathvi });
}
gvEn.DataSource = bindingSource;
}
catch (Exception ex)
{
MessageBox.Show("Có lỗi xảy ra khi load dữ liệu");
}
}