首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > .NET > C#.NET > WinForm设计之UBindingNavigator
【标  题】:WinForm设计之UBindingNavigator
【关键字】:WinForm,UBindingNavigator
【来  源】:http://blog.csdn.net/lzmtw/archive/2006/11/27/1416436.aspx

WinForm设计之UBindingNavigator

Author:水如烟  

代码见应用类代码:LzmTW.uSystem.uWindows.uForms + uBindingNavigator  

示意图:

示例代码:

Imports System.Reflection

Public Class Form1
    
Private gNorthwind As New Northind

    
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
Me.UBindingNavigator1.SourceManager.Add(GetItem("Customers"))
        
Me.UBindingNavigator1.SourceManager.Add(GetItem("Employees"))

        
Dim t As New DataTable("测试一")
        
Dim b As New DataTable("测试二")
        
Dim c As New DataTable

        
With t
            .Columns.Add(
"列一")
            .Columns.Add(
"列二")
            .Rows.Add(
New Object() {"1""张三"})
            .Rows.Add(
New Object() {"2""李四"})
            .Rows.Add(
New Object() {"3""王五"})
            .Rows.Add(
New Object() {"4""钱六"})
            .AcceptChanges()
        
End With

        
With b
            .Columns.Add(
"列三")
            .Columns.Add(
"列四")
            .Rows.Add(
New Object() {"1""张三"})
            .Rows.Add(
New Object() {"2""李四"})
            .Rows.Add(
New Object() {"3""王五"})
            .Rows.Add(
New Object() {"4""钱六"})
            .Rows.Add(
New Object() {"5""张三"})
            .Rows.Add(
New Object() {"6""李四"})
            .Rows.Add(
New Object() {"7""王五"})
            .Rows.Add(
New Object() {"8""钱六"})
            .AcceptChanges()
        
End With

        
Dim m As New LzmTW.uSystem.uWindows.uForms.uMainForm.Menu.MenuManager
        m.GetDefault()
        m.UpdateTo(c)

        
With Me.UBindingNavigator1.SourceManager
            .Add(
New LzmTW.uSystem.uWindows.uForms.uBindingNavigator.TableInformation(t, t.TableName))
            .Add(
New LzmTW.uSystem.uWindows.uForms.uBindingNavigator.TableInformation(b, b.TableName))
            .Add(
New LzmTW.uSystem.uWindows.uForms.uBindingNavigator.TableInformation(c, c.TableName))
        
End With
    
End Sub


    
Private Function GetItem(ByVal table As StringAs LzmTW.uSystem.uWindows.uForms.uBindingNavigator.TableInformation
        
Dim mResult As New LzmTW.uSystem.uWindows.uForms.uBindingNavigator.TableInformation
        
With mResult
            .DataAdapter 
= gNorthwind.CreateAdapter(table)
            .KeyName 
= table
        
End With
        
Return mResult
    
End Function
End Class

 

Public Class Northind
    
Private gLoginInformation As New LzmTW.uSystem.uData.uSql.LoginInformations
    
Sub New()
        gLoginInformation.Database 
= "Northwind"
    
End Sub

    
Public Function CreateAdapter(ByVal table As StringAs SqlClient.SqlDataAdapter
        
Dim ad As New SqlClient.SqlDataAdapter(Me.GetSelectCommand(table))
        
Dim cb As New SqlClient.SqlCommandBuilder(ad)
        
Return ad
    
End Function

    
Private Function GetSelectCommand(ByVal table As StringAs SqlClient.SqlCommand
        
Return New SqlClient.SqlCommand(String.Format("SELECT * FROM {0}", table), Me.GetConnection)
    
End Function

    
Private Function GetConnection() As SqlClient.SqlConnection
        
Return New SqlClient.SqlConnection(Me.gLoginInformation.ConnectionStringBuilder.ConnectionString)
    
End Function
End Class

效果图:

求解:《C#高级编程》第11章“反射”问题!谢谢大虾啦……:【上一篇】
.net中正则表达式的客户端验证--javascript:【下一篇】
【相关文章】
  • .net 2.0 webservice 异步调用在winform中的使用例子。
  • WinForm设计之ToolPanelTree
  • WinForm设计之状态栏
  • .NET改变WinForms的DataGrid.CurrentCell
  • 如何在C#的WinForm中制作饼状图和柱状图
  • WinForm中单个窗体实现P2P聊天程序(Socket,TcpListener,TcpClient,Thread,)
  • 使用 Flash 和 C# WinForm 配合打造界面漂亮的应用程序(摘要)
  • .Net 2.0 Winform部署和安装
  • Winform DataGird ,对最后一行MouseDown的Bug,郁闷
  • .net2003下TreeView控件在winForm与webForm的比较
  • 【随机文章】
  • IBM服务器配件全线产品型号参数
  • 一个简单的日期控件
  • More Effective C++之33
  • 多选下拉菜单的一个实现方案 by unifly
  • 提高ASP性能的最佳选择(三)
  • 破解Serializer(CoDe_InSiDe)
  • 把文件写入变量(已测)
  • 三层架构之我见 —— 不同于您见过的三层架构。
  • 火树银花的夜晚
  • Create the /usr/bin/sign.sh program file
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.