LzmTW.uSystem.uWindows.uForms + GridPropertyForm

Author:水如烟  

Namespace  LzmTW.uSystem.uWindows.uForms
    
Friend   Class  GridPropertyForm

        
Private   Sub  HScrollBar_Scroll( ByVal  sender  As  System.Object,  ByVal  e  As  System.Windows.Forms.ScrollEventArgs)  Handles  HScrollBar.Scroll
            
Me .Opacity  =  HScrollBar.Value  /   100
        
End Sub

        
Private   WithEvents  gDataGridView  As  DataGridView
        
Private  gCurrentRow  As  DataGridViewRow
        
Private  gFormatString  As   String   =   ""

        
Public   Overloads   Sub  Show( ByVal  datagridview  As  DataGridView)
            
Me .gDataGridView  =  datagridview
            
Me .Show(datagridview.FindForm)
        
End Sub

        
Private   Sub  gDataGridView_CurrentCellChanged( ByVal  sender  As   Object ByVal  e  As  System.EventArgs)  Handles  gDataGridView.CurrentCellChanged
            
If  gDataGridView.CurrentRow  Is   Nothing   Then   Exit Sub
            
If  gDataGridView.Columns.Count  =   0   Then   Exit Sub

            
If  gDataGridView.CurrentRow.Equals(gCurrentRow)  Then   Exit Sub
            gCurrentRow 
=  gDataGridView.CurrentRow
            ShowRowInformation()
        
End Sub

        
Private   Sub  ShowRowInformation()
            
Me .RichTextBox.Clear()
            Converter.Input(gCurrentRow)
            
Me .RichTextBox.Text  =  Converter.ToString
        
End Sub

        
Private   Sub  TabControl1_SelectedIndexChanged( ByVal  sender  As   Object ByVal  e  As  System.EventArgs)  Handles  TabControl1.SelectedIndexChanged
            
If   Me .TabControl1.SelectedIndex  =   0   Then   Exit Sub
            
If   Me .gDataGridView.Columns.Count  =   0   Then   Exit Sub

            
Me .TreeView1.Nodes.Clear()

            
Dim  mRoot  As  TreeNode  =   New  TreeNode( " DataGrid " )

            
With  mRoot

                
For   Each  c  As  DataGridViewColumn  In   Me .gDataGridView.Columns
                    .Nodes.Add(c.DataPropertyName)
                
Next

            
End   With

            
Me .TreeView1.Nodes.Add(mRoot)

        
End Sub

        
Private   Sub  TreeView1_AfterSelect( ByVal  sender  As   Object ByVal  e  As  System.Windows.Forms.TreeViewEventArgs)  Handles  TreeView1.AfterSelect
            
If  e.Node  Is   Nothing   Then   Exit Sub

            
If  e.Node.Equals( Me .TreeView1.Nodes( 0 ))  Then
                
Me .PropertyGrid1.SelectedObject  =   Me .gDataGridView
            
Else
                
Me .PropertyGrid1.SelectedObject  =   Me .gDataGridView.Columns(e.Node.Text)
            
End   If
        
End Sub


        
Private   Class  Converter
            
Private   Shared  gDataGridViewRow  As  DataGridViewRow
            
Private   Shared  gRowString  As   String   =   ""

            
Public   Shared   Sub   Input ( ByVal  datagridviewrow  As  DataGridViewRow)
                gDataGridViewRow 
=  datagridviewrow
                GetString()
            
End Sub

            
Private   Shared   Sub  GetString()
                
Dim  mCount  As   Integer   =  gDataGridViewRow.DataGridView.Columns.Count
                
Dim  mMaxLen  As   Integer   =   0
                
Dim  mName  As   String   =   ""

                
For  index  As   Integer   =   0   To  mCount  -   1
                    mName 
=  gDataGridViewRow.DataGridView.Columns(index).Name
                    mMaxLen 
=  Math.Max(mMaxLen, uString.Length(mName))
                
Next

                
Dim  b  As   New  System.Text.StringBuilder
                
For  index  As   Integer   =   0   To  mCount  -   1
                    b.AppendLine(uString.PadLeft(gDataGridViewRow.DataGridView.Columns(index).Name, mMaxLen) 
&   " "   &  gDataGridViewRow.Cells(index).Value.ToString)
                
Next

                gRowString 
=  b.ToString
            
End Sub

            
Public   Overloads   Shared   Function  ToString()  As   String
                
