绑定导航器 [英] Binding Navigator

查看:74
本文介绍了绑定导航器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示记录并使用Binding Navigator的表单,我以前从未需要使用它。

I have a form that displays a record and uses a Binding Navigator, which I have never previously needed to use much.

这对我来说没有问题使用绑定导航器显示不同的记录,前提是我已将所有控件DataBinding属性设置为相应的表。

This presents no problem with me being able to use the binding navigator to display through the different records, provided I have set all of the controls DataBinding properties to the appropriate table.

但是,我想要做的是能够将这个相同的表单用于我使用的几个查找表中的任何一个。

However, What I want to do is be able to use this same form for any of several lookup tables that I use.

在我惯常的天真中,我相信这将是相对容易和直接的。 唉,我又一次感到很失望。

In my usual naivety, I believed this would be relatively easy and straight forward.  Alas, I was once again disappointed.

使用下面的代码我可以得到与上面相同的显示。 但是,虽然Binding Navigator表现出预期,但数据的显示没有改变。

Using the code below I was able to get the same display as above.  However, while the Binding Navigator behaved has expected, the display of the data did not change.

我一直无法弄清楚还有什么需要获取Binding Navigator并显示数据在控件中。

I have been unable to figure out what else is needed to get the Binding Navigator and the data displayed in the controls together.

                    'Department
                    Dim strTable As String = "lkpDepartment"
                    Dim strDepartment As String = "chrDepartment"
                    Dim strCode As String = "chrCode"
                    Dim strDescription As String = "chrDescription"
                    frmSettingsLookUp.LkpDepartmentTableAdapter.Fill(frmSettingsLookUp._MasterBase_1_1DataSet.lkpDepartment)
                    With frmSettingsLookUp
                        .txtName.DataBindings.Add(New Binding("Text", frmSettingsLookUp._MasterBase_1_1DataSet, $"{strTable}.{strDepartment}"))
                        .txtCode.DataBindings.Add(New Binding("Text", frmSettingsLookUp._MasterBase_1_1DataSet, $"{strTable}.{strCode}"))
                        .txtDescription.DataBindings.Add(New Binding("Text", frmSettingsLookUp._MasterBase_1_1DataSet, $"{strTable}.{strDescription}"))
                        .frmSettingsLookUpBindingNavigator.BindingSource = frmSettingsLookUp.lkpDepartmentBindingSource
                    End With

gwboolean

gwboolean

推荐答案

您好, 

Hello, 

使用TableA在处理数据时,dapter组件会限制许多操作的灵活性。此外,具有不同的表通常意味着不同的字段,因此这将是您已经完成定义TextBox控件的问题。你最好(取决于
有多少查找表)隐藏和显示表单上的面板,其中每个面板代表一个查找表。

Using TableAdapter components do restrict flexibility of many operations when working with data. Also, having different tables usually means different fields so that would be an issue with defining TextBox controls as you have done. You are better off (depending how many lookup tables there are) hiding and showing panels on the form where each panel represents a lookup table.

在旁注上,有没有理由在数据绑定到控件时使用New Binding。

On a side note, there is no reason to use New Binding when data binding to controls.


这篇关于绑定导航器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