project 3 com380
Signed-off-by: Amrit Panesar <apanesar-77260@student.coleman.edu>
No files matched your search
@@ -0,0 +1,21 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VBWinFormDataGridView", "VBWinFormDataGridView\VBWinFormDataGridView.vbproj", "{27D2633B-4F34-466C-9177-BCCE6CA02AE6}"
|
||||
EndProject
|
||||
Global
|
||||
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{27D2633B-4F34-466C-9177-BCCE6CA02AE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{27D2633B-4F34-466C-9177-BCCE6CA02AE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{27D2633B-4F34-466C-9177-BCCE6CA02AE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{27D2633B-4F34-466C-9177-BCCE6CA02AE6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.diagnostics>
|
||||
<sources>
|
||||
<!-- This section defines the logging configuration for My.Application.Log -->
|
||||
<source name="DefaultSource" switchName="DefaultSwitch">
|
||||
<listeners>
|
||||
<add name="FileLog"/>
|
||||
<!-- Uncomment the below section to write to the Application Event Log -->
|
||||
<!--<add name="EventLog"/>-->
|
||||
</listeners>
|
||||
</source>
|
||||
</sources>
|
||||
<switches>
|
||||
<add name="DefaultSwitch" value="Information"/>
|
||||
</switches>
|
||||
<sharedListeners>
|
||||
<add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter"/>
|
||||
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
|
||||
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
|
||||
</sharedListeners>
|
||||
</system.diagnostics>
|
||||
|
||||
<appSettings>
|
||||
<add key="connectionString" value="Persist Security Info=False;Integrated Security=SSPI;Initial Catalog=Northwind;server=.\SQLEXPRESS"/>
|
||||
</appSettings>
|
||||
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
|
||||
@@ -0,0 +1,68 @@
|
||||
Namespace VBWinFormDataGridView.CustomDataGridViewColumn
|
||||
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||
Partial Class MainForm
|
||||
Inherits System.Windows.Forms.Form
|
||||
|
||||
'Form overrides dispose to clean up the component list.
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
Try
|
||||
If disposing AndAlso components IsNot Nothing Then
|
||||
components.Dispose()
|
||||
End If
|
||||
Finally
|
||||
MyBase.Dispose(disposing)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Required by the Windows Form Designer
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
'NOTE: The following procedure is required by the Windows Form Designer
|
||||
'It can be modified using the Windows Form Designer.
|
||||
'Do not modify it using the code editor.
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(MainForm))
|
||||
Me.label2 = New System.Windows.Forms.Label
|
||||
Me.employeesDataGridView = New System.Windows.Forms.DataGridView
|
||||
CType(Me.employeesDataGridView, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'label2
|
||||
'
|
||||
Me.label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
||||
Me.label2.Location = New System.Drawing.Point(27, 24)
|
||||
Me.label2.Name = "label2"
|
||||
Me.label2.Size = New System.Drawing.Size(580, 87)
|
||||
Me.label2.TabIndex = 5
|
||||
Me.label2.Text = resources.GetString("label2.Text")
|
||||
'
|
||||
'employeesDataGridView
|
||||
'
|
||||
Me.employeesDataGridView.Location = New System.Drawing.Point(30, 124)
|
||||
Me.employeesDataGridView.Name = "employeesDataGridView"
|
||||
Me.employeesDataGridView.RowTemplate.Height = 21
|
||||
Me.employeesDataGridView.Size = New System.Drawing.Size(577, 299)
|
||||
Me.employeesDataGridView.TabIndex = 4
|
||||
'
|
||||
'MainForm
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.ClientSize = New System.Drawing.Size(634, 446)
|
||||
Me.Controls.Add(Me.label2)
|
||||
Me.Controls.Add(Me.employeesDataGridView)
|
||||
Me.Name = "MainForm"
|
||||
Me.Text = "DataGridViewCustomColumn Sample"
|
||||
CType(Me.employeesDataGridView, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
Me.ResumeLayout(False)
|
||||
|
||||
End Sub
|
||||
Private WithEvents label2 As System.Windows.Forms.Label
|
||||
Private WithEvents employeesDataGridView As System.Windows.Forms.DataGridView
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="label2.Text" xml:space="preserve">
|
||||
<value>This sample demonstrates the use of custom column definitions within the Windows Forms DataGridView control.
|
||||
|
||||
The Employee ID, SSN, State and Zip Code columns use MaskedTextBox controls for format and validate their input.
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,206 @@
|
||||
'************************************* Module Header **************************************\
|
||||
' Module Name: MaskedTextBoxColumn.vb
|
||||
' Project: VBWinFormDataGridView
|
||||
' Copyright (c) Microsoft Corporation.
|
||||
'
|
||||
' This sample demonstrates the use of custom column definitions within the Windows Forms
|
||||
' DataGridView control.
|
||||
'
|
||||
' The Employee ID, SSN, State and Zip Code columns use MaskedTextBox controls for format
|
||||
' and validate their input.
|
||||
'
|
||||
' This source is subject to the Microsoft Public License.
|
||||
' See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
' All other rights reserved.
|
||||
|
||||
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
'**********************************************************************************/
|
||||
|
||||
Imports System.Text
|
||||
|
||||
Namespace VBWinFormDataGridView.CustomDataGridViewColumn
|
||||
|
||||
Public Class MainForm
|
||||
Inherits Form
|
||||
|
||||
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
||||
Dim dgvTextBoxColumn As DataGridViewTextBoxColumn
|
||||
Dim mtbColumn As MaskedTextBoxColumn
|
||||
'
|
||||
' Employee name.
|
||||
'
|
||||
dgvTextBoxColumn = New DataGridViewTextBoxColumn()
|
||||
dgvTextBoxColumn.HeaderText = "Name"
|
||||
dgvTextBoxColumn.Width = 120
|
||||
Me.employeesDataGridView.Columns.Add(dgvTextBoxColumn)
|
||||
|
||||
'
|
||||
' Employee ID -- this will be of the format:
|
||||
' [A-Z][0-9][0-9][0-9][0-9][0-9]
|
||||
'
|
||||
' this is well sutied to using a MaskedTextBox column.
|
||||
'
|
||||
mtbColumn = New MaskedTextBoxColumn()
|
||||
mtbColumn.HeaderText = "Employee ID"
|
||||
mtbColumn.Mask = "L00000"
|
||||
mtbColumn.Width = 75
|
||||
Me.employeesDataGridView.Columns.Add(mtbColumn)
|
||||
|
||||
'
|
||||
' [American] Social Security number, of the format:
|
||||
' ###-##-####
|
||||
'
|
||||
mtbColumn = New MaskedTextBoxColumn()
|
||||
mtbColumn.HeaderText = "SSN"
|
||||
mtbColumn.Mask = "000-00-0000"
|
||||
mtbColumn.Width = 75
|
||||
Me.employeesDataGridView.Columns.Add(mtbColumn)
|
||||
|
||||
'
|
||||
' Address
|
||||
'
|
||||
dgvTextBoxColumn = New DataGridViewTextBoxColumn()
|
||||
dgvTextBoxColumn.HeaderText = "Address"
|
||||
dgvTextBoxColumn.Width = 150
|
||||
Me.employeesDataGridView.Columns.Add(dgvTextBoxColumn)
|
||||
|
||||
'
|
||||
' City
|
||||
'
|
||||
dgvTextBoxColumn = New DataGridViewTextBoxColumn()
|
||||
dgvTextBoxColumn.HeaderText = "City"
|
||||
dgvTextBoxColumn.Width = 75
|
||||
Me.employeesDataGridView.Columns.Add(dgvTextBoxColumn)
|
||||
|
||||
'
|
||||
' State
|
||||
'
|
||||
mtbColumn = New MaskedTextBoxColumn()
|
||||
mtbColumn.HeaderText = "State"
|
||||
mtbColumn.Mask = "LL"
|
||||
mtbColumn.Width = 40
|
||||
Me.employeesDataGridView.Columns.Add(mtbColumn)
|
||||
|
||||
'
|
||||
' Zip Code #####-#### (+4 optional)
|
||||
'
|
||||
mtbColumn = New MaskedTextBoxColumn()
|
||||
mtbColumn.HeaderText = "Zip Code"
|
||||
mtbColumn.Mask = "00000-0000"
|
||||
mtbColumn.Width = 75
|
||||
mtbColumn.ValidatingType = GetType(ZipCode)
|
||||
Me.employeesDataGridView.Columns.Add(mtbColumn)
|
||||
|
||||
'
|
||||
' Department Code
|
||||
'
|
||||
dgvTextBoxColumn = New DataGridViewTextBoxColumn()
|
||||
dgvTextBoxColumn.HeaderText = "Department"
|
||||
dgvTextBoxColumn.ValueType = GetType(Integer)
|
||||
dgvTextBoxColumn.Width = 75
|
||||
Me.employeesDataGridView.Columns.Add(dgvTextBoxColumn)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
#Region "ZipCode Class"
|
||||
Public Class ZipCode
|
||||
Private zipCode As Integer
|
||||
Private plusFour As Integer
|
||||
|
||||
Public Sub New()
|
||||
Me.zipCode = 0
|
||||
Me.plusFour = 0
|
||||
End Sub
|
||||
|
||||
Public Sub New(ByVal in_zipCode As String)
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub New(ByVal in_ivalue)
|
||||
Me.zipCode = in_ivalue
|
||||
Me.plusFour = 0
|
||||
End Sub
|
||||
|
||||
Public Shared Narrowing Operator CType(ByVal s As String) As ZipCode
|
||||
Return New ZipCode(s)
|
||||
End Operator
|
||||
|
||||
Public Shared Narrowing Operator CType(ByVal i As Integer) As ZipCode
|
||||
Return New ZipCode(i)
|
||||
End Operator
|
||||
|
||||
Protected Shared Sub parseFromString(ByVal in_string As String, ByRef out_zipCode As Integer, _
|
||||
ByRef out_plusFour As Integer)
|
||||
Dim zc As Integer = 0, pf = 0
|
||||
Dim charray As Char()
|
||||
Dim x As Integer = 0
|
||||
If in_string Is Nothing OrElse in_string.Equals("") Then
|
||||
Throw New ArgumentException("Invalid String")
|
||||
End If
|
||||
|
||||
charray = in_string.Trim().ToCharArray()
|
||||
|
||||
For x = 0 To 4
|
||||
If Not (Char.IsDigit(charray(x))) Then
|
||||
Throw New ArgumentException("Invalid String")
|
||||
End If
|
||||
zc = zc * 10 + numfromchar(charray(x))
|
||||
Next
|
||||
|
||||
While x < charray.Length AndAlso Not (Char.IsDigit(charray(x)))
|
||||
x = x + 1
|
||||
End While
|
||||
|
||||
If x < charray.Length Then
|
||||
For y As Integer = x To 3
|
||||
If Not (Char.IsDigit(charray(y))) Then
|
||||
Throw New ArgumentException("Invalid ZipCode String")
|
||||
End If
|
||||
pf = pf * 10 + numfromchar(charray(y))
|
||||
Next
|
||||
End If
|
||||
|
||||
out_zipCode = zc
|
||||
out_plusFour = pf
|
||||
End Sub
|
||||
|
||||
Private Shared Function numfromchar(ByVal c As Char)
|
||||
Select Case c
|
||||
Case "0"c
|
||||
Return 0
|
||||
Case "1"c
|
||||
Return 1
|
||||
Case "2"c
|
||||
Return 2
|
||||
Case "3"c
|
||||
Return 3
|
||||
Case "4"c
|
||||
Return 4
|
||||
Case "5"c
|
||||
Return 5
|
||||
Case "6"c
|
||||
Return 6
|
||||
Case "7"c
|
||||
Return 7
|
||||
Case "8"c
|
||||
Return 8
|
||||
Case "9"c
|
||||
Return 9
|
||||
Case Else
|
||||
Throw New ArgumentException("invalid digit")
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Public Overrides Function ToString() As String
|
||||
Dim sb As StringBuilder = New StringBuilder(10)
|
||||
sb.Append(zipCode.ToString("00000"))
|
||||
sb.Append("_")
|
||||
sb.Append(plusFour.ToString("0000"))
|
||||
Return sb.ToString()
|
||||
End Function
|
||||
End Class
|
||||
#End Region
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,158 @@
|
||||
'********************************* Module Header **********************************\
|
||||
' Module Name: MaskedTextBoxCell.vb
|
||||
' Project: VBWinFormDataGridView
|
||||
' Copyright (c) Microsoft Corporation.
|
||||
'
|
||||
' This sample demonstrates how to create a custom DataGridView column.
|
||||
'
|
||||
' This source is subject to the Microsoft Public License.
|
||||
' See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
' All other rights reserved.
|
||||
'
|
||||
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
'**********************************************************************************/
|
||||
|
||||
Namespace VBWinFormDataGridView.CustomDataGridViewColumn
|
||||
Public Class MaskedTextBoxCell
|
||||
Inherits DataGridViewTextBoxCell
|
||||
|
||||
Private _mask As String
|
||||
Private _promptChar As Char
|
||||
Private _includePrompt As DataGridViewTriState
|
||||
Private _includeLiterals As DataGridViewTriState
|
||||
Private _validatingType As Type
|
||||
|
||||
Public Sub New()
|
||||
Me._mask = ""
|
||||
Me._promptChar = "_"c
|
||||
Me._includePrompt = DataGridViewTriState.NotSet
|
||||
Me._includeLiterals = DataGridViewTriState.NotSet
|
||||
Me._validatingType = GetType(String)
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, _
|
||||
ByVal initialFormattedValue As Object, ByVal dataGridViewCellStyle As DataGridViewCellStyle)
|
||||
|
||||
Dim mtbEditingCtrl As MaskedTextBoxEditingControl
|
||||
Dim mtbColumn As MaskedTextBoxColumn
|
||||
Dim dgvColumn As DataGridViewColumn
|
||||
|
||||
MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, _
|
||||
dataGridViewCellStyle)
|
||||
|
||||
mtbEditingCtrl = CType(DataGridView.EditingControl, MaskedTextBoxEditingControl)
|
||||
|
||||
'
|
||||
' Set up props that are specific to the MaskedTextBox
|
||||
'
|
||||
|
||||
dgvColumn = Me.OwningColumn ' this.DataGridView.Columns[this.ColumnIndex];
|
||||
If TypeOf dgvColumn Is MaskedTextBoxColumn Then
|
||||
|
||||
mtbColumn = CType(dgvColumn, MaskedTextBoxColumn)
|
||||
End If
|
||||
'
|
||||
' get the mask from this instance or the parent column.
|
||||
'
|
||||
If String.IsNullOrEmpty(Me._mask) Then
|
||||
|
||||
mtbEditingCtrl.Mask = mtbColumn.Mask
|
||||
|
||||
Else
|
||||
mtbEditingCtrl.Mask = Me._mask
|
||||
'
|
||||
' Prompt char.
|
||||
'
|
||||
mtbEditingCtrl.PromptChar = Me._promptChar
|
||||
'
|
||||
' IncludePrompt
|
||||
'
|
||||
End If
|
||||
If Me._includePrompt = DataGridViewTriState.NotSet Then
|
||||
'mtbEditingCtrl.IncludePrompt = mtbcol.IncludePrompt
|
||||
Else
|
||||
'mtbEditingCtrl.IncludePrompt = BoolFromTri(Me.includePrompt)
|
||||
'
|
||||
' IncludeLiterals
|
||||
'
|
||||
End If
|
||||
|
||||
If Me._includeLiterals = DataGridViewTriState.NotSet Then
|
||||
'mtbEditingCtrl.IncludeLiterals = mtbcol.IncludeLiterals
|
||||
Else
|
||||
'mtbEditingCtrl.IncludeLiterals = BoolFromTri(Me.includeLiterals)
|
||||
End If
|
||||
'
|
||||
' Finally, the validating type ...
|
||||
'
|
||||
If Me.ValidatingType Is Nothing Then
|
||||
mtbEditingCtrl.ValidatingType = mtbColumn.ValidatingType
|
||||
Else
|
||||
mtbEditingCtrl.ValidatingType = Me.ValidatingType
|
||||
mtbEditingCtrl.Text = CType(Me.Value, String)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Overrides ReadOnly Property EditType() As System.Type
|
||||
Get
|
||||
Return GetType(MaskedTextBoxEditingControl)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Overridable Property Mask() As String
|
||||
Get
|
||||
Return Me._mask
|
||||
End Get
|
||||
Set(ByVal value As String)
|
||||
Me._mask = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Overridable Property PromptChar() As Char
|
||||
Get
|
||||
Return Me._promptChar
|
||||
End Get
|
||||
Set(ByVal value As Char)
|
||||
Me._promptChar = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Overridable Property IncludePrompt() As DataGridViewTriState
|
||||
Get
|
||||
Return Me._includePrompt
|
||||
End Get
|
||||
Set(ByVal value As DataGridViewTriState)
|
||||
Me._includePrompt = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Overridable Property IncludeLiterals() As DataGridViewTriState
|
||||
Get
|
||||
Return Me._includeLiterals
|
||||
End Get
|
||||
Set(ByVal value As DataGridViewTriState)
|
||||
Me._includeLiterals = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Overridable Property ValidatingType() As Type
|
||||
Get
|
||||
Return Me._validatingType
|
||||
End Get
|
||||
Set(ByVal value As Type)
|
||||
Me._validatingType = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Protected Shared Function BoolFromTri(ByVal tri As DataGridViewTriState) As Boolean
|
||||
If tri = DataGridViewTriState.True Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,217 @@
|
||||
'********************************* Module Header **********************************\
|
||||
' Module Name: MaskedTextBoxColumn.vb
|
||||
' Project: VBWinFormDataGridView
|
||||
' Copyright (c) Microsoft Corporation.
|
||||
'
|
||||
' This sample demonstrates how to create a custom DataGridView column.
|
||||
'
|
||||
' This source is subject to the Microsoft Public License.
|
||||
' See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
' All other rights reserved.
|
||||
|
||||
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
'**********************************************************************************/
|
||||
|
||||
Namespace VBWinFormDataGridView.CustomDataGridViewColumn
|
||||
|
||||
Public Class MaskedTextBoxColumn
|
||||
Inherits DataGridViewTextBoxColumn
|
||||
|
||||
Private _mask As String
|
||||
Private _promptChar As Char
|
||||
Private _includePrompt As Boolean
|
||||
Private _includeLiterals As Boolean
|
||||
Private _validatingType As Type
|
||||
|
||||
Public Sub New()
|
||||
MyBase.CellTemplate = New MaskedTextBoxCell
|
||||
End Sub
|
||||
|
||||
Private Shared Function TriBool(ByVal value As Boolean) As DataGridViewTriState
|
||||
If value Then
|
||||
Return DataGridViewTriState.True
|
||||
Else
|
||||
Return DataGridViewTriState.False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Overrides Property CellTemplate() As System.Windows.Forms.DataGridViewCell
|
||||
Get
|
||||
Return MyBase.CellTemplate
|
||||
End Get
|
||||
Set(ByVal value As System.Windows.Forms.DataGridViewCell)
|
||||
If value IsNot Nothing AndAlso Not value.GetType().IsAssignableFrom(GetType(MaskedTextBoxCell)) Then
|
||||
Dim s As String = "Cell type is not based upon the MaskedTextBoxCell."
|
||||
Throw New InvalidCastException(s)
|
||||
End If
|
||||
MyBase.CellTemplate = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Overridable Property Mask() As String
|
||||
Get
|
||||
Return Me._mask
|
||||
End Get
|
||||
Set(ByVal value As String)
|
||||
Dim mtbCell As MaskedTextBoxCell
|
||||
Dim dgvCell As DataGridViewCell
|
||||
Dim rowCount As Integer
|
||||
|
||||
If Me._mask <> value Then
|
||||
Me._mask = value
|
||||
'
|
||||
' First, update the value on the template cell.
|
||||
'
|
||||
mtbCell = DirectCast(Me.CellTemplate, MaskedTextBoxCell)
|
||||
mtbCell.Mask = value
|
||||
'
|
||||
' Now set it on all cells in other rows as well.
|
||||
'
|
||||
If Me.DataGridView IsNot Nothing AndAlso Me.DataGridView.Rows IsNot Nothing Then
|
||||
rowCount = Me.DataGridView.Rows.Count
|
||||
For x As Integer = 0 To rowCount - 1
|
||||
dgvCell = Me.DataGridView.Rows.SharedRow(x).Cells(x)
|
||||
If TypeOf dgvCell Is MaskedTextBoxCell Then
|
||||
mtbCell = CType(dgvCell, MaskedTextBoxCell)
|
||||
mtbCell.Mask = value
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Overridable Property PromptChar() As Char
|
||||
Get
|
||||
Return Me._promptChar
|
||||
End Get
|
||||
Set(ByVal value As Char)
|
||||
Dim mtbCell As MaskedTextBoxCell
|
||||
Dim dgvCell As DataGridViewCell
|
||||
Dim rowCount As Integer
|
||||
If Me._promptChar <> value Then
|
||||
Me._promptChar = value
|
||||
'
|
||||
' First, update the value on the template cell.
|
||||
'
|
||||
mtbCell = CType(Me.CellTemplate, MaskedTextBoxCell)
|
||||
mtbCell.PromptChar = value
|
||||
'
|
||||
' Now set it on all cells in other rows as well.
|
||||
'
|
||||
If Me.DataGridView IsNot Nothing AndAlso Me.DataGridView.Rows IsNot Nothing Then
|
||||
rowCount = Me.DataGridView.Rows.Count
|
||||
For x As Integer = 0 To rowCount - 1
|
||||
dgvCell = Me.DataGridView.Rows.SharedRow(x).Cells(x)
|
||||
If TypeOf dgvCell Is MaskedTextBoxCell Then
|
||||
mtbCell = CType(dgvCell, MaskedTextBoxCell)
|
||||
mtbCell.PromptChar = value
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Overridable Property IncludePrompt() As Boolean
|
||||
Get
|
||||
Return Me._includePrompt
|
||||
End Get
|
||||
Set(ByVal value As Boolean)
|
||||
Dim mtbc As MaskedTextBoxCell
|
||||
Dim dgvc As DataGridViewCell
|
||||
Dim rowCount As Integer
|
||||
If Me._includePrompt <> value Then
|
||||
Me._includePrompt = value
|
||||
|
||||
'
|
||||
' First, update the value on the template cell.
|
||||
'
|
||||
mtbc = CType(Me.CellTemplate, MaskedTextBoxCell)
|
||||
mtbc.IncludePrompt = TriBool(value)
|
||||
'
|
||||
' Now set it on all cells in other rows as well.
|
||||
'
|
||||
If Me.DataGridView IsNot Nothing AndAlso Me.DataGridView.Rows IsNot Nothing Then
|
||||
rowCount = Me.DataGridView.Rows.Count
|
||||
For x As Integer = 0 To rowCount - 1
|
||||
dgvc = Me.DataGridView.Rows.SharedRow(x).Cells(x)
|
||||
If TypeOf dgvc Is MaskedTextBoxCell Then
|
||||
mtbc = CType(dgvc, MaskedTextBoxCell)
|
||||
mtbc.IncludePrompt = TriBool(value)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Overridable Property IncludeLiterals() As Boolean
|
||||
Get
|
||||
Return Me._includeLiterals
|
||||
End Get
|
||||
Set(ByVal value As Boolean)
|
||||
Dim mtbCell As MaskedTextBoxCell
|
||||
Dim dgvCell As DataGridViewCell
|
||||
Dim rowCount As Integer
|
||||
If Me._includeLiterals <> value Then
|
||||
Me._includeLiterals = value
|
||||
'
|
||||
' First, update the value on the template cell.
|
||||
'
|
||||
mtbCell = CType(Me.CellTemplate, MaskedTextBoxCell)
|
||||
mtbCell.IncludeLiterals = TriBool(value)
|
||||
'
|
||||
' Now set it on all cells in other rows as well.
|
||||
'
|
||||
If Me.DataGridView IsNot Nothing AndAlso Me.DataGridView.Rows IsNot Nothing Then
|
||||
rowCount = Me.DataGridView.Rows.Count
|
||||
For x As Integer = 0 To rowCount - 1
|
||||
dgvCell = Me.DataGridView.Rows.SharedRow(x).Cells(x)
|
||||
If TypeOf dgvCell Is MaskedTextBoxCell Then
|
||||
mtbCell = CType(dgvCell, MaskedTextBoxCell)
|
||||
mtbCell.IncludeLiterals = TriBool(value)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Overridable Property ValidatingType() As Type
|
||||
Get
|
||||
Return Me._validatingType
|
||||
End Get
|
||||
Set(ByVal value As Type)
|
||||
Dim mtbCell As MaskedTextBoxCell
|
||||
Dim dgvCell As DataGridViewCell
|
||||
Dim rowCount As Integer
|
||||
If Me._validatingType IsNot value Then
|
||||
Me._validatingType = value
|
||||
'
|
||||
' First, update the value on the template cell.
|
||||
'
|
||||
mtbCell = CType(Me.CellTemplate, MaskedTextBoxCell)
|
||||
mtbCell.ValidatingType = value
|
||||
'
|
||||
' Now set it on all cells in other rows as well.
|
||||
'
|
||||
If Me.DataGridView IsNot Nothing AndAlso Me.DataGridView.Rows IsNot Nothing Then
|
||||
rowCount = Me.DataGridView.Rows.Count
|
||||
For x As Integer = 0 To rowCount - 1
|
||||
dgvCell = Me.DataGridView.Rows.SharedRow(x).Cells(x)
|
||||
If TypeOf dgvCell Is MaskedTextBoxCell Then
|
||||
mtbCell = CType(dgvCell, MaskedTextBoxCell)
|
||||
mtbCell.ValidatingType = value
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,169 @@
|
||||
'********************************* Module Header **********************************\
|
||||
' Module Name: MaskedTextBoxEditingControl.vb
|
||||
' Project: VBWinFormDataGridView
|
||||
' Copyright (c) Microsoft Corporation.
|
||||
'
|
||||
' This sample demonstrates how to create a custom DataGridView column.
|
||||
'
|
||||
' This source is subject to the Microsoft Public License.
|
||||
' See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
' All other rights reserved.
|
||||
|
||||
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
'**********************************************************************************/
|
||||
|
||||
Namespace VBWinFormDataGridView.CustomDataGridViewColumn
|
||||
|
||||
Public Class MaskedTextBoxEditingControl
|
||||
Inherits MaskedTextBox
|
||||
Implements IDataGridViewEditingControl
|
||||
|
||||
Private rowIndex As Integer
|
||||
Private dataGridView As DataGridView
|
||||
Private valueChanged As Boolean = False
|
||||
|
||||
Public Sub New()
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
|
||||
MyBase.OnTextChanged(e)
|
||||
' Let the DataGridView know about the value change
|
||||
NotifyDataGridViewOfValueChange()
|
||||
End Sub
|
||||
|
||||
Protected Sub NotifyDataGridViewOfValueChange()
|
||||
Me.valueChanged = True
|
||||
If Me.dataGridView IsNot Nothing Then
|
||||
Me.dataGridView.NotifyCurrentCellDirty(True)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#Region "IDataGridViewEditingControl Members"
|
||||
Public Sub ApplyCellStyleToEditingControl(ByVal dataGridViewCellStyle As System.Windows.Forms.DataGridViewCellStyle) Implements System.Windows.Forms.IDataGridViewEditingControl.ApplyCellStyleToEditingControl
|
||||
Me.Font = dataGridViewCellStyle.Font
|
||||
Me.ForeColor = dataGridViewCellStyle.ForeColor
|
||||
Me.BackColor = dataGridViewCellStyle.BackColor
|
||||
Me.TextAlign = translateAlignment(dataGridViewCellStyle.Alignment)
|
||||
End Sub
|
||||
|
||||
Public Property EditingControlDataGridView() As System.Windows.Forms.DataGridView Implements System.Windows.Forms.IDataGridViewEditingControl.EditingControlDataGridView
|
||||
Get
|
||||
Return Me.dataGridView
|
||||
End Get
|
||||
Set(ByVal value As System.Windows.Forms.DataGridView)
|
||||
Me.dataGridView = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property EditingControlFormattedValue() As Object Implements System.Windows.Forms.IDataGridViewEditingControl.EditingControlFormattedValue
|
||||
Get
|
||||
Return Me.Text
|
||||
End Get
|
||||
Set(ByVal value As Object)
|
||||
Me.Text = value.ToString()
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property EditingControlRowIndex() As Integer Implements System.Windows.Forms.IDataGridViewEditingControl.EditingControlRowIndex
|
||||
Get
|
||||
Return Me.rowIndex
|
||||
End Get
|
||||
Set(ByVal value As Integer)
|
||||
Me.rowIndex = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property EditingControlValueChanged() As Boolean Implements System.Windows.Forms.IDataGridViewEditingControl.EditingControlValueChanged
|
||||
Get
|
||||
|
||||
End Get
|
||||
Set(ByVal value As Boolean)
|
||||
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Function EditingControlWantsInputKey(ByVal keyData As System.Windows.Forms.Keys, ByVal dataGridViewWantsInputKey As Boolean) As Boolean Implements System.Windows.Forms.IDataGridViewEditingControl.EditingControlWantsInputKey
|
||||
Select Case keyData And Keys.KeyCode
|
||||
Case Keys.Right
|
||||
If Not (Me.SelectionLength = 0 AndAlso Me.SelectionStart = Me.ToString().Length) Then
|
||||
Return True
|
||||
End If
|
||||
Exit Select
|
||||
|
||||
Case Keys.Left
|
||||
If Not (Me.SelectionLength = 0 AndAlso Me.SelectionStart = 0) Then
|
||||
Return True
|
||||
End If
|
||||
Exit Select
|
||||
|
||||
Case Keys.Home
|
||||
Case Keys.End
|
||||
If Me.SelectionLength <> Me.ToString().Length Then
|
||||
Return True
|
||||
End If
|
||||
Exit Select
|
||||
|
||||
Case Keys.Prior
|
||||
Case Keys.Next
|
||||
If Me.valueChanged Then
|
||||
Return True
|
||||
End If
|
||||
Exit Select
|
||||
|
||||
Case Keys.Delete
|
||||
If Me.SelectionLength > 0 OrElse Me.SelectionStart < Me.ToString().Length Then
|
||||
Return True
|
||||
End If
|
||||
Exit Select
|
||||
End Select
|
||||
|
||||
Return Not dataGridViewWantsInputKey
|
||||
End Function
|
||||
|
||||
Public ReadOnly Property EditingPanelCursor() As System.Windows.Forms.Cursor Implements System.Windows.Forms.IDataGridViewEditingControl.EditingPanelCursor
|
||||
Get
|
||||
Return Cursors.IBeam
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Function GetEditingControlFormattedValue(ByVal context As System.Windows.Forms.DataGridViewDataErrorContexts) As Object Implements System.Windows.Forms.IDataGridViewEditingControl.GetEditingControlFormattedValue
|
||||
Return Me.Text
|
||||
End Function
|
||||
|
||||
Public Sub PrepareEditingControlForEdit(ByVal selectAll As Boolean) Implements System.Windows.Forms.IDataGridViewEditingControl.PrepareEditingControlForEdit
|
||||
If selectAll Then
|
||||
Me.SelectAll()
|
||||
Else
|
||||
Me.SelectionStart = Me.ToString().Length
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property RepositionEditingControlOnValueChange() As Boolean Implements System.Windows.Forms.IDataGridViewEditingControl.RepositionEditingControlOnValueChange
|
||||
Get
|
||||
Return False
|
||||
End Get
|
||||
End Property
|
||||
#End Region
|
||||
|
||||
Private Shared Function translateAlignment(ByVal align As DataGridViewContentAlignment) As HorizontalAlignment
|
||||
Select Case align
|
||||
Case DataGridViewContentAlignment.TopLeft, _
|
||||
DataGridViewContentAlignment.MiddleLeft, DataGridViewContentAlignment.BottomLeft
|
||||
Return HorizontalAlignment.Left
|
||||
|
||||
Case DataGridViewContentAlignment.TopCenter, _
|
||||
DataGridViewContentAlignment.MiddleCenter, DataGridViewContentAlignment.BottomCenter
|
||||
Return HorizontalAlignment.Center
|
||||
|
||||
Case DataGridViewContentAlignment.TopRight, _
|
||||
DataGridViewContentAlignment.MiddleRight, DataGridViewContentAlignment.BottomRight
|
||||
Return HorizontalAlignment.Right
|
||||
End Select
|
||||
Throw New ArgumentException("Error: Invalid Content Alignment!")
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,64 @@
|
||||
================================================================================
|
||||
WINDOWS FORMS APPLICATION : VBWinFormDataGridView Project Overview
|
||||
|
||||
CustomDataGridViewColumn Sample
|
||||
|
||||
===============================================================================
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Use:
|
||||
|
||||
This sample demonstrates how to create a custom DataGridView column.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Remark:
|
||||
|
||||
There're six standard DataGridViewColumn types for use as follows:
|
||||
|
||||
DataGridViewTextBoxColumn
|
||||
DataGridViewCheckedBoxColumn
|
||||
DataGridViewComboBoxColumn
|
||||
DataGridViewLinkColumn
|
||||
DataGridViewButtonColumn
|
||||
DataGridViewImageColumn
|
||||
|
||||
However, developers may want to use a different control for editing on the column,
|
||||
e.g. MarkedTextBox, DateTimePicker etc. This feature can be achieved in two ways:
|
||||
|
||||
1. Create a custom DataGridViewColumn;
|
||||
|
||||
The code in this CustomDataGridViewColumn sample demonstrates how to do this;
|
||||
|
||||
2. Place the editing control on the current cell when editing begins, and hide
|
||||
the editing control when the editing completes. For the details of this
|
||||
approach, please refer to the EditingControlHosting sample.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Creation:
|
||||
|
||||
1. Create a MaskedTextBoxEditingControl class derive from MaskedTextBox class
|
||||
and IDataGridViewEditingControl class, see the code in the
|
||||
MaskedTextBoxEditingControl.vb file for the implementation details;
|
||||
|
||||
2. Create a MaskedTextBoxCell class derive from DataGridViewTextBoxCell class,
|
||||
see the code in the MaskedTextBoxCell.vb file for the implementation details;
|
||||
|
||||
3. Create a MaskedTextBoxColumn class derive from DataGridViewColumn class,
|
||||
see the code in the MaskedTextBoxColumn.vb file for the implementation details;
|
||||
|
||||
4. Build the program;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
References:
|
||||
|
||||
1. DataGridView Custom Column Sample
|
||||
http://msdn.microsoft.com/en-us/library/ms180996.aspx
|
||||
|
||||
2. Windows Forms FAQs
|
||||
http://windowsclient.net/blogs/faqs/archive/tags/Custom+Designers/default.aspx
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,156 @@
|
||||
Namespace VBWinFormDataGridView.DataGridViewPaging
|
||||
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||
Partial Class MainForm
|
||||
Inherits System.Windows.Forms.Form
|
||||
|
||||
'Form overrides dispose to clean up the component list.
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
Try
|
||||
If disposing AndAlso components IsNot Nothing Then
|
||||
components.Dispose()
|
||||
End If
|
||||
Finally
|
||||
MyBase.Dispose(disposing)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Required by the Windows Form Designer
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
'NOTE: The following procedure is required by the Windows Form Designer
|
||||
'It can be modified using the Windows Form Designer.
|
||||
'Do not modify it using the code editor.
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(MainForm))
|
||||
Me.dataGridView1 = New System.Windows.Forms.DataGridView()
|
||||
Me.toolStripButtonNext = New System.Windows.Forms.ToolStripButton()
|
||||
Me.toolStripButtonPrev = New System.Windows.Forms.ToolStripButton()
|
||||
Me.toolStripButtonFirst = New System.Windows.Forms.ToolStripButton()
|
||||
Me.toolStrip1 = New System.Windows.Forms.ToolStrip()
|
||||
Me.toolStripButtonLast = New System.Windows.Forms.ToolStripButton()
|
||||
Me.groupBox1 = New System.Windows.Forms.GroupBox()
|
||||
Me.Label1 = New System.Windows.Forms.Label()
|
||||
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
|
||||
CType(Me.dataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
Me.toolStrip1.SuspendLayout()
|
||||
Me.groupBox1.SuspendLayout()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'dataGridView1
|
||||
'
|
||||
Me.dataGridView1.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.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
|
||||
Me.dataGridView1.Location = New System.Drawing.Point(3, 44)
|
||||
Me.dataGridView1.Name = "dataGridView1"
|
||||
Me.dataGridView1.Size = New System.Drawing.Size(632, 425)
|
||||
Me.dataGridView1.TabIndex = 0
|
||||
'
|
||||
'toolStripButtonNext
|
||||
'
|
||||
Me.toolStripButtonNext.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
|
||||
Me.toolStripButtonNext.Image = CType(resources.GetObject("toolStripButtonNext.Image"), System.Drawing.Image)
|
||||
Me.toolStripButtonNext.ImageTransparentColor = System.Drawing.Color.Magenta
|
||||
Me.toolStripButtonNext.Name = "toolStripButtonNext"
|
||||
Me.toolStripButtonNext.Size = New System.Drawing.Size(64, 22)
|
||||
Me.toolStripButtonNext.Text = "Next Page"
|
||||
'
|
||||
'toolStripButtonPrev
|
||||
'
|
||||
Me.toolStripButtonPrev.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
|
||||
Me.toolStripButtonPrev.Image = CType(resources.GetObject("toolStripButtonPrev.Image"), System.Drawing.Image)
|
||||
Me.toolStripButtonPrev.ImageTransparentColor = System.Drawing.Color.Magenta
|
||||
Me.toolStripButtonPrev.Name = "toolStripButtonPrev"
|
||||
Me.toolStripButtonPrev.Size = New System.Drawing.Size(85, 22)
|
||||
Me.toolStripButtonPrev.Text = "Previous Page"
|
||||
'
|
||||
'toolStripButtonFirst
|
||||
'
|
||||
Me.toolStripButtonFirst.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
|
||||
Me.toolStripButtonFirst.Image = CType(resources.GetObject("toolStripButtonFirst.Image"), System.Drawing.Image)
|
||||
Me.toolStripButtonFirst.ImageTransparentColor = System.Drawing.Color.Magenta
|
||||
Me.toolStripButtonFirst.Name = "toolStripButtonFirst"
|
||||
Me.toolStripButtonFirst.Size = New System.Drawing.Size(62, 22)
|
||||
Me.toolStripButtonFirst.Text = "First Page"
|
||||
'
|
||||
'toolStrip1
|
||||
'
|
||||
Me.toolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripButtonFirst, Me.toolStripButtonPrev, Me.toolStripButtonNext, Me.toolStripButtonLast})
|
||||
Me.toolStrip1.Location = New System.Drawing.Point(3, 16)
|
||||
Me.toolStrip1.Name = "toolStrip1"
|
||||
Me.toolStrip1.Size = New System.Drawing.Size(632, 25)
|
||||
Me.toolStrip1.TabIndex = 1
|
||||
Me.toolStrip1.Text = "toolStrip1"
|
||||
'
|
||||
'toolStripButtonLast
|
||||
'
|
||||
Me.toolStripButtonLast.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
|
||||
Me.toolStripButtonLast.Image = CType(resources.GetObject("toolStripButtonLast.Image"), System.Drawing.Image)
|
||||
Me.toolStripButtonLast.ImageTransparentColor = System.Drawing.Color.Magenta
|
||||
Me.toolStripButtonLast.Name = "toolStripButtonLast"
|
||||
Me.toolStripButtonLast.Size = New System.Drawing.Size(61, 22)
|
||||
Me.toolStripButtonLast.Text = "Last Page"
|
||||
'
|
||||
'groupBox1
|
||||
'
|
||||
Me.groupBox1.Controls.Add(Me.toolStrip1)
|
||||
Me.groupBox1.Controls.Add(Me.dataGridView1)
|
||||
Me.groupBox1.Location = New System.Drawing.Point(12, 49)
|
||||
Me.groupBox1.Name = "groupBox1"
|
||||
Me.groupBox1.Size = New System.Drawing.Size(638, 472)
|
||||
Me.groupBox1.TabIndex = 2
|
||||
Me.groupBox1.TabStop = False
|
||||
Me.groupBox1.UseCompatibleTextRendering = True
|
||||
'
|
||||
'Label1
|
||||
'
|
||||
Me.Label1.AutoSize = True
|
||||
Me.Label1.Location = New System.Drawing.Point(12, 33)
|
||||
Me.Label1.Name = "Label1"
|
||||
Me.Label1.Size = New System.Drawing.Size(129, 13)
|
||||
Me.Label1.TabIndex = 3
|
||||
Me.Label1.Text = "Number of rows per page:"
|
||||
'
|
||||
'ComboBox1
|
||||
'
|
||||
Me.ComboBox1.FormattingEnabled = True
|
||||
Me.ComboBox1.Location = New System.Drawing.Point(147, 30)
|
||||
Me.ComboBox1.Name = "ComboBox1"
|
||||
Me.ComboBox1.Size = New System.Drawing.Size(40, 21)
|
||||
Me.ComboBox1.TabIndex = 4
|
||||
'
|
||||
'MainForm
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.ClientSize = New System.Drawing.Size(662, 533)
|
||||
Me.Controls.Add(Me.ComboBox1)
|
||||
Me.Controls.Add(Me.Label1)
|
||||
Me.Controls.Add(Me.groupBox1)
|
||||
Me.Name = "MainForm"
|
||||
Me.Text = "MainForm"
|
||||
CType(Me.dataGridView1, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
Me.toolStrip1.ResumeLayout(False)
|
||||
Me.toolStrip1.PerformLayout()
|
||||
Me.groupBox1.ResumeLayout(False)
|
||||
Me.groupBox1.PerformLayout()
|
||||
Me.ResumeLayout(False)
|
||||
Me.PerformLayout()
|
||||
|
||||
End Sub
|
||||
Private WithEvents dataGridView1 As System.Windows.Forms.DataGridView
|
||||
Private WithEvents toolStripButtonNext As System.Windows.Forms.ToolStripButton
|
||||
Private WithEvents toolStripButtonPrev As System.Windows.Forms.ToolStripButton
|
||||
Private WithEvents toolStripButtonFirst As System.Windows.Forms.ToolStripButton
|
||||
Private WithEvents toolStrip1 As System.Windows.Forms.ToolStrip
|
||||
Private WithEvents toolStripButtonLast As System.Windows.Forms.ToolStripButton
|
||||
Private WithEvents groupBox1 As System.Windows.Forms.GroupBox
|
||||
Friend WithEvents Label1 As System.Windows.Forms.Label
|
||||
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,184 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="toolStripButtonNext.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
|
||||
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
|
||||
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
|
||||
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
|
||||
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
|
||||
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
|
||||
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
|
||||
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
|
||||
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
|
||||
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="toolStripButtonPrev.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
|
||||
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
|
||||
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
|
||||
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
|
||||
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
|
||||
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
|
||||
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
|
||||
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
|
||||
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
|
||||
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<data name="toolStripButtonFirst.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
|
||||
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
|
||||
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
|
||||
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
|
||||
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
|
||||
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
|
||||
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
|
||||
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
|
||||
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
|
||||
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<data name="toolStripButtonLast.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
|
||||
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
|
||||
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
|
||||
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
|
||||
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
|
||||
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
|
||||
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
|
||||
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
|
||||
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
|
||||
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,136 @@
|
||||
'********************************* Module Header **********************************\
|
||||
' Module Name: DataGridViewPaging.vb
|
||||
' Project: VBWinFormDataGridView
|
||||
' Copyright (c) Microsoft Corporation.
|
||||
'
|
||||
' This sample demonstrates how to page data in the DataGridView control;
|
||||
'
|
||||
' This source is subject to the Microsoft Public License.
|
||||
' See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
' All other rights reserved.
|
||||
|
||||
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
'**********************************************************************************/
|
||||
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Configuration
|
||||
|
||||
|
||||
Namespace VBWinFormDataGridView.DataGridViewPaging
|
||||
|
||||
Public Class MainForm
|
||||
Private PageSize As Integer = 30
|
||||
Private CurrentPageIndex As Integer = 1
|
||||
Private TotalPage As Integer
|
||||
Private connstr As String = ConfigurationManager.AppSettings("connectionString").ToString()
|
||||
Private conn As SqlConnection
|
||||
Private adapter As SqlDataAdapter
|
||||
Private command As SqlCommand
|
||||
|
||||
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
||||
Me.conn = New SqlConnection(connstr)
|
||||
Me.adapter = New SqlDataAdapter()
|
||||
Me.command = conn.CreateCommand()
|
||||
|
||||
' Get total count of the pages
|
||||
Me.GetTotalPageCount()
|
||||
Me.dataGridView1.ReadOnly = True
|
||||
|
||||
' Load the first page of data
|
||||
Me.Text = "MainForm – Page " & Me.CurrentPageIndex.ToString()
|
||||
|
||||
Dim intarray = Enumerable.Range(1, 25).Where(Function(numberin As Integer)
|
||||
Return (numberin Mod 5) = 0
|
||||
End Function) _
|
||||
.Select(Function(numberin As Integer)
|
||||
Return numberin.ToString()
|
||||
End Function)
|
||||
|
||||
For Each strin As String In intarray
|
||||
ComboBox1.Items.Add(strin)
|
||||
Next
|
||||
|
||||
ComboBox1.SelectedIndex = ComboBox1.Items.Count - 1
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub GetTotalPageCount()
|
||||
command.Parameters.Clear()
|
||||
command.CommandType = CommandType.Text
|
||||
command.CommandText = "Select Count(OrderID) From Orders"
|
||||
Try
|
||||
conn.Open()
|
||||
Dim rowCount As Integer = CType(command.ExecuteScalar(), Integer)
|
||||
Me.TotalPage = rowCount / PageSize
|
||||
If rowCount Mod PageSize > 0 Then
|
||||
Me.TotalPage += 1
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MessageBox.Show(ex.Message)
|
||||
Finally
|
||||
conn.Close()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Function GetPageData(ByVal page As Integer) As DataTable
|
||||
Dim dt As DataTable = New DataTable()
|
||||
command.Parameters.Clear()
|
||||
command.CommandType = CommandType.StoredProcedure
|
||||
|
||||
command.CommandText = "usp_paginateorders"
|
||||
|
||||
command.Parameters.Add("@pageNumber", SqlDbType.Int).Value = page
|
||||
command.Parameters.Add("@numberOfRows", SqlDbType.Int).Value = PageSize
|
||||
Try
|
||||
Me.conn.Open()
|
||||
Me.adapter.SelectCommand = command
|
||||
Me.adapter.Fill(dt)
|
||||
Catch ex As Exception
|
||||
MessageBox.Show(ex.Message)
|
||||
Finally
|
||||
conn.Close()
|
||||
End Try
|
||||
Dim view As New DataView(dt)
|
||||
view.Sort = "CustomerID"
|
||||
Dim dtout As DataTable = view.ToTable()
|
||||
Return dtout
|
||||
End Function
|
||||
|
||||
Private Sub toolStripButtonFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolStripButtonFirst.Click
|
||||
Me.CurrentPageIndex = 1
|
||||
Me.Text = "MainForm – Page " & Me.CurrentPageIndex.ToString()
|
||||
Me.dataGridView1.DataSource = GetPageData(Me.CurrentPageIndex)
|
||||
End Sub
|
||||
|
||||
Private Sub toolStripButtonPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolStripButtonPrev.Click
|
||||
If Me.CurrentPageIndex > 1 Then
|
||||
Me.CurrentPageIndex -= 1
|
||||
Me.Text = "MainForm – Page " & Me.CurrentPageIndex.ToString()
|
||||
Me.dataGridView1.DataSource = GetPageData(Me.CurrentPageIndex)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub toolStripButtonNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolStripButtonNext.Click
|
||||
If Me.CurrentPageIndex < Me.TotalPage Then
|
||||
Me.CurrentPageIndex += 1
|
||||
Me.Text = "MainForm – Page " & Me.CurrentPageIndex.ToString()
|
||||
Me.dataGridView1.DataSource = GetPageData(Me.CurrentPageIndex)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub toolStripButtonLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles toolStripButtonLast.Click
|
||||
Me.CurrentPageIndex = TotalPage
|
||||
Me.Text = "MainForm – Page " & Me.CurrentPageIndex.ToString()
|
||||
Me.dataGridView1.DataSource = GetPageData(Me.CurrentPageIndex)
|
||||
End Sub
|
||||
|
||||
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
|
||||
Me.PageSize = Int32.Parse(ComboBox1.Items(ComboBox1.SelectedIndex))
|
||||
Me.GetTotalPageCount()
|
||||
Me.dataGridView1.DataSource = GetPageData(Me.CurrentPageIndex)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,31 @@
|
||||
================================================================================
|
||||
WINDOWS FORMS APPLICATION : VBWinFormDataGridView Project Overview
|
||||
|
||||
DataGridViewPaging Sample
|
||||
|
||||
===============================================================================
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Use:
|
||||
|
||||
This sample demonstrates how to page data in the DataGridView control;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Code Logic:
|
||||
|
||||
1. Get total count of the rows in the table;
|
||||
|
||||
2. Calculate total count of pages;
|
||||
|
||||
3. Load each page on demand;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
References:
|
||||
|
||||
1. DataGridView Custom Column Sample
|
||||
http://msdn.microsoft.com/en-us/library/ms180996.aspx
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<a:clrMap xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>
|
||||
@@ -0,0 +1,18 @@
|
||||
<xml xmlns:o="urn:schemas-microsoft-com:office:office">
|
||||
<o:MainFile HRef="../ReadMe.htm"/>
|
||||
<o:File HRef="themedata.thmx"/>
|
||||
<o:File HRef="colorschememapping.xml"/>
|
||||
<o:File HRef="image001.png"/>
|
||||
<o:File HRef="image002.jpg"/>
|
||||
<o:File HRef="image003.png"/>
|
||||
<o:File HRef="image004.jpg"/>
|
||||
<o:File HRef="image005.png"/>
|
||||
<o:File HRef="image006.jpg"/>
|
||||
<o:File HRef="image007.png"/>
|
||||
<o:File HRef="image008.jpg"/>
|
||||
<o:File HRef="image009.png"/>
|
||||
<o:File HRef="image010.jpg"/>
|
||||
<o:File HRef="image011.png"/>
|
||||
<o:File HRef="header.htm"/>
|
||||
<o:File HRef="filelist.xml"/>
|
||||
</xml>
|
||||
@@ -0,0 +1,66 @@
|
||||
<html xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
xmlns:w="urn:schemas-microsoft-com:office:word"
|
||||
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
|
||||
xmlns="http://www.w3.org/TR/REC-html40">
|
||||
|
||||
<head>
|
||||
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
|
||||
<meta name=ProgId content=Word.Document>
|
||||
<meta name=Generator content="Microsoft Word 14">
|
||||
<meta name=Originator content="Microsoft Word 14">
|
||||
<link id=Main-File rel=Main-File href="../ReadMe.htm">
|
||||
<!--[if gte mso 9]><xml>
|
||||
<o:shapedefaults v:ext="edit" spidmax="2049"/>
|
||||
</xml><![endif]-->
|
||||
</head>
|
||||
|
||||
<body lang=EN-US link=blue vlink=purple>
|
||||
|
||||
<div style='mso-element:footnote-separator' id=fs>
|
||||
|
||||
<p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
|
||||
normal'><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
|
||||
|
||||
<hr align=left size=1 width="33%">
|
||||
|
||||
<![endif]></span></p>
|
||||
|
||||
</div>
|
||||
|
||||
<div style='mso-element:footnote-continuation-separator' id=fcs>
|
||||
|
||||
<p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
|
||||
normal'><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
|
||||
|
||||
<hr align=left size=1>
|
||||
|
||||
<![endif]></span></p>
|
||||
|
||||
</div>
|
||||
|
||||
<div style='mso-element:endnote-separator' id=es>
|
||||
|
||||
<p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
|
||||
normal'><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
|
||||
|
||||
<hr align=left size=1 width="33%">
|
||||
|
||||
<![endif]></span></p>
|
||||
|
||||
</div>
|
||||
|
||||
<div style='mso-element:endnote-continuation-separator' id=ecs>
|
||||
|
||||
<p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
|
||||
normal'><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
|
||||
|
||||
<hr align=left size=1>
|
||||
|
||||
<![endif]></span></p>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 32 KiB |
@@ -0,0 +1,70 @@
|
||||
Namespace VBWinFormDataGridView.EditingControlHosting
|
||||
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||
Partial Class MainForm
|
||||
Inherits System.Windows.Forms.Form
|
||||
|
||||
'Form overrides dispose to clean up the component list.
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
Try
|
||||
If disposing AndAlso components IsNot Nothing Then
|
||||
components.Dispose()
|
||||
End If
|
||||
Finally
|
||||
MyBase.Dispose(disposing)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Required by the Windows Form Designer
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
'NOTE: The following procedure is required by the Windows Form Designer
|
||||
'It can be modified using the Windows Form Designer.
|
||||
'Do not modify it using the code editor.
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
Me.label1 = New System.Windows.Forms.Label
|
||||
Me.dataGridView1 = New System.Windows.Forms.DataGridView
|
||||
CType(Me.dataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'label1
|
||||
'
|
||||
Me.label1.AutoSize = True
|
||||
Me.label1.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
||||
Me.label1.Location = New System.Drawing.Point(20, 27)
|
||||
Me.label1.Name = "label1"
|
||||
Me.label1.Size = New System.Drawing.Size(582, 20)
|
||||
Me.label1.TabIndex = 3
|
||||
Me.label1.Text = "This sample demonstrates how to host a control in the current DataGridViewCell f" & _
|
||||
"or editing."
|
||||
Me.label1.UseCompatibleTextRendering = True
|
||||
'
|
||||
'dataGridView1
|
||||
'
|
||||
Me.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
|
||||
Me.dataGridView1.Location = New System.Drawing.Point(23, 64)
|
||||
Me.dataGridView1.Name = "dataGridView1"
|
||||
Me.dataGridView1.Size = New System.Drawing.Size(586, 350)
|
||||
Me.dataGridView1.TabIndex = 2
|
||||
'
|
||||
'MainForm
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.ClientSize = New System.Drawing.Size(628, 441)
|
||||
Me.Controls.Add(Me.label1)
|
||||
Me.Controls.Add(Me.dataGridView1)
|
||||
Me.Name = "MainForm"
|
||||
Me.Text = "MainForm"
|
||||
CType(Me.dataGridView1, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
Me.ResumeLayout(False)
|
||||
Me.PerformLayout()
|
||||
|
||||
End Sub
|
||||
Private WithEvents label1 As System.Windows.Forms.Label
|
||||
Private WithEvents dataGridView1 As System.Windows.Forms.DataGridView
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,115 @@
|
||||
'************************************* Module Header **************************************\
|
||||
' Module Name: EditingControlHosting
|
||||
' Project: VBWinFormDataGridView
|
||||
' Copyright (c) Microsoft Corporation.
|
||||
'
|
||||
' This sample demonstrates how to host a control in the current DataGridViewCell for
|
||||
' editing.
|
||||
'
|
||||
' This source is subject to the Microsoft Public License.
|
||||
' See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
' All other rights reserved.
|
||||
'
|
||||
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
'**********************************************************************************/
|
||||
|
||||
Namespace VBWinFormDataGridView.EditingControlHosting
|
||||
|
||||
Public Class MainForm
|
||||
Private maskedTextBoxForEditing As MaskedTextBox
|
||||
Private IsKeyPressHandled As Boolean
|
||||
|
||||
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
||||
Me.maskedTextBoxForEditing = New MaskedTextBox()
|
||||
|
||||
' The "000-00-0000" mask allows only digits can be input
|
||||
Me.maskedTextBoxForEditing.Mask = "000-00-0000"
|
||||
|
||||
' Hide the MaskedTextBox
|
||||
Me.maskedTextBoxForEditing.Visible = False
|
||||
|
||||
' Add the MaskedTextBox to the DataGridView's control collection
|
||||
Me.dataGridView1.Controls.Add(Me.maskedTextBoxForEditing)
|
||||
|
||||
' Add a DataGridViewTextBoxColumn to the
|
||||
Dim tc As DataGridViewTextBoxColumn = New DataGridViewTextBoxColumn()
|
||||
tc.HeaderText = "Mask Column"
|
||||
tc.Name = "MaskColumn"
|
||||
Me.dataGridView1.Columns.Add(tc)
|
||||
|
||||
' Add some empty rows for testing purpose
|
||||
For j As Integer = 0 To 29
|
||||
Me.dataGridView1.Rows.Add()
|
||||
Next
|
||||
|
||||
' Handle the CellBeginEdit event to show the MaskedTextBox on
|
||||
' the current editing cell
|
||||
End Sub
|
||||
|
||||
Private Sub dataGridView1_CellBeginEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles dataGridView1.CellBeginEdit
|
||||
' If the current cell is on the "MaskColumn", we use the MaskedTextBox control
|
||||
' for editing instead of the default TextBox control
|
||||
If e.ColumnIndex = Me.dataGridView1.Columns("MaskColumn").Index Then
|
||||
' Calculate the cell bounds of the current cell
|
||||
Dim rect As Rectangle = Me.dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, True)
|
||||
' Adjust the MaskedTextBox's size and location to fit the cell
|
||||
Me.maskedTextBoxForEditing.Size = rect.Size
|
||||
Me.maskedTextBoxForEditing.Location = rect.Location
|
||||
' Set value for the MaskedTextBox
|
||||
If Me.dataGridView1.CurrentCell.Value IsNot Nothing Then
|
||||
Me.maskedTextBoxForEditing.Text = Me.dataGridView1.CurrentCell.Value.ToString()
|
||||
End If
|
||||
|
||||
' Show the MaskedTextBox
|
||||
Me.maskedTextBoxForEditing.Visible = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub dataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dataGridView1.CellEndEdit
|
||||
' When finish editing on the "MaskColumn", we replace the cell value with
|
||||
' the text typed in the MaskedTextBox, and hide the MaskedTextBox
|
||||
If e.ColumnIndex = Me.dataGridView1.Columns("MaskColumn").Index Then
|
||||
Me.dataGridView1.CurrentCell.Value = Me.maskedTextBoxForEditing.Text
|
||||
Me.maskedTextBoxForEditing.Text = ""
|
||||
Me.maskedTextBoxForEditing.Visible = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub dataGridView1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles dataGridView1.Scroll
|
||||
If Me.dataGridView1.IsCurrentCellInEditMode = True Then
|
||||
' Adjust the location for the MaskedTextBox while scrolling
|
||||
Dim rect As Rectangle = Me.dataGridView1.GetCellDisplayRectangle(Me.dataGridView1.CurrentCell.ColumnIndex, Me.dataGridView1.CurrentCell.RowIndex, True)
|
||||
Console.WriteLine(rect.ToString())
|
||||
Console.WriteLine(Me.dataGridView1.CurrentCellAddress.ToString())
|
||||
Console.WriteLine("")
|
||||
|
||||
If rect.X <= 0 OrElse rect.Y <= 0 Then
|
||||
Me.maskedTextBoxForEditing.Visible = False
|
||||
Else
|
||||
Me.maskedTextBoxForEditing.Location = rect.Location
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub dataGridView1_EditingControlShowing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dataGridView1.EditingControlShowing
|
||||
If Not (Me.IsKeyPressHandled AndAlso Me.dataGridView1.CurrentCell.ColumnIndex = Me.dataGridView1.Columns("MaskColumn").Index) Then
|
||||
Dim tb As TextBox = CType(e.Control, TextBox)
|
||||
AddHandler tb.KeyPress, AddressOf tb_KeyPress
|
||||
Me.IsKeyPressHandled = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub tb_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
|
||||
If Me.dataGridView1.CurrentCell.ColumnIndex = Me.dataGridView1.Columns("MaskColumn").Index Then
|
||||
' Prevent the key char to be input in the editing control
|
||||
e.Handled = True
|
||||
|
||||
' Set focus to the MaskedTextBox for editing.
|
||||
Me.maskedTextBoxForEditing.Focus()
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,74 @@
|
||||
================================================================================
|
||||
WINDOWS FORMS APPLICATION : VBWinFormDataGridView Project Overview
|
||||
|
||||
EditingControlHosting Sample
|
||||
|
||||
===============================================================================
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Use:
|
||||
|
||||
This sample demonstrates how to host a control in the current DataGridViewCell
|
||||
for editing.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Remark:
|
||||
|
||||
There're six standard DataGridViewColumn types for use as follows:
|
||||
|
||||
DataGridViewTextBoxColumn
|
||||
DataGridViewCheckedBoxColumn
|
||||
DataGridViewComboBoxColumn
|
||||
DataGridViewLinkColumn
|
||||
DataGridViewButtonColumn
|
||||
DataGridViewImageColumn
|
||||
|
||||
However, developers may want to use a different control for editing on the column,
|
||||
e.g. MarkedTextBox, DateTimePicker etc. This feature can be achieved in two ways:
|
||||
|
||||
1. Create a custom DataGridViewColumn;
|
||||
|
||||
For the details of how to do this, please refer to the CustomDataGridViewColumn
|
||||
sample.
|
||||
|
||||
2. Place the editing control on the current cell when editing begins, and hide
|
||||
the editing control when the editing completes.
|
||||
|
||||
This sample demonstrates how to do this.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Code Logic:
|
||||
|
||||
1. Create an instance of the editing control, in this sample the editing control
|
||||
is MaskedTextBox.
|
||||
|
||||
2. Specify a mask for the MaskedTextBox and add the MaskedTextBox to the
|
||||
control collection of the DataGridView;
|
||||
|
||||
3. Hide the MaskedTextBox;
|
||||
|
||||
4. Handle the CellBeginEdit event to show the MaskedTextBox on the current
|
||||
editing cell;
|
||||
|
||||
5. Handle the CellEndEdit event to hide the MaskedTextBox when editing completes;
|
||||
|
||||
6. Handle the Scroll event to adjust the location of the MaskedTextBox as it is
|
||||
showing when scrolling the DataGridView;
|
||||
|
||||
7. Handle the EditingControlShowing event to pass the focus to the MaskedTextBox
|
||||
when begin editing with keystrokes;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
References:
|
||||
|
||||
1. DataGridView Class
|
||||
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx
|
||||
|
||||
2. Windows Forms FAQs
|
||||
http://windowsclient.net/blogs/faqs/archive/tags/Custom+Designers/default.aspx
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,251 @@
|
||||
'************************************* Module Header **************************************\
|
||||
' Module Name: JustInTimeDataLoading.Cache
|
||||
' Project: VBWinFormDataGridView
|
||||
' Copyright (c) Microsoft Corporation.
|
||||
'
|
||||
' This sample demonstrates how to use virtual mode in the DataGridView control
|
||||
' with a data cache that loads data from a server only when it is needed.
|
||||
' This kind of data loading is called "Just-in-time data loading".
|
||||
'
|
||||
' This source is subject to the Microsoft Public License.
|
||||
' See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
' All other rights reserved.
|
||||
'
|
||||
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
'**********************************************************************************/
|
||||
|
||||
|
||||
Imports System.Data.SqlClient
|
||||
|
||||
Namespace VBWinFormDataGridView.JustInTimeDataLoading
|
||||
|
||||
#Region "Cache Class"
|
||||
Public Class Cache
|
||||
Private Shared RowsPerPage As Integer
|
||||
|
||||
Public Structure DataPage
|
||||
Public table As DataTable
|
||||
Private lowestIndexValue As Integer
|
||||
Private highestIndexValue As Integer
|
||||
|
||||
Public Sub New(ByVal table As DataTable, ByVal rowIndex As Integer)
|
||||
Me.table = table
|
||||
lowestIndexValue = MapToLowerBoundary(rowIndex)
|
||||
highestIndexValue = MapToUpperBoundary(rowIndex)
|
||||
System.Diagnostics.Debug.Assert(lowestIndexValue >= 0)
|
||||
System.Diagnostics.Debug.Assert(highestIndexValue >= 0)
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property LowestIndex() As Integer
|
||||
Get
|
||||
Return lowestIndexValue
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property HighestIndex() As Integer
|
||||
Get
|
||||
Return highestIndexValue
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Shared Function MapToLowerBoundary(ByVal rowIndex As Integer) As Integer
|
||||
' Return the lowest index of a page containing the given index.
|
||||
Return (rowIndex \ RowsPerPage) * RowsPerPage
|
||||
End Function
|
||||
|
||||
Private Shared Function MapToUpperBoundary(ByVal rowIndex) As Integer
|
||||
' Return the highest index of a page containing the given index.
|
||||
Return MapToLowerBoundary(rowIndex) + RowsPerPage - 1
|
||||
End Function
|
||||
End Structure
|
||||
|
||||
Private cachePages As DataPage()
|
||||
Private dataSupply As IDataPageRetriever
|
||||
|
||||
Public Sub New(ByVal dataSupplier As IDataPageRetriever, ByVal rowsPerPage As Integer)
|
||||
dataSupply = dataSupplier
|
||||
Cache.RowsPerPage = rowsPerPage
|
||||
LoadFirstTwoPages()
|
||||
End Sub
|
||||
|
||||
Private Function IfPageCached_ThenSetElement(ByVal rowIndex As Integer, ByVal columnIndex As Integer, ByRef element As String) As Boolean
|
||||
|
||||
If IsRowCachedInPage(0, rowIndex) Then
|
||||
element = cachePages(0).table.Rows(rowIndex Mod RowsPerPage)(columnIndex).ToString()
|
||||
Return True
|
||||
ElseIf (IsRowCachedInPage(1, rowIndex)) Then
|
||||
element = cachePages(1).table.Rows(rowIndex Mod RowsPerPage)(columnIndex).ToString()
|
||||
Return True
|
||||
End If
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public Function RetrieveElement(ByVal rowIndex As Integer, ByVal columnIndex As Integer) As String
|
||||
Dim element As String = Nothing
|
||||
If IfPageCached_ThenSetElement(rowIndex, columnIndex, element) Then
|
||||
Return element
|
||||
Else
|
||||
Return RetrieveData_CacheIt_ThenReturnElement(rowIndex, columnIndex)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Sub LoadFirstTwoPages()
|
||||
cachePages = New DataPage() {
|
||||
New DataPage(dataSupply.SupplyPageOfData(DataPage.MapToLowerBoundary(0), RowsPerPage), 0), _
|
||||
New DataPage(dataSupply.SupplyPageOfData(DataPage.MapToLowerBoundary(RowsPerPage), _
|
||||
RowsPerPage), RowsPerPage)}
|
||||
End Sub
|
||||
|
||||
Private Function RetrieveData_CacheIt_ThenReturnElement(ByVal rowIndex As Integer, ByVal columnIndex As Integer)
|
||||
' Retrieve a page worth of data containing the requested value.
|
||||
Dim table As DataTable = dataSupply.SupplyPageOfData(DataPage.MapToLowerBoundary(rowIndex), RowsPerPage)
|
||||
' Replace the cached page furthest from the requested cell
|
||||
' with a new page containing the newly retrieved data.
|
||||
cachePages(GetIndexToUnusedPage(rowIndex)) = New DataPage(table, rowIndex)
|
||||
Return RetrieveElement(rowIndex, columnIndex)
|
||||
End Function
|
||||
|
||||
Private Function GetIndexToUnusedPage(ByVal rowIndex As Integer) As Integer
|
||||
If rowIndex > cachePages(0).HighestIndex AndAlso rowIndex > cachePages(1).HighestIndex Then
|
||||
Dim offsetFromPage0 As Integer = rowIndex - cachePages(0).HighestIndex
|
||||
Dim offsetFromPage1 As Integer = rowIndex - cachePages(1).HighestIndex
|
||||
If offsetFromPage0 < offsetFromPage1 Then
|
||||
Return 1
|
||||
End If
|
||||
Return 0
|
||||
Else
|
||||
Dim offsetFromPage0 As Integer = cachePages(0).LowestIndex - rowIndex
|
||||
Dim offsetFromPage1 As Integer = cachePages(1).LowestIndex - rowIndex
|
||||
If offsetFromPage0 < offsetFromPage1 Then
|
||||
Return 1
|
||||
End If
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function IsRowCachedInPage(ByVal pageNumber As Integer, ByVal rowIndex As Integer) As Boolean
|
||||
Return ((rowIndex <= cachePages(pageNumber).HighestIndex) AndAlso (rowIndex >= cachePages(pageNumber).LowestIndex))
|
||||
End Function
|
||||
End Class
|
||||
#End Region
|
||||
|
||||
#Region "IDataPageRetriever Interface"
|
||||
Public Interface IDataPageRetriever
|
||||
Function SupplyPageOfData(ByVal lowerPageBoundary As Integer, ByVal rowsPerPage As Integer) As DataTable
|
||||
End Interface
|
||||
#End Region
|
||||
|
||||
#Region "DataRetriever Class"
|
||||
Public Class DataRetriever
|
||||
Implements IDataPageRetriever
|
||||
|
||||
Private tableName As String
|
||||
Private command As SqlCommand
|
||||
|
||||
Public Sub New(ByVal connectionString As String, ByVal tableName As String)
|
||||
Dim connection As SqlConnection = New SqlConnection(connectionString)
|
||||
connection.Open()
|
||||
command = connection.CreateCommand()
|
||||
Me.tableName = tableName
|
||||
End Sub
|
||||
|
||||
Private rowCountValue As Integer = -1
|
||||
|
||||
Public ReadOnly Property RowCount() As Integer
|
||||
Get
|
||||
' Return the existing value if it has already been determined.
|
||||
If rowCountValue <> -1 Then
|
||||
Return rowCountValue
|
||||
End If
|
||||
' Retrieve the row count from the database.
|
||||
command.CommandText = "SELECT COUNT(*) FROM " & tableName
|
||||
rowCountValue = CType(command.ExecuteScalar(), Integer)
|
||||
Return rowCountValue
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private columnsValue As DataColumnCollection
|
||||
|
||||
Public ReadOnly Property Columns() As DataColumnCollection
|
||||
Get
|
||||
' Return the existing value if it has already been determined.
|
||||
If columnsValue IsNot Nothing Then
|
||||
Return columnsValue
|
||||
End If
|
||||
|
||||
' Retrieve the column information from the database.
|
||||
command.CommandText = "SELECT * FROM " & tableName
|
||||
Dim adapter As SqlDataAdapter = New SqlDataAdapter()
|
||||
adapter.SelectCommand = command
|
||||
Dim table As DataTable = New DataTable()
|
||||
table.Locale = System.Globalization.CultureInfo.InvariantCulture
|
||||
adapter.FillSchema(table, SchemaType.Source)
|
||||
columnsValue = table.Columns
|
||||
Return columnsValue
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private commaSeparatedListOfColumnNamesValue As String = Nothing
|
||||
|
||||
Private ReadOnly Property CommaSeparatedListOfColumnNames() As String
|
||||
Get
|
||||
' Return the existing value if it has already been determined.
|
||||
|
||||
If commaSeparatedListOfColumnNamesValue IsNot Nothing Then
|
||||
Return commaSeparatedListOfColumnNamesValue
|
||||
End If
|
||||
|
||||
' Store a list of column names for use in the
|
||||
' SupplyPageOfData method.
|
||||
Dim commaSeparatedColumnNames As System.Text.StringBuilder = New System.Text.StringBuilder()
|
||||
Dim firstColumn As Boolean = True
|
||||
For Each column As DataColumn In Columns
|
||||
If Not firstColumn Then
|
||||
commaSeparatedColumnNames.Append(", ")
|
||||
End If
|
||||
commaSeparatedColumnNames.Append(column.ColumnName)
|
||||
firstColumn = False
|
||||
Next
|
||||
|
||||
commaSeparatedListOfColumnNamesValue = commaSeparatedColumnNames.ToString()
|
||||
Return commaSeparatedListOfColumnNamesValue
|
||||
End Get
|
||||
End Property
|
||||
|
||||
' Declare variables to be reused by the SupplyPageOfData method.
|
||||
Private columnToSortBy As String
|
||||
Private adapter As SqlDataAdapter = New SqlDataAdapter()
|
||||
|
||||
Public Function SupplyPageOfData(ByVal lowerPageBoundary As Integer, ByVal rowsPerPage As Integer) As System.Data.DataTable Implements IDataPageRetriever.SupplyPageOfData
|
||||
' Store the name of the ID column. This column must contain unique
|
||||
' values so the SQL below will work properly.
|
||||
If columnToSortBy Is Nothing Then
|
||||
columnToSortBy = Me.Columns(0).ColumnName
|
||||
End If
|
||||
|
||||
If Not Me.Columns(columnToSortBy).Unique Then
|
||||
Throw New InvalidOperationException(String.Format("Column {0} must contain unique values.", columnToSortBy))
|
||||
End If
|
||||
|
||||
' Retrieve the specified number of rows from the database, starting
|
||||
' with the row specified by the lowerPageBoundary parameter.
|
||||
command.CommandText = "Select Top " & rowsPerPage & " " & _
|
||||
CommaSeparatedListOfColumnNames & " From " & tableName & _
|
||||
" WHERE " & columnToSortBy & " NOT IN (SELECT TOP " & _
|
||||
lowerPageBoundary & " " & columnToSortBy & " From " & _
|
||||
tableName & " Order By " & columnToSortBy & _
|
||||
") Order By " & columnToSortBy
|
||||
|
||||
adapter.SelectCommand = command
|
||||
|
||||
Dim table As DataTable = New DataTable()
|
||||
table.Locale = System.Globalization.CultureInfo.InvariantCulture
|
||||
adapter.Fill(table)
|
||||
Return table
|
||||
End Function
|
||||
End Class
|
||||
#End Region
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,68 @@
|
||||
Namespace VBWinFormDataGridView.JustInTimeDataLoading
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||
Partial Class MainForm
|
||||
Inherits System.Windows.Forms.Form
|
||||
|
||||
'Form overrides dispose to clean up the component list.
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
Try
|
||||
If disposing AndAlso components IsNot Nothing Then
|
||||
components.Dispose()
|
||||
End If
|
||||
Finally
|
||||
MyBase.Dispose(disposing)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Required by the Windows Form Designer
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
'NOTE: The following procedure is required by the Windows Form Designer
|
||||
'It can be modified using the Windows Form Designer.
|
||||
'Do not modify it using the code editor.
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(MainForm))
|
||||
Me.dataGridView1 = New System.Windows.Forms.DataGridView
|
||||
Me.label1 = New System.Windows.Forms.Label
|
||||
CType(Me.dataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'dataGridView1
|
||||
'
|
||||
Me.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
|
||||
Me.dataGridView1.Location = New System.Drawing.Point(30, 93)
|
||||
Me.dataGridView1.Name = "dataGridView1"
|
||||
Me.dataGridView1.Size = New System.Drawing.Size(596, 381)
|
||||
Me.dataGridView1.TabIndex = 3
|
||||
'
|
||||
'label1
|
||||
'
|
||||
Me.label1.AutoSize = True
|
||||
Me.label1.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
||||
Me.label1.Location = New System.Drawing.Point(27, 25)
|
||||
Me.label1.Name = "label1"
|
||||
Me.label1.Size = New System.Drawing.Size(511, 49)
|
||||
Me.label1.TabIndex = 2
|
||||
Me.label1.Text = resources.GetString("label1.Text")
|
||||
Me.label1.UseCompatibleTextRendering = True
|
||||
'
|
||||
'MainForm
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.ClientSize = New System.Drawing.Size(652, 498)
|
||||
Me.Controls.Add(Me.dataGridView1)
|
||||
Me.Controls.Add(Me.label1)
|
||||
Me.Name = "MainForm"
|
||||
Me.Text = "MainForm"
|
||||
CType(Me.dataGridView1, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
Me.ResumeLayout(False)
|
||||
Me.PerformLayout()
|
||||
|
||||
End Sub
|
||||
Private WithEvents dataGridView1 As System.Windows.Forms.DataGridView
|
||||
Private WithEvents label1 As System.Windows.Forms.Label
|
||||
End Class
|
||||
End Namespace
|
||||
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="label1.Text" xml:space="preserve">
|
||||
<value>This sample demonstrates how to use virtual mode in the DataGridView control
|
||||
with a data cache that loads data from a server only when it is needed.
|
||||
This kind of data loading is called "Just-in-time data loading". </value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,63 @@
|
||||
'********************************* Module Header **********************************\
|
||||
' Module Name: JustInTimeDataLoading
|
||||
' Project: VBWinFormDataGridView
|
||||
' Copyright (c) Microsoft Corporation.
|
||||
'
|
||||
' This sample demonstrates how to use virtual mode in the DataGridView control
|
||||
' with a data cache that loads data from a server only when it is needed.
|
||||
' This kind of data loading is called "Just-in-time data loading".
|
||||
'
|
||||
' This source is subject to the Microsoft Public License.
|
||||
' See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
' All other rights reserved.
|
||||
'
|
||||
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
'**********************************************************************************/
|
||||
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Configuration
|
||||
|
||||
Namespace VBWinFormDataGridView.JustInTimeDataLoading
|
||||
Public Class MainForm
|
||||
Private memoryCache As Cache
|
||||
|
||||
' Specify a connection string. Replace the given value with a
|
||||
' valid connection string for a Northwind SQL Server sample
|
||||
' database accessible to your system.
|
||||
Private connectionString As String = ConfigurationManager.AppSettings("connectionString")
|
||||
|
||||
Private table As String = "Orders"
|
||||
|
||||
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
||||
' Enable VirtualMode on the DataGridView
|
||||
Me.dataGridView1.VirtualMode = True
|
||||
' Handle the CellValueNeeded event to retrieve the requested cell value
|
||||
' from the data store or the Customer object currently in edit.
|
||||
' This event occurs whenever the DataGridView control needs to paint a cell.
|
||||
|
||||
' Create a DataRetriever and use it to create a Cache object
|
||||
' and to initialize the DataGridView columns and rows.
|
||||
Try
|
||||
Dim retriever As DataRetriever = New DataRetriever(connectionString, table)
|
||||
memoryCache = New Cache(retriever, 16)
|
||||
For Each column As DataColumn In retriever.Columns
|
||||
dataGridView1.Columns.Add(column.ColumnName, column.ColumnName)
|
||||
Next
|
||||
Me.dataGridView1.RowCount = retriever.RowCount
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Connection could not be established. " & _
|
||||
"Verify that the connection string is valid.")
|
||||
Application.Exit()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub dataGridView1_CellValueNeeded(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellValueEventArgs) Handles dataGridView1.CellValueNeeded
|
||||
|
||||
e.Value = memoryCache.RetrieveElement(e.RowIndex, e.ColumnIndex)
|
||||
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
@@ -0,0 +1,55 @@
|
||||
================================================================================
|
||||
WINDOWS FORMS APPLICATION : VBWinFormDataGridView Project Overview
|
||||
|
||||
JustInTimeDataLoading Sample
|
||||
|
||||
===============================================================================
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Use:
|
||||
|
||||
This sample demonstrates how to use virtual mode in the DataGridView control
|
||||
with a data cache that loads data from a server only when it is needed.
|
||||
This kind of data loading is called "Just-in-time data loading".
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Remark:
|
||||
|
||||
If you are working with a very large table in a remote database, for example,
|
||||
you might want to avoid startup delays by retrieving only the data that is
|
||||
necessary for display and retrieving additional data only when the user scrolls
|
||||
new rows into view. If the client computers running your application have a
|
||||
limited amount of memory available for storing data, you might also want to
|
||||
discard unused data when retrieving new values from the database.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Code Logic:
|
||||
|
||||
1. Enable VirtualMode on the DataGridView control by setting the VirtualMode
|
||||
property to true:
|
||||
|
||||
Me.dataGridView1.VirtualMode = true;
|
||||
|
||||
2. Add columns to the DataGridView according to the data in the database;
|
||||
|
||||
3. Retrieve the row count of the data in the database and set the RowCount
|
||||
property for the DataGridView;
|
||||
|
||||
4. Handle the CellValueNeeded event to retrieve the requested cell value
|
||||
from the data store or the Customer object currently in edit.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
References:
|
||||
|
||||
1. Implementing Virtual Mode with Just-In-Time Data Loading in the Windows
|
||||
Forms DataGridView Control
|
||||
http://msdn.microsoft.com/en-us/library/ms171624.aspx
|
||||
|
||||
2. Windows Forms FAQs
|
||||
http://windowsclient.net/blogs/faqs/archive/tags/Custom+Designers/default.aspx
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,70 @@
|
||||
Namespace VBWinFormDataGridView.MultipleLayeredColumnHeader
|
||||
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||
Partial Class MainForm
|
||||
Inherits System.Windows.Forms.Form
|
||||
|
||||
'Form overrides dispose to clean up the component list.
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
Try
|
||||
If disposing AndAlso components IsNot Nothing Then
|
||||
components.Dispose()
|
||||
End If
|
||||
Finally
|
||||
MyBase.Dispose(disposing)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Required by the Windows Form Designer
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
'NOTE: The following procedure is required by the Windows Form Designer
|
||||
'It can be modified using the Windows Form Designer.
|
||||
'Do not modify it using the code editor.
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
Me.label1 = New System.Windows.Forms.Label
|
||||
Me.dataGridView1 = New System.Windows.Forms.DataGridView
|
||||
CType(Me.dataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'label1
|
||||
'
|
||||
Me.label1.AutoSize = True
|
||||
Me.label1.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
||||
Me.label1.Location = New System.Drawing.Point(13, 24)
|
||||
Me.label1.Name = "label1"
|
||||
Me.label1.Size = New System.Drawing.Size(641, 21)
|
||||
Me.label1.TabIndex = 3
|
||||
Me.label1.Text = "This sample demonstrates how to display multiple layer column headers on the Data" & _
|
||||
"GridView."
|
||||
Me.label1.UseCompatibleTextRendering = True
|
||||
'
|
||||
'dataGridView1
|
||||
'
|
||||
Me.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
|
||||
Me.dataGridView1.Location = New System.Drawing.Point(18, 60)
|
||||
Me.dataGridView1.Name = "dataGridView1"
|
||||
Me.dataGridView1.Size = New System.Drawing.Size(621, 389)
|
||||
Me.dataGridView1.TabIndex = 2
|
||||
'
|
||||
'MainForm
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.ClientSize = New System.Drawing.Size(667, 473)
|
||||
Me.Controls.Add(Me.label1)
|
||||
Me.Controls.Add(Me.dataGridView1)
|
||||
Me.Name = "MainForm"
|
||||
Me.Text = "MainForm"
|
||||
CType(Me.dataGridView1, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
Me.ResumeLayout(False)
|
||||
Me.PerformLayout()
|
||||
|
||||
End Sub
|
||||
Private WithEvents label1 As System.Windows.Forms.Label
|
||||
Private WithEvents dataGridView1 As System.Windows.Forms.DataGridView
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,90 @@
|
||||
'************************************* Module Header **************************************\
|
||||
' Module Name: MultipleLayeredColumnHeader
|
||||
' Project: VBWinFormDataGridView
|
||||
' Copyright (c) Microsoft Corporation.
|
||||
'
|
||||
' This sample demonstrates how to display multiple layer column headers on the DataGridView.
|
||||
'
|
||||
' This source is subject to the Microsoft Public License.
|
||||
' See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
' All other rights reserved.
|
||||
'
|
||||
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
'**********************************************************************************/
|
||||
|
||||
Namespace VBWinFormDataGridView.MultipleLayeredColumnHeader
|
||||
|
||||
Public Class MainForm
|
||||
|
||||
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
||||
Me.dataGridView1.Columns.Add("JanWin", "Win")
|
||||
Me.dataGridView1.Columns.Add("JanLoss", "Loss")
|
||||
Me.dataGridView1.Columns.Add("FebWin", "Win")
|
||||
Me.dataGridView1.Columns.Add("FebLoss", "Loss")
|
||||
Me.dataGridView1.Columns.Add("MarWin", "Win")
|
||||
Me.dataGridView1.Columns.Add("MarLoss", "Loss")
|
||||
|
||||
For j As Integer = 0 To Me.dataGridView1.ColumnCount - 1
|
||||
Me.dataGridView1.Columns(j).Width = 45
|
||||
Next
|
||||
|
||||
' Enable resizing on the column headers
|
||||
Me.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
|
||||
|
||||
' Adjust the height for the column headers
|
||||
Me.dataGridView1.ColumnHeadersHeight = Me.dataGridView1.ColumnHeadersHeight * 2
|
||||
|
||||
' Adjust the text alignment on the column headers to make the text display
|
||||
' at the center of the bottom
|
||||
Me.dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter
|
||||
|
||||
' Handle the CellPainting event to draw text for each header cell
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub dataGridView1_CellPainting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles dataGridView1.CellPainting
|
||||
If e.RowIndex = -1 AndAlso e.ColumnIndex > -1 Then
|
||||
e.PaintBackground(e.CellBounds, False)
|
||||
Dim r2 As Rectangle = e.CellBounds
|
||||
r2.Y += e.CellBounds.Height / 2
|
||||
r2.Height = e.CellBounds.Height / 2
|
||||
e.PaintContent(r2)
|
||||
e.Handled = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub dataGridView1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles dataGridView1.Paint
|
||||
' Data for the "merged" header cells
|
||||
Dim monthes As String() = {"January", "February", "March"}
|
||||
For j As Integer = 0 To Me.dataGridView1.ColumnCount - 1 Step 2
|
||||
' Get the column header cell bounds
|
||||
Dim r1 As Rectangle = Me.dataGridView1.GetCellDisplayRectangle(j, -1, True)
|
||||
|
||||
r1.X += 1
|
||||
r1.Y += 1
|
||||
r1.Width = r1.Width * 2 - 2
|
||||
r1.Height = r1.Height / 2 - 2
|
||||
|
||||
Using br As SolidBrush = New SolidBrush(Me.dataGridView1.ColumnHeadersDefaultCellStyle.BackColor)
|
||||
e.Graphics.FillRectangle(br, r1)
|
||||
End Using
|
||||
|
||||
Using p As Pen = New Pen(SystemColors.InactiveBorder)
|
||||
e.Graphics.DrawLine(p, r1.X, r1.Bottom, r1.Right, r1.Bottom)
|
||||
End Using
|
||||
|
||||
Using format As StringFormat = New StringFormat()
|
||||
Using br As SolidBrush = New SolidBrush(Me.dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor)
|
||||
format.Alignment = StringAlignment.Center
|
||||
format.LineAlignment = StringAlignment.Center
|
||||
e.Graphics.DrawString(monthes(j / 2), Me.dataGridView1.ColumnHeadersDefaultCellStyle.Font, _
|
||||
br, r1, format)
|
||||
End Using
|
||||
End Using
|
||||
Next
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,65 @@
|
||||
================================================================================
|
||||
WINDOWS FORMS APPLICATION : VBWinFormDataGridView Project Overview
|
||||
|
||||
MultipleLayeredColumnHeader Sample
|
||||
|
||||
===============================================================================
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Use:
|
||||
|
||||
This sample demonstrates how to display multiple layer column headers on the
|
||||
DataGridView contorl.
|
||||
|
||||
|
||||
-----------------------------------------------------------------
|
||||
| January | February | March |
|
||||
| Win | Loss | Win | Loss | Win | Loss |
|
||||
-----------------------------------------------------------------
|
||||
Team1 | | | | | | |
|
||||
-----------------------------------------------------------------
|
||||
Team2 | | | | | | |
|
||||
-----------------------------------------------------------------
|
||||
TeamN | | | | | | |
|
||||
-----------------------------------------------------------------
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Code Logic:
|
||||
|
||||
1. Enable resizing on the column headers by setting the
|
||||
ColumnHeadersHeightSizeMode property as follows:
|
||||
|
||||
this.dataGridView1.ColumnHeadersHeightSizeMode =
|
||||
DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
|
||||
|
||||
2. Adjust the height for the column headers to make it wide enough for two
|
||||
layers;
|
||||
|
||||
this.dataGridView1.ColumnHeadersHeight =
|
||||
this.dataGridView1.ColumnHeadersHeight * 2;
|
||||
|
||||
|
||||
3. Adjust the text alignment on the column headers to make the text display
|
||||
at the center of the bottom;
|
||||
|
||||
this.dataGridView1.ColumnHeadersDefaultCellStyle.Alignment =
|
||||
DataGridViewContentAlignment.BottomCenter;
|
||||
|
||||
4. Handle the DataGridView.CellPainting event to draw text for each header
|
||||
cell;
|
||||
|
||||
5. Handle the DataGridView.Paint event to draw "merged" header cells;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
References:
|
||||
|
||||
1. DataGridView Class
|
||||
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx
|
||||
|
||||
2. Windows Forms FAQs
|
||||
http://windowsclient.net/blogs/faqs/archive/tags/Custom+Designers/default.aspx
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,38 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.34209
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
'NOTE: This file is auto-generated; do not modify it directly. To make changes,
|
||||
' or if you encounter build errors in this file, go to the Project Designer
|
||||
' (go to Project Properties or double-click the My Project node in
|
||||
' Solution Explorer), and make changes on the Application tab.
|
||||
'
|
||||
Partial Friend Class MyApplication
|
||||
|
||||
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
|
||||
Public Sub New()
|
||||
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
|
||||
Me.IsSingleInstance = false
|
||||
Me.EnableVisualStyles = true
|
||||
Me.SaveMySettingsOnExit = true
|
||||
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
|
||||
End Sub
|
||||
|
||||
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
|
||||
Protected Overrides Sub OnCreateMainForm()
|
||||
Me.MainForm = Global.VBWinFormDataGridView.VBWinFormDataGridView.DataGridViewPaging.MainForm
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<MySubMain>true</MySubMain>
|
||||
<MainForm>VBWinFormDataGridView.DataGridViewPaging.MainForm</MainForm>
|
||||
<SingleInstance>false</SingleInstance>
|
||||
<ShutdownMode>0</ShutdownMode>
|
||||
<EnableVisualStyles>true</EnableVisualStyles>
|
||||
<AuthenticationMode>0</AuthenticationMode>
|
||||
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
|
||||
</MyApplicationData>
|
||||
@@ -0,0 +1,35 @@
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' General Information about an assembly is controlled through the following
|
||||
' set of attributes. Change these attribute values to modify the information
|
||||
' associated with an assembly.
|
||||
|
||||
' Review the values of the assembly attributes
|
||||
|
||||
<Assembly: AssemblyTitle("VBWinFormDataGridView")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("Microsoft Corporation")>
|
||||
<Assembly: AssemblyProduct("VBWinFormDataGridView")>
|
||||
<Assembly: AssemblyCopyright("Copyright © Microsoft 2010")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
'The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
<Assembly: Guid("501a2a66-e6c9-4875-9d0a-3e3530bac633")>
|
||||
|
||||
' Version information for an assembly consists of the following four values:
|
||||
'
|
||||
' Major Version
|
||||
' Minor Version
|
||||
' Build Number
|
||||
' Revision
|
||||
'
|
||||
' You can specify all the values or you can default the Build and Revision Numbers
|
||||
' by using the '*' as shown below:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
@@ -0,0 +1,63 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.34209
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace My.Resources
|
||||
|
||||
'This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
'class via a tool like ResGen or Visual Studio.
|
||||
'To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
'with the /str option, or rebuild your VS project.
|
||||
'''<summary>
|
||||
''' A strongly-typed resource class, for looking up localized strings, etc.
|
||||
'''</summary>
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||
Friend Module Resources
|
||||
|
||||
Private resourceMan As Global.System.Resources.ResourceManager
|
||||
|
||||
Private resourceCulture As Global.System.Globalization.CultureInfo
|
||||
|
||||
'''<summary>
|
||||
''' Returns the cached ResourceManager instance used by this class.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
|
||||
Get
|
||||
If Object.ReferenceEquals(resourceMan, Nothing) Then
|
||||
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("VBWinFormDataGridView.Resources", GetType(Resources).Assembly)
|
||||
resourceMan = temp
|
||||
End If
|
||||
Return resourceMan
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Overrides the current thread's CurrentUICulture property for all
|
||||
''' resource lookups using this strongly typed resource class.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend Property Culture() As Global.System.Globalization.CultureInfo
|
||||
Get
|
||||
Return resourceCulture
|
||||
End Get
|
||||
Set
|
||||
resourceCulture = value
|
||||
End Set
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,73 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.34209
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
|
||||
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
|
||||
|
||||
#Region "My.Settings Auto-Save Functionality"
|
||||
#If _MyType = "WindowsForms" Then
|
||||
Private Shared addedHandler As Boolean
|
||||
|
||||
Private Shared addedHandlerLockObject As New Object
|
||||
|
||||
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
|
||||
If My.Application.SaveMySettingsOnExit Then
|
||||
My.Settings.Save()
|
||||
End If
|
||||
End Sub
|
||||
#End If
|
||||
#End Region
|
||||
|
||||
Public Shared ReadOnly Property [Default]() As MySettings
|
||||
Get
|
||||
|
||||
#If _MyType = "WindowsForms" Then
|
||||
If Not addedHandler Then
|
||||
SyncLock addedHandlerLockObject
|
||||
If Not addedHandler Then
|
||||
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||
addedHandler = True
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
#End If
|
||||
Return defaultInstance
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||
Friend Module MySettingsProperty
|
||||
|
||||
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||
Friend ReadOnly Property Settings() As Global.VBWinFormDataGridView.My.MySettings
|
||||
Get
|
||||
Return Global.VBWinFormDataGridView.My.MySettings.Default
|
||||
End Get
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,227 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{27D2633B-4F34-466C-9177-BCCE6CA02AE6}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<StartupObject>VBWinFormDataGridView.My.MyApplication</StartupObject>
|
||||
<RootNamespace>VBWinFormDataGridView</RootNamespace>
|
||||
<AssemblyName>VBWinFormDataGridView</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>WindowsForms</MyType>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>VBWinFormDataGridView.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355</NoWarn>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DocumentationFile>VBWinFormDataGridView.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355</NoWarn>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Collections.Generic" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Drawing" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
<Import Include="System.Windows.Forms" />
|
||||
<Import Include="System.Linq" />
|
||||
<Import Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CustomDataGridViewColumn\MainForm.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CustomDataGridViewColumn\MainForm.Designer.vb">
|
||||
<DependentUpon>MainForm.vb</DependentUpon>
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CustomDataGridViewColumn\MaskedTextBoxCell.vb" />
|
||||
<Compile Include="CustomDataGridViewColumn\MaskedTextBoxColumn.vb" />
|
||||
<Compile Include="CustomDataGridViewColumn\MaskedTextBoxEditingControl.vb">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DataGridViewPaging\MainForm.Designer.vb">
|
||||
<DependentUpon>MainForm.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DataGridViewPaging\MainForm.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="EditingControlHosting\MainForm.Designer.vb">
|
||||
<DependentUpon>MainForm.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="EditingControlHosting\MainForm.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="JustInTimeDataLoading\Cache.vb" />
|
||||
<Compile Include="JustInTimeDataLoading\MainForm.Designer.vb">
|
||||
<DependentUpon>MainForm.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="JustInTimeDataLoading\MainForm.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MultipleLayeredColumnHeader\MainForm.Designer.vb">
|
||||
<DependentUpon>MainForm.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MultipleLayeredColumnHeader\MainForm.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Settings.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="CustomDataGridViewColumn\MainForm.resx">
|
||||
<DependentUpon>MainForm.vb</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="DataGridViewPaging\MainForm.resx">
|
||||
<DependentUpon>MainForm.vb</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="EditingControlHosting\MainForm.resx">
|
||||
<DependentUpon>MainForm.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="JustInTimeDataLoading\MainForm.resx">
|
||||
<DependentUpon>MainForm.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="MultipleLayeredColumnHeader\MainForm.resx">
|
||||
<DependentUpon>MainForm.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="Documentation\ReadMe_files\themedata.thmx" />
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="My Project\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<CustomToolNamespace>My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="CustomDataGridViewColumn\ReadMe.txt" />
|
||||
<Content Include="DataGridViewPaging\ReadMe.txt" />
|
||||
<Content Include="Documentation\ReadMe.htm" />
|
||||
<Content Include="Documentation\ReadMe_files\colorschememapping.xml" />
|
||||
<Content Include="Documentation\ReadMe_files\filelist.xml" />
|
||||
<Content Include="Documentation\ReadMe_files\header.htm" />
|
||||
<Content Include="Documentation\ReadMe_files\image001.png" />
|
||||
<Content Include="Documentation\ReadMe_files\image002.jpg" />
|
||||
<Content Include="Documentation\ReadMe_files\image003.png" />
|
||||
<Content Include="Documentation\ReadMe_files\image004.jpg" />
|
||||
<Content Include="Documentation\ReadMe_files\image005.png" />
|
||||
<Content Include="Documentation\ReadMe_files\image006.jpg" />
|
||||
<Content Include="Documentation\ReadMe_files\image007.png" />
|
||||
<Content Include="Documentation\ReadMe_files\image008.jpg" />
|
||||
<Content Include="Documentation\ReadMe_files\image009.png" />
|
||||
<Content Include="Documentation\ReadMe_files\image010.jpg" />
|
||||
<Content Include="Documentation\ReadMe_files\image011.png" />
|
||||
<Content Include="EditingControlHosting\ReadMe.txt" />
|
||||
<Content Include="JustInTimeDataLoading\ReadMe.txt" />
|
||||
<Content Include="MultipleLayeredColumnHeader\ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,601 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head><link rel="stylesheet" type="text/css" href="description/Combined.css,0:HeaderFooterSprite,0:Header.NonMtps,1:LinkList;/Areas/Centers/Themes/StandardDevCenter/Content:0,/Areas/Epx/Themes/Base/Content:1&amp;hashKey=C9973DA951AE6202C9B348379A1BE49D" xmlns="http://www.w3.org/1999/xhtml" />
|
||||
<link type="text/css" rel="stylesheet" xmlns="http://www.w3.org/1999/xhtml" />
|
||||
<link rel="stylesheet" type="text/css" href="description/1c1e217c-1475-400e-91a7-b2be1bd6efa0Combined.css,0:HeaderFooterSprite,0:Footer.NonMtps,1:LinkList;/Areas/Centers/Themes/StandardDevCenter/Content:0,/Areas/Epx/Themes/Base/Content:1&amp;hashKey=F576C687BC536B84D6E5B3246EE39B49" xmlns="http://www.w3.org/1999/xhtml" />
|
||||
<link type="text/css" rel="stylesheet" xmlns="http://www.w3.org/1999/xhtml" />
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Windows Forms DataGridView demo (VBWinFormDataGridView)</title>
|
||||
<link href="description/Galleries.css" type="text/css" rel="Stylesheet" /><link href="description/Layout.css" type="text/css" rel="Stylesheet" /><link href="description/Brand.css" type="text/css" rel="Stylesheet" />
|
||||
<link href="description/iframedescription.css" rel="Stylesheet" type="text/css" />
|
||||
<script src="description/offline.js" type="text/javascript"></script>
|
||||
<style type="text/css">
|
||||
#projectInfo {
|
||||
overflow: auto;
|
||||
}
|
||||
#longDesc {
|
||||
clear:both;
|
||||
margin: 25px 0 10px 0;
|
||||
}
|
||||
|
||||
#SampleIndexList{
|
||||
margin-left: 15px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="offlineDescription">
|
||||
<h1>Windows Forms DataGridView demo (VBWinFormDataGridView)</h1>
|
||||
<br/>
|
||||
<div id="projectInfo">
|
||||
<div class="section">
|
||||
<div class="itemBarLong tagsContainer">
|
||||
<label for="Technologies">Technologies</label>
|
||||
<div id="Technologies">
|
||||
Windows Forms
|
||||
</div>
|
||||
</div>
|
||||
<div class="itemBarLong tagsContainer">
|
||||
<label for="Topics">Topics</label>
|
||||
<div id="Topics">
|
||||
Data Binding, DataGridView
|
||||
</div>
|
||||
</div>
|
||||
<div class="itemBarLong">
|
||||
<label for="Platforms">Platforms</label>
|
||||
<div id="Platforms">
|
||||
Desktop
|
||||
</div>
|
||||
</div>
|
||||
<div class="itemBarLong">
|
||||
<label for="Requirements">Requirements</label>
|
||||
<div id="Requirements">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="itemBar">
|
||||
<label for="LastUpdated">Primary language</label>
|
||||
<div id="LastUpdated">en-US</div>
|
||||
</div>
|
||||
<div class="itemBar">
|
||||
<label for="LastUpdated">Updated</label>
|
||||
<div id="LastUpdated">3/4/2012</div>
|
||||
</div>
|
||||
<div class="itemBarLong">
|
||||
<label for="License">License</label>
|
||||
<div id="License">
|
||||
<a href="license.rtf">MS-LPL</a></div>
|
||||
</div>
|
||||
<div class="itemBar">
|
||||
<div class="viewonlinecont">
|
||||
<a data-link="online" href="http://code.msdn.microsoft.com/VBWinFormDataGridView-961db2a6">View this sample online</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function initializePage() {
|
||||
var otherTabClass = 'otherTab';
|
||||
var hiddenPreClass = 'hidden';
|
||||
|
||||
var htmlDecode = function(encodedData) {
|
||||
var decodedData = "";
|
||||
if (encodedData) {
|
||||
var div = document.createElement('div');
|
||||
div.innerHTML = encodedData;
|
||||
decodedData = div.firstChild.nodeValue.replace( /\\r\\n/ig , '\r\n');
|
||||
}
|
||||
return decodedData;
|
||||
};
|
||||
|
||||
Galleries.iterateElem(Galleries.findElem(null, 'div', 'scriptcode'), function (index, scriptBlock) {
|
||||
var titleElem = Galleries.findElem(scriptBlock, 'div', 'title')[0];
|
||||
var labelElems = Galleries.findElem(titleElem, 'span');
|
||||
if (labelElems.length == 0) {
|
||||
labelElems = titleElem;
|
||||
}
|
||||
var languageSpans = Galleries.findElem(scriptBlock, 'span', 'hidden');
|
||||
var pres = Galleries.findElem(scriptBlock, 'pre');
|
||||
if (languageSpans.length > 0 && pres.length > 1) {
|
||||
Galleries.iterateElem(labelElems, function(index, elem) {
|
||||
var codePre = pres[index];
|
||||
var labelSpan = elem;
|
||||
var languageSpan = languageSpans[index];
|
||||
|
||||
elem.code = codePre.innerHTML.replace( /(\r(\n)?)|((\r)?\n)/ig , '\\r\\n');
|
||||
|
||||
codePre.className = codePre.className.replace(hiddenPreClass, '');
|
||||
|
||||
languageSpan.parentNode.removeChild(languageSpan);
|
||||
});
|
||||
|
||||
pres = Galleries.findElem(scriptBlock, 'pre');
|
||||
Galleries.iterateElem(labelElems, function(index, elem) {
|
||||
var codePre = pres[index];
|
||||
var labelSpan = elem;
|
||||
if (index == 0) {
|
||||
scriptBlock.activeTab = 0;
|
||||
}
|
||||
else {
|
||||
labelSpan.className += otherTabClass;
|
||||
codePre.className += hiddenPreClass;
|
||||
}
|
||||
Galleries.attachEventHandler(labelSpan, 'click', function(e) {
|
||||
var activeTab = scriptBlock.activeTab;
|
||||
labelElems[activeTab].className += otherTabClass;
|
||||
pres[activeTab].className += hiddenPreClass;
|
||||
|
||||
codePre.className = codePre.className.replace(hiddenPreClass, '');
|
||||
labelSpan.className = labelSpan.className.replace(otherTabClass, '');
|
||||
scriptBlock.activeTab = index;
|
||||
});
|
||||
});
|
||||
|
||||
var preview = Galleries.findElem(scriptBlock, 'div', 'preview');
|
||||
if (preview.length == 0) {
|
||||
preview.push(pres[pres.length - 1]);
|
||||
}
|
||||
Galleries.iterateElem(preview, function(index, elem) {
|
||||
elem.parentNode.removeChild(elem);
|
||||
});
|
||||
|
||||
if (window.clipboardData && clipboardData.setData) {
|
||||
var copyLink = document.createElement('a');
|
||||
copyLink.href = 'javascript:void(0);';
|
||||
copyLink.className = 'copyCode';
|
||||
copyLink.innerHTML = 'Copy code';
|
||||
Galleries.attachEventHandler(copyLink, 'click', function (e) {
|
||||
clipboardData.setData("Text", htmlDecode(labelElems[scriptBlock.activeTab].code));
|
||||
return false;
|
||||
});
|
||||
scriptBlock.insertBefore(copyLink, scriptBlock.childNodes[0]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Galleries.onWindowLoad(function(){
|
||||
initializePage();
|
||||
});
|
||||
|
||||
</script>
|
||||
<div id="longDesc">
|
||||
|
||||
<h1><span style="font-family:������">WINDOWS FORMS APPLICATION</span> (<span style="font-family:������">VBWinFormDataGridView</span>)</h1>
|
||||
<h2>Introduction</h2>
|
||||
<p class="MsoNormal"><span style="">There are five samples in this solution to demonstrate DataGridView:
|
||||
</span></p>
|
||||
<p class="MsoListParagraphCxSpFirst" style=""><span style=""><span style="">1.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>CustomDataGridViewColumn<span style="">:</span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle">This sample demonstrates how to create a custom DataGridView column<span style="">.
|
||||
</span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle" style=""><span style=""><span style="">2.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>DataGridViewPaging<span style="">:</span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle">This sample demonstrates how to page data in the<span style="">
|
||||
</span>DataGridView control<span style="">. </span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle" style=""><span style=""><span style="">3.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>EditingControlHosting<span style="">:</span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle">This sample demonstrates how to host a control in the current DataGridViewCell<span style="">
|
||||
</span>for editing.</p>
|
||||
<p class="MsoListParagraphCxSpMiddle" style=""><span style=""><span style="">4.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>JustInTimeDataLoading<span style="">:</span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle">If you are working with a very large table in a remote database, for example, you might want to avoid startup delays by retrieving only the data that is necessary for display and retrieving additional data only when the
|
||||
user scrolls<span style=""> </span>new rows into view. If the client computers running your application have a<span style="">
|
||||
</span>limited amount of memory available for storing data, you might also want to<span style="">
|
||||
</span>discard unused data when retrieving new values from the database.</p>
|
||||
<p class="MsoListParagraphCxSpMiddle">This sample demonstrates how to use virtual mode in the DataGridView control<span style="">
|
||||
</span>with a data cache that loads data from a server only when it is needed.<span style="">
|
||||
</span>This kind of data loading is called "Just-in-time data loading".</p>
|
||||
<p class="MsoListParagraphCxSpMiddle" style=""><span style=""><span style="">5.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>MultipleLayeredColumnHeader<span style="">:</span></p>
|
||||
<p class="MsoListParagraphCxSpLast">This sample demonstrates how to display multiple layer column headers on the DataGridView contorl.<span style="">
|
||||
</span></p>
|
||||
<h2>Running the Sample</h2>
|
||||
<p class="MsoListParagraph" style=""><span style=""><span style="">1.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>CustomDataGridViewColumn.</p>
|
||||
<p class="MsoNormal"><span style=""><img src="description/image.png" alt="" width="576" height="407" align="middle">
|
||||
</span><span style=""></span></p>
|
||||
<p class="MsoListParagraph" style=""><span style=""><span style="">2.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>DataGridViewPaging<span style="">.</span></p>
|
||||
<p class="MsoNormal"><span style=""><img src="description/4c4d2c39-e583-48a8-95c7-13f2534db7e5image.png" alt="" width="576" height="512" align="middle">
|
||||
</span></p>
|
||||
<p class="MsoListParagraph" style=""><span style=""><span style="">3.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span><span style="">EditingControlHosting. </span></p>
|
||||
<p class="MsoNormal"><span style=""><img src="description/e91a529a-733b-4283-a54e-e28c15880dc6image.png" alt="" width="576" height="428" align="middle">
|
||||
</span><span style=""></span></p>
|
||||
<p class="MsoListParagraph" style=""><span style=""><span style="">4.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>JustInTimeDataLoading<span style="">. </span></p>
|
||||
<p class="MsoNormal"><span style=""><img src="description/12c98344-11ba-4fbc-84f9-8e78d71d1afeimage.png" alt="" width="576" height="460" align="middle">
|
||||
</span><span style=""></span></p>
|
||||
<p class="MsoListParagraph" style=""><span style=""><span style="">5.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>MultipleLayeredColumnHeader<span style="">.</span></p>
|
||||
<p class="MsoNormal"><span style=""><img src="description/a89925e1-4a65-4f1f-9f5a-8e70ce5146b4image.png" alt="" width="576" height="431" align="middle">
|
||||
</span></p>
|
||||
<p class="MsoNormal">. </p>
|
||||
<h2>Using the Code</h2>
|
||||
<p class="MsoListParagraph" style=""><span style=""><span style="">1.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>CustomDataGridViewColumn<span style="">. </span></p>
|
||||
<p class="MsoNormal" style="margin-left:36.0pt">There're six standard DataGridViewColumn types for use as follows:</p>
|
||||
<p class="MsoNormal" style="margin-left:72.0pt"><span style=""><img src="description/f1d00a92-af6e-43ae-9c09-84b019f2c544image.png" alt="" width="433" height="407" align="middle">
|
||||
</span><span style="background:#D9D9D9"></span></p>
|
||||
<p class="MsoNormal" style="margin-left:36.0pt">However, developers may want to use a different control for editing on the column,<span style="">
|
||||
</span>e.g. MarkedTextBox, DateTimePicker etc. This feature can be achieved in two ways:</p>
|
||||
<p class="MsoNormal" style="margin-left:36.0pt"><span style="">A</span>. Create a custom DataGridViewColumn;
|
||||
</p>
|
||||
<p class="MsoNormal" style="margin-left:36.0pt"><span style=""> </span>
|
||||
The code in this CustomDataGridViewColumn sample demonstrates how to do this;<span style="">
|
||||
</span></p>
|
||||
<p class="MsoNormal" style="margin-left:36.0pt"><span style="">B</span>. Place the editing control on the current cell when editing begins, and hide the editing control when the editing completes. For the details of this<span style="">
|
||||
</span>approach, please refer to the <span style=""><span style=""> </span></span>EditingControlHosting sample.<span style="">
|
||||
</span></p>
|
||||
<p class="MsoListParagraph" style=""><span style=""><span style="">2.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>DataGridViewPaging<span style=""> </span></p>
|
||||
<p class="MsoNormal" style="margin-left:36.0pt"><span style="">A. Get total count of the rows in the table;
|
||||
</span></p>
|
||||
<p class="MsoNormal" style="margin-left:36.0pt"><span style="">B. Calculate total count of pages;
|
||||
</span></p>
|
||||
<p class="MsoNormal" style="margin-left:36.0pt"><span style="">C. Load each page on demand;
|
||||
</span></p>
|
||||
<p class="MsoListParagraphCxSpFirst" style=""><span style=""><span style="">3.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>EditingControlHosting<span style=""> </span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle"><span style="">A. Create an instance of the editing control, in this sample the editing control is MaskedTextBox.<span style="">
|
||||
</span></span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle"><span style="">B. Specify a mask for the MaskedTextBox and add the MaskedTextBox to the control collection of the DataGridView;<span style="">
|
||||
</span></span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle"><span style="">C. Hide the MaskedTextBox;
|
||||
</span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle"><span style="">D. Handle the CellBeginEdit event to show the MaskedTextBox on the current editing cell;<span style="">
|
||||
</span></span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle"><span style="">E. Handle the CellEndEdit event to hide the MaskedTextBox when editing completes;
|
||||
</span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle"><span style="">F. Handle the Scroll event to adjust the location of the MaskedTextBox as it is showing when scrolling the DataGridView;
|
||||
</span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle"><span style="">G. Handle the EditingControlShowing event to pass the focus to the MaskedTextBox when begin editing with keystrokes;
|
||||
</span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle" style=""><span style=""><span style="">4.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>JustInTimeDataLoading</p>
|
||||
<p class="MsoListParagraphCxSpLast"><span style="">A</span>.<span style="">
|
||||
</span>Enable VirtualMode on the DataGridView control by setting the VirtualMode property to true:<span style="">
|
||||
</span><span style=""></span></p>
|
||||
<div class="scriptcode">
|
||||
<div class="pluginEditHolder" pluginCommand="mceScriptCode">
|
||||
<div class="title"><span>VB</span></div>
|
||||
<div class="pluginLinkHolder"><span class="pluginEditHolderLink">Edit</span>|<span class="pluginRemoveHolderLink">Remove</span>
|
||||
</div>
|
||||
<span class="hidden">vb</span>
|
||||
<pre class="hidden">
|
||||
' Enable VirtualMode on the DataGridView
|
||||
Me.dataGridView1.VirtualMode = True
|
||||
|
||||
</pre>
|
||||
<pre id="codePreview" class="vb">
|
||||
' Enable VirtualMode on the DataGridView
|
||||
Me.dataGridView1.VirtualMode = True
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="endscriptcode"> </div>
|
||||
<p class="MsoListParagraphCxSpFirst"><span style=""></span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle"><span style="">B</span>.<span style="">
|
||||
</span>Add columns to the DataGridView according to the data in the database;<span style="">
|
||||
</span></p>
|
||||
<p class="MsoListParagraphCxSpLast"><span style="">C</span>.<span style="">
|
||||
</span>Retrieve the row count of the data in the database and set the RowCount<span style="">
|
||||
</span>property for the DataGridView;<span style=""> </span><span style=""></span></p>
|
||||
<div class="scriptcode">
|
||||
<div class="pluginEditHolder" pluginCommand="mceScriptCode">
|
||||
<div class="title"><span>VB</span></div>
|
||||
<div class="pluginLinkHolder"><span class="pluginEditHolderLink">Edit</span>|<span class="pluginRemoveHolderLink">Remove</span>
|
||||
</div>
|
||||
<span class="hidden">vb</span>
|
||||
<pre class="hidden">
|
||||
' Handle the CellValueNeeded event to retrieve the requested cell value
|
||||
' from the data store or the Customer object currently in edit.
|
||||
' This event occurs whenever the DataGridView control needs to paint a cell.
|
||||
|
||||
|
||||
' Create a DataRetriever and use it to create a Cache object
|
||||
' and to initialize the DataGridView columns and rows.
|
||||
Try
|
||||
Dim retriever As DataRetriever = New DataRetriever(connectionString, table)
|
||||
memoryCache = New Cache(retriever, 16)
|
||||
For Each column As DataColumn In retriever.Columns
|
||||
dataGridView1.Columns.Add(column.ColumnName, column.ColumnName)
|
||||
Next
|
||||
Me.dataGridView1.RowCount = retriever.RowCount
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Connection could not be established. " + _
|
||||
"Verify that the connection string is valid.")
|
||||
Application.Exit()
|
||||
End Try
|
||||
|
||||
</pre>
|
||||
<pre id="codePreview" class="vb">
|
||||
' Handle the CellValueNeeded event to retrieve the requested cell value
|
||||
' from the data store or the Customer object currently in edit.
|
||||
' This event occurs whenever the DataGridView control needs to paint a cell.
|
||||
|
||||
|
||||
' Create a DataRetriever and use it to create a Cache object
|
||||
' and to initialize the DataGridView columns and rows.
|
||||
Try
|
||||
Dim retriever As DataRetriever = New DataRetriever(connectionString, table)
|
||||
memoryCache = New Cache(retriever, 16)
|
||||
For Each column As DataColumn In retriever.Columns
|
||||
dataGridView1.Columns.Add(column.ColumnName, column.ColumnName)
|
||||
Next
|
||||
Me.dataGridView1.RowCount = retriever.RowCount
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Connection could not be established. " + _
|
||||
"Verify that the connection string is valid.")
|
||||
Application.Exit()
|
||||
End Try
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="endscriptcode"> </div>
|
||||
<p class="MsoListParagraphCxSpFirst"><span style=""></span></p>
|
||||
<p class="MsoListParagraphCxSpLast"><span style="">D</span>.<span style="">
|
||||
</span>Handle the CellValueNeeded event to retrieve the requested cell value from the data store or the Customer object currently in edit.<span style="">
|
||||
</span></p>
|
||||
<div class="scriptcode">
|
||||
<div class="pluginEditHolder" pluginCommand="mceScriptCode">
|
||||
<div class="title"><span>VB</span></div>
|
||||
<div class="pluginLinkHolder"><span class="pluginEditHolderLink">Edit</span>|<span class="pluginRemoveHolderLink">Remove</span>
|
||||
</div>
|
||||
<span class="hidden">vb</span>
|
||||
<pre class="hidden">
|
||||
Private Sub dataGridView1_CellValueNeeded(ByVal sender As <a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/System.Object.aspx" title="Auto generated link to System.Object">System.Object</a>, ByVal e As <a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/System.Windows.Forms.DataGridViewCellValueEventArgs.aspx" title="Auto generated link to System.Windows.Forms.DataGridViewCellValueEventArgs">System.Windows.Forms.DataGridViewCellValueEventArgs</a>) Handles dataGridView1.CellValueNeeded
|
||||
e.Value = memoryCache.RetrieveElement(e.RowIndex, e.ColumnIndex)
|
||||
End Sub
|
||||
|
||||
</pre>
|
||||
<pre id="codePreview" class="vb">
|
||||
Private Sub dataGridView1_CellValueNeeded(ByVal sender As <a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/System.Object.aspx" title="Auto generated link to System.Object">System.Object</a>, ByVal e As <a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/System.Windows.Forms.DataGridViewCellValueEventArgs.aspx" title="Auto generated link to System.Windows.Forms.DataGridViewCellValueEventArgs">System.Windows.Forms.DataGridViewCellValueEventArgs</a>) Handles dataGridView1.CellValueNeeded
|
||||
e.Value = memoryCache.RetrieveElement(e.RowIndex, e.ColumnIndex)
|
||||
End Sub
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="endscriptcode"> </div>
|
||||
<p class="MsoListParagraphCxSpFirst"><span style=""></span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle" style=""><span style=""><span style="">5.<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span>MultipleLayeredColumnHeader</p>
|
||||
<p class="MsoListParagraphCxSpLast"><span style="">A</span>.<span style="">
|
||||
</span>Enable resizing on the column headers by setting the ColumnHeadersHeightSizeMode property as follows:<span style="">
|
||||
</span></p>
|
||||
<div class="scriptcode">
|
||||
<div class="pluginEditHolder" pluginCommand="mceScriptCode">
|
||||
<div class="title"><span>VB</span></div>
|
||||
<div class="pluginLinkHolder"><span class="pluginEditHolderLink">Edit</span>|<span class="pluginRemoveHolderLink">Remove</span>
|
||||
</div>
|
||||
<span class="hidden">vb</span>
|
||||
<pre class="hidden">
|
||||
' Enable resizing on the column headers
|
||||
Me.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
|
||||
|
||||
</pre>
|
||||
<pre id="codePreview" class="vb">
|
||||
' Enable resizing on the column headers
|
||||
Me.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="endscriptcode"> </div>
|
||||
<p class="MsoListParagraphCxSpFirst"><span style=""></span></p>
|
||||
<p class="MsoListParagraphCxSpLast"><span style="">B</span>.<span style="">
|
||||
</span>Adjust the height for the column headers to make it wide enough for two layers;<span style="">
|
||||
</span></p>
|
||||
<div class="scriptcode">
|
||||
<div class="pluginEditHolder" pluginCommand="mceScriptCode">
|
||||
<div class="title"><span>VB</span></div>
|
||||
<div class="pluginLinkHolder"><span class="pluginEditHolderLink">Edit</span>|<span class="pluginRemoveHolderLink">Remove</span>
|
||||
</div>
|
||||
<span class="hidden">vb</span>
|
||||
<pre class="hidden">
|
||||
' Adjust the height for the column headers
|
||||
Me.dataGridView1.ColumnHeadersHeight = Me.dataGridView1.ColumnHeadersHeight * 2
|
||||
|
||||
</pre>
|
||||
<pre id="codePreview" class="vb">
|
||||
' Adjust the height for the column headers
|
||||
Me.dataGridView1.ColumnHeadersHeight = Me.dataGridView1.ColumnHeadersHeight * 2
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="endscriptcode"> </div>
|
||||
<p class="MsoListParagraphCxSpFirst"><span style=""></span></p>
|
||||
<p class="MsoListParagraphCxSpLast"><span style="">C</span>.<span style="">
|
||||
</span>Adjust the text alignment on the column headers to make the text display at the center of the bottom;<span style="">
|
||||
</span><span style=""></span></p>
|
||||
<div class="scriptcode">
|
||||
<div class="pluginEditHolder" pluginCommand="mceScriptCode">
|
||||
<div class="title"><span>VB</span></div>
|
||||
<div class="pluginLinkHolder"><span class="pluginEditHolderLink">Edit</span>|<span class="pluginRemoveHolderLink">Remove</span>
|
||||
</div>
|
||||
<span class="hidden">vb</span>
|
||||
<pre class="hidden">
|
||||
' Adjust the text alignment on the column headers to make the text display
|
||||
' at the center of the bottom
|
||||
Me.dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter
|
||||
|
||||
|
||||
' Handle the CellPainting event to draw text for each header cell
|
||||
|
||||
</pre>
|
||||
<pre id="codePreview" class="vb">
|
||||
' Adjust the text alignment on the column headers to make the text display
|
||||
' at the center of the bottom
|
||||
Me.dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter
|
||||
|
||||
|
||||
' Handle the CellPainting event to draw text for each header cell
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="endscriptcode"> </div>
|
||||
<p class="MsoListParagraphCxSpFirst"><span style=""></span></p>
|
||||
<p class="MsoListParagraphCxSpLast"><span style="">D</span>.<span style="">
|
||||
</span>Handle the DataGridView.CellPainting event to draw text for each header<span style="">
|
||||
</span>cell;<span style=""> </span></p>
|
||||
<div class="scriptcode">
|
||||
<div class="pluginEditHolder" pluginCommand="mceScriptCode">
|
||||
<div class="title"><span>VB</span></div>
|
||||
<div class="pluginLinkHolder"><span class="pluginEditHolderLink">Edit</span>|<span class="pluginRemoveHolderLink">Remove</span>
|
||||
</div>
|
||||
<span class="hidden">vb</span>
|
||||
<pre class="hidden">
|
||||
Private Sub dataGridView1_CellPainting(ByVal sender As <a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/System.Object.aspx" title="Auto generated link to System.Object">System.Object</a>, ByVal e As <a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/System.Windows.Forms.DataGridViewCellPaintingEventArgs.aspx" title="Auto generated link to System.Windows.Forms.DataGridViewCellPaintingEventArgs">System.Windows.Forms.DataGridViewCellPaintingEventArgs</a>) Handles dataGridView1.CellPainting
|
||||
If e.RowIndex = -1 AndAlso e.ColumnIndex > -1 Then
|
||||
e.PaintBackground(e.CellBounds, False)
|
||||
Dim r2 As Rectangle = e.CellBounds
|
||||
r2.Y += e.CellBounds.Height / 2
|
||||
r2.Height = e.CellBounds.Height / 2
|
||||
e.PaintContent(r2)
|
||||
e.Handled = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
</pre>
|
||||
<pre id="codePreview" class="vb">
|
||||
Private Sub dataGridView1_CellPainting(ByVal sender As <a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/System.Object.aspx" title="Auto generated link to System.Object">System.Object</a>, ByVal e As <a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/System.Windows.Forms.DataGridViewCellPaintingEventArgs.aspx" title="Auto generated link to System.Windows.Forms.DataGridViewCellPaintingEventArgs">System.Windows.Forms.DataGridViewCellPaintingEventArgs</a>) Handles dataGridView1.CellPainting
|
||||
If e.RowIndex = -1 AndAlso e.ColumnIndex > -1 Then
|
||||
e.PaintBackground(e.CellBounds, False)
|
||||
Dim r2 As Rectangle = e.CellBounds
|
||||
r2.Y += e.CellBounds.Height / 2
|
||||
r2.Height = e.CellBounds.Height / 2
|
||||
e.PaintContent(r2)
|
||||
e.Handled = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="endscriptcode"> </div>
|
||||
<p class="MsoListParagraphCxSpFirst"><span style=""></span></p>
|
||||
<p class="MsoListParagraphCxSpLast"><span style="">E</span>.<span style="">
|
||||
</span>Handle the DataGridView.Paint event to draw "merged" header cells;<span style="">
|
||||
</span></p>
|
||||
<div class="scriptcode">
|
||||
<div class="pluginEditHolder" pluginCommand="mceScriptCode">
|
||||
<div class="title"><span>VB</span></div>
|
||||
<div class="pluginLinkHolder"><span class="pluginEditHolderLink">Edit</span>|<span class="pluginRemoveHolderLink">Remove</span>
|
||||
</div>
|
||||
<span class="hidden">vb</span>
|
||||
<pre class="hidden">
|
||||
Private Sub dataGridView1_Paint(ByVal sender As <a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/System.Object.aspx" title="Auto generated link to System.Object">System.Object</a>, ByVal e As <a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/System.Windows.Forms.PaintEventArgs.aspx" title="Auto generated link to System.Windows.Forms.PaintEventArgs">System.Windows.Forms.PaintEventArgs</a>) Handles dataGridView1.Paint
|
||||
' Data for the "merged" header cells
|
||||
Dim monthes As String() = {"January", "February", "March"}
|
||||
For j As Integer = 0 To Me.dataGridView1.ColumnCount - 1 Step 2
|
||||
' Get the column header cell bounds
|
||||
Dim r1 As Rectangle = Me.dataGridView1.GetCellDisplayRectangle(j, -1, True)
|
||||
|
||||
|
||||
r1.X += 1
|
||||
r1.Y += 1
|
||||
r1.Width = r1.Width * 2 - 2
|
||||
r1.Height = r1.Height / 2 - 2
|
||||
|
||||
|
||||
Using br As SolidBrush = New SolidBrush(Me.dataGridView1.ColumnHeadersDefaultCellStyle.BackColor)
|
||||
e.Graphics.FillRectangle(br, r1)
|
||||
End Using
|
||||
|
||||
|
||||
Using p As Pen = New Pen(SystemColors.InactiveBorder)
|
||||
e.Graphics.DrawLine(p, r1.X, r1.Bottom, r1.Right, r1.Bottom)
|
||||
End Using
|
||||
|
||||
|
||||
Using format As StringFormat = New StringFormat()
|
||||
Using br As SolidBrush = New SolidBrush(Me.dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor)
|
||||
format.Alignment = StringAlignment.Center
|
||||
format.LineAlignment = StringAlignment.Center
|
||||
e.Graphics.DrawString(monthes(j / 2), Me.dataGridView1.ColumnHeadersDefaultCellStyle.Font, _
|
||||
br, r1, format)
|
||||
End Using
|
||||
End Using
|
||||
Next
|
||||
End Sub
|
||||
|
||||
</pre>
|
||||
<pre id="codePreview" class="vb">
|
||||
Private Sub dataGridView1_Paint(ByVal sender As <a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/System.Object.aspx" title="Auto generated link to System.Object">System.Object</a>, ByVal e As <a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/System.Windows.Forms.PaintEventArgs.aspx" title="Auto generated link to System.Windows.Forms.PaintEventArgs">System.Windows.Forms.PaintEventArgs</a>) Handles dataGridView1.Paint
|
||||
' Data for the "merged" header cells
|
||||
Dim monthes As String() = {"January", "February", "March"}
|
||||
For j As Integer = 0 To Me.dataGridView1.ColumnCount - 1 Step 2
|
||||
' Get the column header cell bounds
|
||||
Dim r1 As Rectangle = Me.dataGridView1.GetCellDisplayRectangle(j, -1, True)
|
||||
|
||||
|
||||
r1.X += 1
|
||||
r1.Y += 1
|
||||
r1.Width = r1.Width * 2 - 2
|
||||
r1.Height = r1.Height / 2 - 2
|
||||
|
||||
|
||||
Using br As SolidBrush = New SolidBrush(Me.dataGridView1.ColumnHeadersDefaultCellStyle.BackColor)
|
||||
e.Graphics.FillRectangle(br, r1)
|
||||
End Using
|
||||
|
||||
|
||||
Using p As Pen = New Pen(SystemColors.InactiveBorder)
|
||||
e.Graphics.DrawLine(p, r1.X, r1.Bottom, r1.Right, r1.Bottom)
|
||||
End Using
|
||||
|
||||
|
||||
Using format As StringFormat = New StringFormat()
|
||||
Using br As SolidBrush = New SolidBrush(Me.dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor)
|
||||
format.Alignment = StringAlignment.Center
|
||||
format.LineAlignment = StringAlignment.Center
|
||||
e.Graphics.DrawString(monthes(j / 2), Me.dataGridView1.ColumnHeadersDefaultCellStyle.Font, _
|
||||
br, r1, format)
|
||||
End Using
|
||||
End Using
|
||||
Next
|
||||
End Sub
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="endscriptcode"> </div>
|
||||
<p class="MsoListParagraph"><span style=""></span></p>
|
||||
<h2>More Information</h2>
|
||||
<p class="MsoListParagraphCxSpFirst" style="margin-bottom:0cm; margin-bottom:.0001pt; line-height:normal; text-autospace:none">
|
||||
<span style="font-family:Symbol"><span style="">��<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span><span style="font-family:������"><a href="http://windowsclient.net/blogs/faqs/archive/tags/Custom+Designers/default.aspx">Windows Forms FAQs</a>
|
||||
</span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom:0cm; margin-bottom:.0001pt; line-height:normal; text-autospace:none">
|
||||
<span style="font-family:Symbol"><span style="">��<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span><span style="font-family:������"><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx">DataGridView Class</a><span style="">
|
||||
</span></span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom:0cm; margin-bottom:.0001pt; line-height:normal; text-autospace:none">
|
||||
<span style="font-family:Symbol"><span style="">��<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span><span style="font-family:������"><a href="http://msdn.microsoft.com/en-us/library/ms180996.aspx">DataGridView Custom Column Sample</a>
|
||||
</span></p>
|
||||
<p class="MsoListParagraphCxSpMiddle" style="margin-bottom:0cm; margin-bottom:.0001pt; line-height:normal; text-autospace:none">
|
||||
<span style="font-family:Symbol"><span style="">��<span style="font:7.0pt "Times New Roman"">
|
||||
</span></span></span><span style="font-family:������"><a href="http://msdn.microsoft.com/en-us/library/ms171624.aspx">Implementing Virtual Mode with Just-In-Time Data Loading in the Windows Forms DataGridView Control.</a><span style="">
|
||||
</span></span></p>
|
||||
<p class="MsoListParagraphCxSpLast"><span style="font-family:������"><span style="">
|
||||
</span></span></p>
|
||||
<hr>
|
||||
<div><a href="http://go.microsoft.com/?linkid=9759640" style="margin-top:3px"><img alt="" src="description/f0ce43d4-e8ea-415f-bfdd-f6bb39d3f968image.png">
|
||||
</a></div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 48 KiB |
@@ -0,0 +1,417 @@
|
||||
/* ***************************************************
|
||||
Galleries.css - Common Structure
|
||||
|
||||
This is where we define common layout for structures that are truly close to common across the different
|
||||
Galleries sites. To make sure this works we need to follow certain conventions.
|
||||
|
||||
1. Define each logical structure in its own section with its own comment block that gives the section
|
||||
a Name, Description and defines the root element if one exists (i.e #someElement). Also, mark the closing block.
|
||||
|
||||
2. Indent styles in a section to represent if it is a child of a previous element.
|
||||
i.e. #someDiv{
|
||||
}
|
||||
#someDiv ul {
|
||||
}
|
||||
|
||||
3. Do not include brand specific information here like colors and fonts unless they are *really* common.
|
||||
|
||||
4. If there is an element that you know will be overridden in each brand stylesheet still include it here with an empty definition.
|
||||
This will aid in knowing what section to override and what selectors to use.
|
||||
|
||||
i.e. #someSction a {
|
||||
}
|
||||
|
||||
5. When you add a new section also update the Table of Contents below so that we have a quick overview of the sections
|
||||
|
||||
*****************************************************/
|
||||
|
||||
/****************************************************
|
||||
Table of Contents
|
||||
|
||||
Global - global classes
|
||||
|
||||
FileAttachmentDisplay - The list of attached files under the editor
|
||||
Eyebrow - The breadcrumb control at the top of the master page
|
||||
Pager - The common paging control, used for browsing pages of search results
|
||||
Profile User Card - Elements in the profile usercard control
|
||||
SideNav - The navigation side bar that contains the search filters
|
||||
|
||||
|
||||
*****************************************************/
|
||||
|
||||
/********************************
|
||||
Name: Global
|
||||
Root: none
|
||||
Description: truly global classes
|
||||
********************************/
|
||||
body {
|
||||
text-align: left;
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
img.rss {
|
||||
background: url(../../../GlobalResources/Images/Rss.png) no-repeat;
|
||||
background-position: 0px 0px;
|
||||
height: 17px;
|
||||
width: 17px;
|
||||
}
|
||||
/* End Global Section */
|
||||
|
||||
/********************************
|
||||
Name: FileAttachmentDisplay
|
||||
Root: #fileAttachmentDisplay
|
||||
Description: The list of attached files under the editor
|
||||
********************************/
|
||||
#fileAttachmentDisplay {
|
||||
}
|
||||
#fileAttachmentDisplay .attachment {
|
||||
margin-right: 10px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#fileAttachmentDisplay .attachment .displayAttachment {
|
||||
padding: 0px 0 13px 0;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#fileAttachmentDisplay .attachment .removeAttachment {
|
||||
background-image: url('/Content/Common/delete.png');
|
||||
display: block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
float: left;
|
||||
}
|
||||
/* End FileAttachmentDisplay Section */
|
||||
|
||||
|
||||
/********************************
|
||||
Name: Eyebrow
|
||||
Root: .EyebrowContainer
|
||||
Description: The breadcrumb control at the top of the master page
|
||||
********************************/
|
||||
.EyebrowContainer {
|
||||
}
|
||||
.EyebrowContainer div.EyebrowElement{
|
||||
display:inline;
|
||||
}
|
||||
|
||||
.EyebrowContainer .EyebrowElement{
|
||||
font-weight:normal
|
||||
}
|
||||
.EyebrowContainer .EyebrowLeafLink{
|
||||
color:#000;
|
||||
}
|
||||
/* End Eyebrow Section */
|
||||
|
||||
/********************************
|
||||
Name: Pager
|
||||
Root: #Pager
|
||||
Description: The common paging control, used for browsing pages of search results
|
||||
********************************/
|
||||
#Pager {
|
||||
}
|
||||
#Pager div{
|
||||
display:inline;
|
||||
}
|
||||
/* End Pager Section */
|
||||
|
||||
/********************************
|
||||
|
||||
Name: Profile User Card
|
||||
Root: #dashboardPage #userCard
|
||||
Description: Elements in the profile usercard control
|
||||
|
||||
********************************/
|
||||
#dashboardPage #userCard .profile-usercard-inline {
|
||||
margin: 5px 0 10px 0;
|
||||
}
|
||||
|
||||
/* #dashboardPage #userCard .profile-usercard {
|
||||
width: 288px;
|
||||
}
|
||||
/* End Profile User Card Section */
|
||||
|
||||
/********************************
|
||||
|
||||
Name: Discussion
|
||||
Root: #DiscussionsTabPane
|
||||
Description: Defines the layout of the dicussion
|
||||
|
||||
|
||||
********************************/
|
||||
#DiscussionsTabPane {
|
||||
}
|
||||
|
||||
#DiscussionsTabPane .itemHidden
|
||||
{
|
||||
background: lightgrey;
|
||||
}
|
||||
|
||||
#discussionListItem {
|
||||
}
|
||||
|
||||
.discussion .postActions
|
||||
{
|
||||
float: right;
|
||||
}
|
||||
|
||||
#discussionListItem .postItem
|
||||
{
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
font-size:1em;
|
||||
}
|
||||
|
||||
/* End Discussion Section */
|
||||
|
||||
|
||||
/********************************
|
||||
|
||||
Name: SearchDefaultLocale
|
||||
Root: .searchDefaultLocale
|
||||
Description: Defines the layout of the include english result checkbox on the Browse Page
|
||||
|
||||
|
||||
********************************/
|
||||
.searchDefaultLocale
|
||||
{
|
||||
float: right;
|
||||
margin: 20px 0 0 5px;
|
||||
}
|
||||
.searchDefaultLocale input
|
||||
{
|
||||
vertical-align:top;
|
||||
}
|
||||
.searchDefaultLocale span
|
||||
{
|
||||
margin-left: -3px;
|
||||
}
|
||||
/*-------- End SearchDefaultLocale --------*/
|
||||
|
||||
|
||||
/********************************
|
||||
|
||||
Name: SideNav
|
||||
Root: #sideNav
|
||||
Description: Defines the layout of the naviation elements on the side of the Browse Page
|
||||
These represent the different filters like Code Language, Category and Tag
|
||||
|
||||
|
||||
********************************/
|
||||
|
||||
#sideNav {
|
||||
width: 250px;
|
||||
vertical-align:top;
|
||||
}
|
||||
#sideNav h3 {
|
||||
}
|
||||
|
||||
#sideNav .section {
|
||||
padding: 0 0 10px 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#sideNav .section a {
|
||||
}
|
||||
|
||||
#sideNav .section a:hover {
|
||||
}
|
||||
|
||||
#sideNav .section > div {
|
||||
padding:5px 5px 5px 0;
|
||||
line-height:150%;
|
||||
}
|
||||
|
||||
#sideNav .section ul {
|
||||
list-style-type:none;
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
}
|
||||
|
||||
#sideNav .section ul li {
|
||||
position: relative;
|
||||
padding: 5px 5px 5px 0;
|
||||
}
|
||||
|
||||
#sideNav .section ul li .selectedFilter {
|
||||
float: left;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
#sideNav .section div.itemCount {
|
||||
float: right;
|
||||
}
|
||||
|
||||
#sideNav .section form input[ type = "checkbox"] {
|
||||
margin: 0px 4px 0px 0px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
/* End SideNav Section */
|
||||
|
||||
/*----------- Contribution Logos *******/
|
||||
.contributionLogo {
|
||||
float: left;
|
||||
position: relative;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.logo_visualstudio {
|
||||
background: transparent url('../common/logos/visualstudio.png') no-repeat;
|
||||
width: 23px;
|
||||
height: 12px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
.logo_allinonecode {
|
||||
background: transparent url('../common/logos/1code.png') no-repeat;
|
||||
width: 14px;
|
||||
height: 16px;
|
||||
}
|
||||
.logo_exchange {
|
||||
background: transparent url('../common/logos/exchange.png') no-repeat;
|
||||
width: 14px;
|
||||
height: 16px;
|
||||
}
|
||||
.logo_ie {
|
||||
background: transparent url('../common/logos/ie.png') no-repeat;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
.logo_office {
|
||||
background: transparent url('../common/logos/office.png') no-repeat;
|
||||
width: 17px;
|
||||
height: 16px;
|
||||
}
|
||||
.logo_windows {
|
||||
background: transparent url('../common/logos/windows.png') no-repeat;
|
||||
width: 17px;
|
||||
height: 16px;
|
||||
}
|
||||
.logo_azure {
|
||||
background: transparent url('../common/logos/windowsazuredark.png') no-repeat;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.logo_windowsphone {
|
||||
background: transparent url('../common/logos/windowsphone.png') no-repeat;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.contributionLogoTip {
|
||||
position: absolute;
|
||||
display: none;
|
||||
border: solid 1px #CCC;
|
||||
color: #333;
|
||||
background-color: #F0F0F0;
|
||||
font-size: 11px;
|
||||
font-family: "Segoe UI",Sans-Serif;
|
||||
box-shadow: 3px 3px 5px #888;
|
||||
-moz-box-shadow: 3px 3px 5px #888;
|
||||
z-index: 1003;
|
||||
padding: 5px;
|
||||
min-width: 250px;
|
||||
}
|
||||
|
||||
/*----------- End Contribution Logos *******/
|
||||
|
||||
.clear
|
||||
{
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.customcontributionLogoTip {
|
||||
position: absolute;
|
||||
display: none;
|
||||
border: solid 1px #CCC;
|
||||
background-color: white;
|
||||
color: #333;
|
||||
font-size: 11px;
|
||||
font-family: "Segoe UI",Sans-Serif;
|
||||
box-shadow: 3px 3px 5px #888;
|
||||
-moz-box-shadow: 3px 3px 5px #888;
|
||||
z-index: 1004;
|
||||
padding: 5px;
|
||||
min-width: 250px;
|
||||
}
|
||||
|
||||
.customcontributionTittle {
|
||||
font-size: 14px;
|
||||
margin-left: 90px;
|
||||
}
|
||||
|
||||
.customcontributionDiscription {
|
||||
font-size: 13px;
|
||||
margin: 10px 5px;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
.customcontribution {
|
||||
float: left;
|
||||
position: relative;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.customcontributionLink {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.customcontributionlogo {
|
||||
float: left;
|
||||
padding: 0 10px;
|
||||
margin: 0;
|
||||
width: 70px;
|
||||
height: 70px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
|
||||
.logo_azure_large {
|
||||
background-image: url('../common/logos/windowsazure_large.png');
|
||||
}
|
||||
.logo_visualstudio_large {
|
||||
background-image: url('../common/logos/visualstudio_large.png');
|
||||
}
|
||||
.logo_exchange_large {
|
||||
background-image: url('../common/logos/exchange_large.png');
|
||||
}
|
||||
.logo_ie_large {
|
||||
background-image: url('../common/logos/ie_large.png');
|
||||
}
|
||||
.logo_office_large {
|
||||
background-image: url('../common/logos/office_large.png');
|
||||
}
|
||||
.logo_windows_large {
|
||||
background-image: url('../common/logos/windows_large.png');
|
||||
}
|
||||
.logo_windowsphone_large {
|
||||
background-image: url('../common/logos/windowsphone_large.png');
|
||||
}
|
||||
|
||||
/* Custome Header */
|
||||
.dirSubHeading .windowssdk .container
|
||||
{
|
||||
background: #00BCF2 url('wpappsbackground.png') no-repeat;
|
||||
color: #575757;
|
||||
padding: 20px 10px 50px 225px;
|
||||
}
|
||||
|
||||
.dirSubHeading .windowssdk .container h1, .dirSubHeading .windowssdk .container h2 {
|
||||
color: #575757 !important;
|
||||
}
|
||||
|
||||
.dirSubHeading .windowssdk .container p {
|
||||
margin: 28px 0 0 0 !important;
|
||||
}
|
||||
|
||||
.dirSubHeading .windowssdk .container a {
|
||||
background-color: #575757;
|
||||
color: #FFFFFF !important;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
font-family: 'Segoe UI Semibold','Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;
|
||||
padding: 11px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
#container {
|
||||
min-height: 768px;
|
||||
}
|
||||
|
||||
#leftSubHeaderContainer
|
||||
{
|
||||
margin-top:20px;
|
||||
}
|
||||
|
||||
#title h1
|
||||
{
|
||||
font-size:25px;
|
||||
}
|
||||
|
||||
#subtitle h2
|
||||
{
|
||||
font-size:15px;
|
||||
}
|
||||
|
||||
#subtitle
|
||||
{
|
||||
margin-left:10px;
|
||||
}
|
||||
|
||||
|
||||
#formContainer
|
||||
{
|
||||
margin-left:10px;
|
||||
margin-top:30px;
|
||||
}
|
||||
|
||||
.formLabel
|
||||
{
|
||||
float:left;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.formRow
|
||||
{
|
||||
clear:both;
|
||||
padding: 10px 0 10px 10px;
|
||||
}
|
||||
|
||||
|
||||
.formRecaptchaRow
|
||||
{
|
||||
clear:both;
|
||||
float:left;
|
||||
margin-top:20px;
|
||||
margin-left:10px;
|
||||
margin-bottom:20px;
|
||||
}
|
||||
|
||||
.formSubmitRow
|
||||
{
|
||||
clear:both;
|
||||
margin-top:20px;
|
||||
margin-left:300px;
|
||||
margin-bottom:20px;
|
||||
}
|
||||
|
||||
.formControl {
|
||||
width:300px;
|
||||
float:left;
|
||||
}
|
||||
.formControl .textInput
|
||||
{
|
||||
width:300px;
|
||||
}
|
||||
|
||||
.formControl textarea
|
||||
{
|
||||
width:425px;
|
||||
height:100px;
|
||||
}
|
||||
|
||||
.formControl .tag
|
||||
{
|
||||
width:425px;
|
||||
}
|
||||
|
||||
.formControl .richText
|
||||
{
|
||||
margin-top:10px;
|
||||
width:500px;
|
||||
height:440px;
|
||||
}
|
||||
|
||||
.formWideLabel
|
||||
{
|
||||
width:500px;
|
||||
}
|
||||
|
||||
.formBigLabel
|
||||
{
|
||||
margin-top:20px;
|
||||
font-size:20px;
|
||||
}
|
||||
|
||||
.formControlBelow
|
||||
{
|
||||
clear:both;
|
||||
margin-top:10px;
|
||||
width:500px;
|
||||
}
|
||||
|
||||
.required
|
||||
{
|
||||
color: Red;
|
||||
}
|
||||
.helpText
|
||||
{
|
||||
color: #9D9D9D;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#agreementSummary
|
||||
{
|
||||
clear:both;
|
||||
margin-top:10px;
|
||||
width:800px;
|
||||
}
|
||||
|
||||
.field-validation-error, .validation-summary-errors
|
||||
{
|
||||
color: #FF0000;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tinyMCETemplate {
|
||||
position: relative;
|
||||
left: 400px;
|
||||
width: 300px;
|
||||
max-height: 300px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.IE6 .tinyMCETemplate {
|
||||
left: 25px;
|
||||
}
|
||||
|
||||
.ownerBar {
|
||||
padding: 5px;
|
||||
}
|
||||
.ownerBar .ownerBarOptions {
|
||||
float: right;
|
||||
}
|
||||
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 32 KiB |
@@ -0,0 +1,179 @@
|
||||
body {
|
||||
color: #000000;
|
||||
font-family: 'Segoe UI',Verdana,Arial;
|
||||
font-size: 0.813em;
|
||||
font-style: normal;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
/*BEGIN HEADERS*/
|
||||
.h1, h1 {
|
||||
color: #3A3E43;
|
||||
font-family: 'Segoe UI',Verdana,Arial;
|
||||
font-size: 1.4em;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.h2, h2 {
|
||||
color: #3A3E43;
|
||||
font-family: 'Segoe UI',Verdana,Arial;
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
}
|
||||
.h3, h3 {
|
||||
color: #3A3E43;
|
||||
font-family: 'Segoe UI',Verdana,Arial;
|
||||
font-size: 1.077em;
|
||||
font-weight: bold;
|
||||
}
|
||||
.h4, h4 {
|
||||
color: #3A3E43;
|
||||
font-family: 'Segoe UI',Verdana,Arial;
|
||||
font-size: 1em;
|
||||
font-weight: bold;
|
||||
}
|
||||
h4.subHeading {
|
||||
margin-bottom: 7px;
|
||||
margin-top: 13px;
|
||||
}
|
||||
/*END HEADERS*/
|
||||
|
||||
/*BEGIN LINKS*/
|
||||
a:link {
|
||||
color: #00749E;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:visited {
|
||||
color: #960BB4;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:focus {
|
||||
outline: 1px dotted #000000;
|
||||
}
|
||||
|
||||
a.libraryLink:link {
|
||||
text-decoration:none;
|
||||
border-bottom:1px dotted;
|
||||
}
|
||||
|
||||
/*END LINKS*/
|
||||
|
||||
/*BEGIN IMAGES*/
|
||||
img {
|
||||
border: 0 none;
|
||||
}
|
||||
/*END IMAGES*/
|
||||
|
||||
/*BEGIN TABLE*/
|
||||
.title table {
|
||||
color: #000000;
|
||||
font-family: 'Segoe UI',Verdana,Arial;
|
||||
font-size: 1.077em;
|
||||
font-style: normal;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table, table th, table td {
|
||||
border:1px solid #BBBBBB;
|
||||
}
|
||||
/*END TABLE*/
|
||||
|
||||
/*BEGIN LIST*/
|
||||
ul {
|
||||
list-style-type: disc;
|
||||
margin-left:40px;
|
||||
padding-left: 0;
|
||||
}
|
||||
ul li {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
ol {
|
||||
margin-left:40px;
|
||||
padding-left: 0;
|
||||
}
|
||||
ol li {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
/*END LIST*/
|
||||
|
||||
.scriptcode {
|
||||
position: relative;
|
||||
padding: 8px 8px 8px 8px;
|
||||
background: #FFFFFF;
|
||||
font-size: 12px;
|
||||
line-height: 125%;
|
||||
font-weight:normal;
|
||||
}
|
||||
.scriptcode pre
|
||||
{
|
||||
white-space: pre-wrap !important; /* css-3 */
|
||||
word-wrap: break-word !important; /* Internet Explorer 5.5+ */
|
||||
margin:0 0 10px 0 !important;
|
||||
padding: 10px;
|
||||
border-top: solid 2px #D0D2D2;
|
||||
border-bottom: solid 2px #D0D2D2;
|
||||
border-left: solid 1px #D0D2D2;
|
||||
border-right: solid 1px #D0D2D2;
|
||||
}
|
||||
|
||||
.scriptcode .title {
|
||||
color:#E66A38;
|
||||
font-size: 12px;
|
||||
font-weight:bold;
|
||||
margin: 0;
|
||||
min-height: 23px;
|
||||
}
|
||||
.scriptcode .title > span:first-child {
|
||||
border-left: solid 1px #D0D2D2;
|
||||
}
|
||||
.scriptcode .title > span {
|
||||
padding: 4px 8px 4px 8px;
|
||||
display: inline-block;
|
||||
border-top: 1px solid #D0D2D2;
|
||||
border-right: 1px solid #D0D2D2;
|
||||
border-collapse: collapse;
|
||||
text-align: center;
|
||||
background: white;
|
||||
}
|
||||
.scriptcode .title > span.otherTab {
|
||||
color: #1364C4;
|
||||
background: #EFF5FF;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.scriptcode .hidden {
|
||||
display: none !important;
|
||||
visibility: hidden !important;
|
||||
}
|
||||
|
||||
.scriptcode .copyCode {
|
||||
padding: 8px 2px 0 2px !important;
|
||||
margin-right: 15px;
|
||||
position: absolute !important;
|
||||
right: 0 !important;
|
||||
top: 17px;
|
||||
display:block !important;
|
||||
background: #FFFFFF;
|
||||
}
|
||||
.scriptcode .pluginLinkHolder {
|
||||
display: none;
|
||||
}
|
||||
.scriptcode .pluginEditHolderLink {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.Opera wbr
|
||||
{
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.IE9 wbr:after
|
||||
{
|
||||
content: "\00200B";
|
||||
}
|
||||
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,52 @@
|
||||
var Galleries = Galleries || { };
|
||||
|
||||
(function() {
|
||||
|
||||
function findElem(parent, tagName, className) {
|
||||
var elemToSearch = (parent) ? parent : document.body;
|
||||
var tagMatch = elemToSearch.getElementsByTagName(tagName);
|
||||
var evaluator = function(elem) {
|
||||
return (className) ? (elem.className.indexOf(className) > -1) : true;
|
||||
};
|
||||
|
||||
return findArrayElem(tagMatch, evaluator);
|
||||
}
|
||||
|
||||
function findArrayElem(array, evaluator) {
|
||||
var newArray = new Array();
|
||||
for (var count = 0; count < array.length; count++) {
|
||||
if (evaluator(array[count])) {
|
||||
newArray.push(array[count]);
|
||||
}
|
||||
}
|
||||
return newArray;
|
||||
}
|
||||
|
||||
function iterateElem(elems, delegate) {
|
||||
for(var count = 0; count < elems.length; count++) {
|
||||
delegate(count, elems[count]);
|
||||
}
|
||||
}
|
||||
|
||||
function isHidden(elem) {
|
||||
return (elem.offsetHeight === 0 && elem.offsetWidth === 0) || elem.style && elem.style.display === "none";
|
||||
}
|
||||
|
||||
function onWindowLoad(callback) {
|
||||
attachEventHandler(null, 'load', callback);
|
||||
}
|
||||
|
||||
function attachEventHandler(elem, event, callback) {
|
||||
var elemToAttach = (elem) ? elem : window;
|
||||
if (document.addEventListener) {
|
||||
elemToAttach.addEventListener(event, callback, false);
|
||||
} else if ( document.attachEvent ) {
|
||||
elemToAttach.attachEvent('on' + event, callback);
|
||||
}
|
||||
}
|
||||
|
||||
Galleries.findElem = findElem;
|
||||
Galleries.iterateElem = iterateElem;
|
||||
Galleries.attachEventHandler = attachEventHandler;
|
||||
Galleries.onWindowLoad = onWindowLoad;
|
||||
})();
|
||||
@@ -0,0 +1,25 @@
|
||||
{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 MS Shell Dlg;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs16\f2\cf0 \cf0\ql{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\fs40\f2 {\ltrch MICROSOFT LIMITED PUBLIC LICENSE version 1.1}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 \line {\ltrch ----------------------}\line \li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch This license governs use of code marked as \ldblquote sample\rdblquote or \ldblquote example\rdblquote available on this web site without a license agreement, as provided under the section above titled \ldblquote NOTICE SPECIFIC TO SOFTWARE AVAILABLE ON THIS WEB SITE.\rdblquote If you use such code (the \ldblquote software\rdblquote ), you accept this license. If you do not accept the license, do not use the software.}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch 1. Definitions}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch The terms \ldblquote reproduce,\rdblquote \ldblquote reproduction,\rdblquote \ldblquote derivative works,\rdblquote and \ldblquote distribution\rdblquote have the same meaning here as under U.S. copyright law. }\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch A \ldblquote contribution\rdblquote is the original software, or any additions or changes to the software.}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch A \ldblquote contributor\rdblquote is any person that distributes its contribution under this license.}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch \ldblquote Licensed patents\rdblquote are a contributor\rquote s patent claims that read directly on its contribution.}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch 2. Grant of Rights}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch (A) Copyright Grant - Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch (B) Patent Grant - Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch 3. Conditions and Limitations}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch (A) No Trademark License- This license does not grant you rights to use any contributors\rquote name, logo, or trademarks.}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch (E) The software is licensed \ldblquote as-is.\rdblquote You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 {\ltrch (F) Platform Limitation - The licenses granted in sections 2(A) and 2(B) extend only to the software or derivative works that you create that run directly on a Microsoft Windows operating system product, Microsoft run-time technology (such as the .NET Framework or Silverlight), or Microsoft application platform (such as Microsoft Office or Microsoft Dynamics).}\li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par}
|
||||
}
|
||||
}
|
||||