C# UserControl未更新到表
问题 只有当我尝试插入时,问题才会出现。但是我可以浏览记录。当我插入一个新的记录时,USER控件不考虑我键入的值,而是将它存储为NULL。我基本上认为在新唱片上,它不同步 表单布局 用户控制的目的 DB以JKB-932340094VN00的形式存储字段值,我使用我的UserControl按-分割值,并在其中的2个文本框中显示它。因此,一个文本框的值为JKB,另一个文本框的值为932340094VN00 UserControl如下所示:C# UserControl未更新到表,c#,winforms,user-controls,oracle9i,C#,Winforms,User Controls,Oracle9i,问题 只有当我尝试插入时,问题才会出现。但是我可以浏览记录。当我插入一个新的记录时,USER控件不考虑我键入的值,而是将它存储为NULL。我基本上认为在新唱片上,它不同步 表单布局 用户控制的目的 DB以JKB-932340094VN00的形式存储字段值,我使用我的UserControl按-分割值,并在其中的2个文本框中显示它。因此,一个文本框的值为JKB,另一个文本框的值为932340094VN00 UserControl如下所示: public partial class ucClientA
public partial class ucClientAccountIDParser : UserControl, INotifyPropertyChanged
{
public ucClientAccountIDParser()
{
InitializeComponent();
id = "JKB-821230063VN00";
txtClientAccountID.TextChanged += new EventHandler(clientaccountIDChanged);
txtCustodyID.TextChanged += new EventHandler(custodyIDChanged);
}
private string _clientaccountID = string.Empty;
public string ClientaccountID
{
get { return _clientaccountID; }
set
{
_clientaccountID = value;
txtClientAccountID.Text = this._clientaccountID;
}
}
private string _custodyID = string.Empty;
public string CustodyID
{
get { return _custodyID; }
set
{
_custodyID = value;
txtCustodyID.Text = this._custodyID;
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
public string id = string.Empty;
[System.ComponentModel.Bindable(true)]
public string Text
{
get
{
return id;
}
set
{
id = value;
if (id != null)
{
string[] aVal = id.Split('-');
if (aVal.Length > 1)
{
this.CustodyID = aVal[0];
this.ClientaccountID = aVal[1];
}
else
{
this.ClientaccountID = id;
}
}
else
{
this.CustodyID = string.Empty;
this.ClientaccountID = string.Empty;
}
NotifyPropertyChanged(id);
}
}
public void NotifyPropertyChanged(string info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("Text"));
}
}
private void clientaccountIDChanged(object sender, EventArgs e)
{
this.id = string.Format("{0}-{1}", txtCustodyID.Text, (sender as TextBox).Text);
NotifyPropertyChanged(this.id);
}
private void custodyIDChanged(object sender, EventArgs e)
{
this.id = string.Format("{0}-{1}", (sender as TextBox).Text, txtClientAccountID.Text);
NotifyPropertyChanged(this.id);
}
}
我是这样绑定它的:
我不明白为什么需要空值。让我知道我是否以正确的方式进行了UserControl的设计
我希望任何人都能帮助我。保存操作的代码在哪里?这可能是问题所在。是的,我修改了UserControl中的一些内容,效果很好。作为一个结果,我有了新的插曲,所以打开了一个新的帖子。我能够从中提取代码。再次感谢!如果你的问题解决了,你可以删除帖子。
try
{
this.Init(null);
this.Text = "General Account Add/Change";
objTable = new ClientAccountBusinessTable();
this.PrimaryDataAdapters = new ClientAccountBusinessTable[1] { objTable };
this.PrimaryDataGridView = null;
objTable.KeyDBField = "CLIENTID";
PrimaryBindingSource = new BindingSource[1] { bindingSource1 };
PrimaryDataSet.Tables.Add(objTable.GetBusinessTable());
SetKeyDBControl(new Control[1] { ucClientAccountIDParser1 }, new string[1] { "CLIENTID" });
ucClientAccountIDParser1.DataBindings.Clear();
ucClientAccountIDParser1.DataBindings.Add(new Binding("Text", this.bindingSource1, "CLIENTID"));
bindingSource1.DataMember = this.PrimaryDataSet.Tables[0].TableName;
bindingSource1.DataSource = this.PrimaryDataSet;
}
catch (Exception ex)
{
objTable = null;
throw ex;
}