Return  gRowString
            
End Function

        
End Class

    
End Class
End Namespace

 

Namespace  LzmTW.uSystem.uWindows.uForms
    
< Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated() >  _
    
Partial   Class  GridPropertyForm
        
Inherits  System.Windows.Forms.Form

        
' Form 重写 Dispose,以清理组件列表。
         < System.Diagnostics.DebuggerNonUserCode() >  _
        
Protected   Overrides   Sub  Dispose( ByVal  disposing  As   Boolean )
            
If  disposing  AndAlso  components  IsNot   Nothing   Then
                components.Dispose()
            
End   If
            
MyBase .Dispose(disposing)
        
End Sub

        
' Windows 窗体设计器所必需的
         Private  components  As  System.ComponentModel.IContainer

        
' 注意: 以下过程是 Windows 窗体设计器所必需的
         ' 可以使用 Windows 窗体设计器修改它。
         ' 不要使用代码编辑器修改它。
         < System.Diagnostics.DebuggerStepThrough() >  _
        
Private   Sub  InitializeComponent()
            
Me .TabControl1  =   New  System.Windows.Forms.TabControl
            
Me .TabPage1  =   New  System.Windows.Forms.TabPage
            
Me .Label1  =   New  System.Windows.Forms.Label
            
Me .HScrollBar  =   New  System.Windows.Forms.HScrollBar
            
Me .RichTextBox  =   New  System.Windows.Forms.RichTextBox
            
Me .TabPage2  =   New  System.Windows.Forms.TabPage
            
Me .PropertyGrid1  =   New  System.Windows.Forms.PropertyGrid
            
Me .TreeView1  =   New  System.Windows.Forms.TreeView
            
Me .TabControl1.SuspendLayout()
            
Me .TabPage1.SuspendLayout()
            
Me .TabPage2.SuspendLayout()
            
Me .SuspendLayout()
            
'
             ' TabControl1
             '
             Me .TabControl1.Controls.Add( Me .TabPage1)
            
Me .TabControl1.Controls.Add( Me .TabPage2)
            
Me .TabControl1.Dock  =  System.Windows.Forms.DockStyle.Fill
            
Me .TabControl1.Location  =   New  System.Drawing.Point( 0 0 )
            
Me .TabControl1.Name  =   " TabControl1 "
            
Me .TabControl1.SelectedIndex  =   0
            
Me .TabControl1.Size  =   New  System.Drawing.Size( 550 424 )
            
Me .TabControl1.TabIndex  =   0
            
'
             ' TabPage1
             '
             Me .TabPage1.Controls.Add( Me .Label1)
            
Me .TabPage1.Controls.Add( Me .HScrollBar)
            
Me .TabPage1.Controls.Add( Me .RichTextBox)
            
Me .TabPage1.Location  =   New  System.Drawing.Point( 4 21 )
            
Me .TabPage1.Name  =   " TabPage1 "
            
Me .TabPage1.Padding  =   New  System.Windows.Forms.Padding( 3 )
            
Me .TabPage1.Size  =   New  System.Drawing.Size( 542 399 )
            
Me .TabPage1.TabIndex  =   0
            
Me .TabPage1.Text  =   " 当前行数据 "
            
Me .TabPage1.UseVisualStyleBackColor  =   True
            
