﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-C# step by step </title><link>http://www.cnitblog.com/wuming3000/</link><description>begin programme</description><language>zh-cn</language><lastBuildDate>Wed, 29 Apr 2026 05:57:37 GMT</lastBuildDate><pubDate>Wed, 29 Apr 2026 05:57:37 GMT</pubDate><ttl>60</ttl><item><title>Using the CurrencyManager</title><link>http://www.cnitblog.com/wuming3000/archive/2006/10/26/18471.html</link><dc:creator>开始编程</dc:creator><author>开始编程</author><pubDate>Thu, 26 Oct 2006 12:14:00 GMT</pubDate><guid>http://www.cnitblog.com/wuming3000/archive/2006/10/26/18471.html</guid><wfw:comment>http://www.cnitblog.com/wuming3000/comments/18471.html</wfw:comment><comments>http://www.cnitblog.com/wuming3000/archive/2006/10/26/18471.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cnitblog.com/wuming3000/comments/commentRss/18471.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/wuming3000/services/trackbacks/18471.html</trackback:ping><description><![CDATA[
		<font size="2">昨天写一个代码感觉CurrencyManager运用在DataGrvdView中用处很大 所以摘录一些内容来学习参考<br /><img src="http://www.codeproject.com/cs/database/DatabaseAcessWithAdoNet1/ImageCurrencyManager.jpg" /><br /><br /><p><font size="3">You use the <code>CurrencyManager</code> object if you want to keep data-bound controls synchronized with each other which means showing data from the same record. For example: if you want to add a <code>TextBox</code> control to a form and bind it to a column of a table (e.g., <code>Customers.FirstName</code>) in a <code>DataSet</code> (e.g., <code>dSet</code>), the control is going to communicate with the <code>BindingContext</code> object for this form. In turn, the <code>BindingContext</code> object is going to talk to the specific <code>CurrencyManager</code> object for the data the <code>TextBox</code> control is binding.</font></p><p><font size="3">Every Windows Form has a <code>BindingContext</code> object keeping track of all the <code>CurrencyManager</code> objects on the Windows Form. <code>CurrencyManager</code> keeps track of the position in the data source. When you bind a data object to a control (i.e., <code>TextBox</code>), a <code>CurrencyManager</code> object is automatically assigned. If you bind several controls to the same data source, they share the same <code>CurrencyManager</code>.</font></p><p><font size="3">In a normal case where you are using an <b>ADO.NET</b> database (connecting and closing database) and displaying the records, e.g., in a <code>DataGrid</code>, you never need the <code>CurrencyManager</code> object. <i>But</i> if you want to know the exact position within a data structure (e.g., table in your database) as I did, you have to use the <code>CurrencyManager</code> object because the <code>CurrencyManager</code> has the <code>Position</code> property for this purpose. You can, for example, manipulate the <code>Position</code> property in a Next or Previous or First or Last button which I did in my program as well.<br />For example:<br />If you want to know how many records are in a <code>DataTable</code>, you simply query the <code>BindingContext</code> object's <code>Count</code> property<br /><font color="#ff0000">this.BindingContext[dataset1,"PersonTable"].Count - 1 ;<br /></font><font color="#000000">If you want to get the current position from the <code>BindingContext</code> object:<br /></font><font color="#ff3366"><font color="#ff0000">this.BindingContext[dataset1, "PersonTable"].Position + 1;<br /></font></font></font></p><p><font color="#000000">After data binding, you call and initialize <code>CurrencyManager</code> for your table. Here is the method I used to initialize the <code>CurrencyManager</code> for the table <i>"PersonTable"</i>:<br /></font><font color="#ff0000">public void fnSetCurrencyManager()<br />{<br />  currManager = (CurrencyManager)this.<br />  BindingContext [ datc.dSet.Tables["PersonTable"]] ;<br />}</font></p></font>
<img src ="http://www.cnitblog.com/wuming3000/aggbug/18471.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/wuming3000/" target="_blank">开始编程</a> 2006-10-26 20:14 <a href="http://www.cnitblog.com/wuming3000/archive/2006/10/26/18471.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C#用户窗体登陆设计</title><link>http://www.cnitblog.com/wuming3000/archive/2006/10/26/18470.html</link><dc:creator>开始编程</dc:creator><author>开始编程</author><pubDate>Thu, 26 Oct 2006 11:57:00 GMT</pubDate><guid>http://www.cnitblog.com/wuming3000/archive/2006/10/26/18470.html</guid><wfw:comment>http://www.cnitblog.com/wuming3000/comments/18470.html</wfw:comment><comments>http://www.cnitblog.com/wuming3000/archive/2006/10/26/18470.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.cnitblog.com/wuming3000/comments/commentRss/18470.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/wuming3000/services/trackbacks/18470.html</trackback:ping><description><![CDATA[
		<p>
				<font size="2">做为学习过程中的札记 所写的都是本人自己的一些设计写法 只是想记录一下学习的点点嘀嘀。<br />转入正题：利用数据库提取用户验证信息实现登陆。<br />priviate void button1_Click(object sender,System.EventArgs e)<br />{<br />       SqlConnection conn=new SqlConnection("@Data Source="(local);Integrated Security=SSPI;Initial Catalog=DBApp"");<br />       SqlCommand cmd=conn.CreateCommand();<br />       cmd.CommandType=CommandType.Text;<br />     cmd.CommandType = CommandType.Text;<br />            if (txtUserName.Text.Length == 0)<br />            {<br />                MessageBox.Show("用户不能为空，请查询后输入");<br />                txtPassWord.Focus();<br />                return;<br />            }<br />            cmd.CommandText = "select count(*) from UserList where UserName='" + txtUserName.Text + "'";<br />            conn.Open();<br />            if ((int)cmd.ExecuteScalar() == 0)<br />            {<br />                MessageBox.Show("不存在此用户，请检查后重新输入");<br />                txtPassWord.Focus();<br />                return;<br />            }<br />            cmd.CommandText = "select UserName, PassWord from UserList where PassWord='" +txtPassWord .Text + "'";<br />            SqlDataReader myReader = cmd.ExecuteReader();<br />            if (myReader.Read())<br />            {<br />                if (txtPassWord.Text == myReader[0].ToString() &amp;&amp; txtUserName.Text.Length != 0) ;<br />                MessageBox.Show("登录成功", "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);<br />                frmMain fm = new frmMain();<br />                fm.ShowDialog();<br />            }</font>
		</p>
		<p>
				<font size="2">            else<br />            {<br />                MessageBox.Show("用户" + txtUserName.Text + "的密码不正确", "密码", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);<br />                txtPassWord.Focus();<br />                return;<br />            }<br />        }</font>
		</p>
		<p>
				<font size="2">        private void button2_Click(object sender, EventArgs e)<br />        {<br />            this.Close();<br />        }<br />}</font>
		</p>
<img src ="http://www.cnitblog.com/wuming3000/aggbug/18470.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/wuming3000/" target="_blank">开始编程</a> 2006-10-26 19:57 <a href="http://www.cnitblog.com/wuming3000/archive/2006/10/26/18470.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>