'
             ' Label1
             '
             Me .Label1.Anchor  =   CType ((System.Windows.Forms.AnchorStyles.Bottom  Or  System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            
Me .Label1.AutoSize  =   True
            
Me .Label1.Location  =   New  System.Drawing.Point( 371 382 )
            
Me .Label1.Name  =   " Label1 "
            
Me .Label1.Size  =   New  System.Drawing.Size( 65 12 )
            
Me .Label1.TabIndex  =   4
            
Me .Label1.Text  =   " 调整透明度 "
            
'
             ' HScrollBar
             '
             Me .HScrollBar.Anchor  =   CType ((System.Windows.Forms.AnchorStyles.Bottom  Or  System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            
Me .HScrollBar.Location  =   New  System.Drawing.Point( 439 374 )
            
Me .HScrollBar.Maximum  =   105
            
Me .HScrollBar.Minimum  =   20
            
Me .HScrollBar.Name  =   " HScrollBar "
            
Me .HScrollBar.Size  =   New  System.Drawing.Size( 98 20 )
            
Me .HScrollBar.TabIndex  =   3
            
Me .HScrollBar.Value  =   105
            
'
             ' RichTextBox
             '
             Me .RichTextBox.Anchor  =   CType ((((System.Windows.Forms.AnchorStyles.Top  Or  System.Windows.Forms.AnchorStyles.Bottom) _
                        
Or  System.Windows.Forms.AnchorStyles.Left) _
                        
Or  System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            
Me .RichTextBox.BackColor  =  System.Drawing.SystemColors.Info
            
Me .RichTextBox.Location  =   New  System.Drawing.Point( 0 0 )
            
Me .RichTextBox.Name  =   " RichTextBox "
            
Me .RichTextBox.Size  =   New  System.Drawing.Size( 542 371 )
            
Me .RichTextBox.TabIndex  =   1
            
Me .RichTextBox.Text  =   ""
            
'
             ' TabPage2
             '
             Me .TabPage2.Controls.Add( Me .PropertyGrid1)
            
Me .TabPage2.Controls.Add( Me .TreeView1)
            
Me .TabPage2.Location  =   New  System.Drawing.Point( 4 21 )
            
Me .TabPage2.Name  =   " TabPage2 "
            
Me .TabPage2.Padding  =   New  System.Windows.Forms.Padding( 3 )
            
Me .TabPage2.Size  =   New  System.Drawing.Size( 542 399 )
            
Me .TabPage2.TabIndex  =   1
            
Me .TabPage2.Text  =   " 表格属性 "
            
Me .TabPage2.UseVisualStyleBackColor  =   True
            
'
             ' PropertyGrid1
             '
             Me .PropertyGrid1.Anchor  =   CType ((((System.Windows.Forms.AnchorStyles.Top  Or  System.Windows.Forms.AnchorStyles.Bottom) _
                        
Or  System.Windows.Forms.AnchorStyles.Left) _
                        
Or  System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            
Me .PropertyGrid1.Location  =   New  System.Drawing.Point( 192 0 )
            
Me .PropertyGrid1.Name  =   " PropertyGrid1 "
            
Me .PropertyGrid1.Size  =   New  System.Drawing.Size( 349 399 )
            
Me .PropertyGrid1.TabIndex  =   1
            
'
             ' TreeView1
             '
             Me .TreeView1.Anchor  =   CType (((System.Windows.Forms.AnchorStyles.Top  Or  System.Windows.Forms.AnchorStyles.Bottom) _
                        
Or  System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
            
Me .TreeView1.Location  =   New  System.Drawing.Point( 0 3 )
            
Me .TreeView1.Name  =   " TreeView1 "
            
Me .TreeView1.Size  =   New  System.Drawing.Size( 184 396 )
            
Me .TreeView1.TabIndex  =   0
            
'
             ' GridPropertyForm
             '
             Me .AutoScaleDimensions  =   New  System.Drawing.SizeF( 6.0 !,  12.0 !)
            
Me .AutoScaleMode  =  System.Windows.Forms.AutoScaleMode.Font
            
Me .ClientSize  =   New  System.Drawing.Size( 550 424 )
            
Me .Controls.Add( Me .TabControl1)
            
Me .FormBorderStyle  =  System.Windows.Forms.FormBorderStyle.SizableToolWindow
            
Me .Name  =   " GridPropertyForm "
            
Me .ShowInTaskbar  =   False
            
Me .Text  =   " 窗格信息 "
            
Me .TabControl1.ResumeLayout( False )
            
Me .TabPage1.ResumeLayout( False )
            
Me .TabPage1.PerformLayout()
            
Me .TabPage2.ResumeLayout( False )
            
Me .ResumeLayout( False )

        
End Sub
        
Friend   WithEvents  TabControl1  As  System.Windows.Forms.TabControl
        
Friend   WithEvents  TabPage1  As  System.Windows.Forms.TabPage
        
Friend   WithEvents  TabPage2  As  System.Windows.Forms.TabPage
        
Private   WithEvents  RichTextBox  As  System.Windows.Forms.RichTextBox
        
Private   WithEvents  HScrollBar  As  System.Windows.Forms.HScrollBar
        
Friend   WithEvents  PropertyGrid1  As  System.Windows.Forms.PropertyGrid
        
Friend   WithEvents  TreeView1  As  System.Windows.Forms.TreeView
        
Friend   WithEvents  Label1  As  System.Windows.Forms.Label
    
End Class
End Namespace
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值