From dcff87d4777f6a434b4b67662d0403857bc7e730 Mon Sep 17 00:00:00 2001 From: Nadya Todorova Date: Tue, 21 May 2024 16:26:14 +0300 Subject: [PATCH] Load On Demand Combobox for RadGridView --- .../GridWithListViewColumn/Description.md | 2 + .../LoadOnDemandComboBoxInGrid/Description.md | 22 ++ .../LoadOnDemand.sln | 55 ++++ .../LoadOnDemandCS/Form1.Designer.cs | 83 +++++ .../LoadOnDemandCS/Form1.cs | 148 +++++++++ .../LoadOnDemandCS/Form1.resx | 120 +++++++ .../LoadOnDemandCS/LoadOnDemandCS.csproj | 236 ++++++++++++++ .../LoadOnDemandCS/LoadOnDemandCellEditor.cs | 294 ++++++++++++++++++ .../Properties/Application.Designer.cs | 73 +++++ .../Properties/Application.myapp | 11 + .../LoadOnDemandCS/Properties/AssemblyInfo.cs | 51 +++ .../System.Data.DataSet.datasource | 10 + .../Properties/Resources.Designer.cs | 63 ++++ .../LoadOnDemandCS/Properties/Resources.resx | 117 +++++++ .../Properties/Settings.Designer.cs | 56 ++++ .../Properties/Settings.settings | 25 ++ .../LoadOnDemandCS/SampleApp.xml | 54 ++++ .../Web References/localhost/Reference.cs | 151 +++++++++ .../Web References/localhost/Reference.map | 7 + .../Web References/localhost/Service.disco | 6 + .../Web References/localhost/Service.wsdl | 72 +++++ .../LoadOnDemandCS/app.config | 43 +++ .../LoadOnDemandVB/Form1.Designer.vb | 54 ++++ .../LoadOnDemandVB/Form1.resx | 120 +++++++ .../LoadOnDemandVB/Form1.vb | 127 ++++++++ .../LoadOnDemandVB/LoadOnDemandCellEditor.vb | 272 ++++++++++++++++ .../LoadOnDemandVB/LoadOnDemandVB.vbproj | 242 ++++++++++++++ .../My Project/Application.Designer.vb | 44 +++ .../My Project/Application.myapp | 11 + .../LoadOnDemandVB/My Project/AssemblyInfo.vb | 35 +++ .../System.Data.DataSet.datasource | 10 + .../My Project/Resources.Designer.vb | 63 ++++ .../LoadOnDemandVB/My Project/Resources.resx | 117 +++++++ .../My Project/Settings.Designer.vb | 103 ++++++ .../My Project/Settings.settings | 25 ++ .../Web References/localhost/Reference.map | 7 + .../Web References/localhost/Reference.vb | 150 +++++++++ .../Web References/localhost/Service.disco | 6 + .../Web References/localhost/Service.wsdl | 72 +++++ .../LoadOnDemandVB/app.config | 43 +++ .../WebService1/App_Code/DataSet1.xsd | 33 ++ .../WebService1/App_Code/DataSet1.xss | 12 + .../WebService1/App_Code/Service.vb | 187 +++++++++++ .../WebService1/Service.asmx | 1 + .../WebService1/web.config | 148 +++++++++ 45 files changed, 3581 insertions(+) create mode 100644 GridView/LoadOnDemandComboBoxInGrid/Description.md create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemand.sln create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Form1.Designer.cs create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Form1.cs create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Form1.resx create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/LoadOnDemandCS.csproj create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/LoadOnDemandCellEditor.cs create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Application.Designer.cs create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Application.myapp create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/AssemblyInfo.cs create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/DataSources/System.Data.DataSet.datasource create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Resources.Designer.cs create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Resources.resx create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Settings.Designer.cs create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Settings.settings create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/SampleApp.xml create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Reference.cs create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Reference.map create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Service.disco create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Service.wsdl create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/app.config create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Form1.Designer.vb create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Form1.resx create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Form1.vb create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/LoadOnDemandCellEditor.vb create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/LoadOnDemandVB.vbproj create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Application.Designer.vb create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Application.myapp create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/AssemblyInfo.vb create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/DataSources/System.Data.DataSet.datasource create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Resources.Designer.vb create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Resources.resx create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Settings.Designer.vb create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Settings.settings create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Reference.map create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Reference.vb create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Service.disco create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Service.wsdl create mode 100644 GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/app.config create mode 100644 GridView/LoadOnDemandComboBoxInGrid/WebService1/App_Code/DataSet1.xsd create mode 100644 GridView/LoadOnDemandComboBoxInGrid/WebService1/App_Code/DataSet1.xss create mode 100644 GridView/LoadOnDemandComboBoxInGrid/WebService1/App_Code/Service.vb create mode 100644 GridView/LoadOnDemandComboBoxInGrid/WebService1/Service.asmx create mode 100644 GridView/LoadOnDemandComboBoxInGrid/WebService1/web.config diff --git a/GridView/GridWithListViewColumn/Description.md b/GridView/GridWithListViewColumn/Description.md index 9e06cfa..64c702b 100644 --- a/GridView/GridWithListViewColumn/Description.md +++ b/GridView/GridWithListViewColumn/Description.md @@ -13,4 +13,6 @@ ## Description +#### ListViewColumn for RadGridView + This project demonstrates how to create a ListViewColumn for a cell on a RadGridView. The list view column is useful to display formatted information including an image and text in multiple rows in a single grid cell. It also demonstrates how to add a complex control to a grid view cell for special processing. A list of data objects is assigned to list to fill out each list item. It can be updated any time. diff --git a/GridView/LoadOnDemandComboBoxInGrid/Description.md b/GridView/LoadOnDemandComboBoxInGrid/Description.md new file mode 100644 index 0000000..0875b40 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/Description.md @@ -0,0 +1,22 @@ +## Environment + + + + + + + + + +
Product VersionQ2 2011
ProductRadGridView for WinForms
+ + +## Description + +#### Load On Demand Combobox for RadGridView + +This project demonstrates "load on demand" functionality for a combobox in the grid. Although this is available with the controls for ASP.NET, this is not currently supported for the WinForms combobox. + +The application consists of a single RadGridView control with one GridViewMultiComboBoxColumn named "Country". The load on demand functionality is encapsulated in the LoadOnDemandCellEditor class, which inherits from RadMultiColumnComboBoxElement. Once the cell is put into edit mode, the default cell editor is changed to the custom cell editor. This makes use of System.Timer object, which is used to buffer the requests to the web service (included with the project). Once the timer's interval has passed, it executes an asynchronous web service call to load the matching items. + +When the application runs, a window form is loaded with a RadGridView. The grid contains a list of countries. Double click on a row to put it into edit mode and clear out the text. As you type, the combobox makes asynchronous web service calls to retrieve matching items. So for example if you type in "Mo" it will return all countries that match this (ex. "Morocco", "Monaco"). As you continue typing it will further refine the matching items. diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemand.sln b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemand.sln new file mode 100644 index 0000000..5edea77 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemand.sln @@ -0,0 +1,55 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34728.123 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WebService1", "WebService1\", "{09E6812F-1685-4B6B-A01C-E14933263D8A}" + ProjectSection(WebsiteProperties) = preProject + TargetFrameworkMoniker = ".NETFramework,Version%3Dv3.5" + Debug.AspNetCompiler.VirtualPath = "/WebService1" + Debug.AspNetCompiler.PhysicalPath = "WebService1\" + Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\WebService1\" + Debug.AspNetCompiler.Updateable = "true" + Debug.AspNetCompiler.ForceOverwrite = "true" + Debug.AspNetCompiler.FixedNames = "false" + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.VirtualPath = "/WebService1" + Release.AspNetCompiler.PhysicalPath = "WebService1\" + Release.AspNetCompiler.TargetPath = "PrecompiledWeb\WebService1\" + Release.AspNetCompiler.Updateable = "true" + Release.AspNetCompiler.ForceOverwrite = "true" + Release.AspNetCompiler.FixedNames = "false" + Release.AspNetCompiler.Debug = "False" + VWDPort = "4384" + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadOnDemandCS", "LoadOnDemandCS\LoadOnDemandCS.csproj", "{26129175-42DE-46AE-A44E-B406AA9D24EA}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LoadOnDemandVB", "LoadOnDemandVB\LoadOnDemandVB.vbproj", "{C86FFBA3-2E62-4025-80EB-7F0AC9581EF1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {09E6812F-1685-4B6B-A01C-E14933263D8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {09E6812F-1685-4B6B-A01C-E14933263D8A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {09E6812F-1685-4B6B-A01C-E14933263D8A}.Release|Any CPU.ActiveCfg = Debug|Any CPU + {09E6812F-1685-4B6B-A01C-E14933263D8A}.Release|Any CPU.Build.0 = Debug|Any CPU + {26129175-42DE-46AE-A44E-B406AA9D24EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {26129175-42DE-46AE-A44E-B406AA9D24EA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {26129175-42DE-46AE-A44E-B406AA9D24EA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {26129175-42DE-46AE-A44E-B406AA9D24EA}.Release|Any CPU.Build.0 = Release|Any CPU + {C86FFBA3-2E62-4025-80EB-7F0AC9581EF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C86FFBA3-2E62-4025-80EB-7F0AC9581EF1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C86FFBA3-2E62-4025-80EB-7F0AC9581EF1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C86FFBA3-2E62-4025-80EB-7F0AC9581EF1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AB75E12B-B3EB-48E7-A80A-45B04CF19481} + EndGlobalSection +EndGlobal diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Form1.Designer.cs b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Form1.Designer.cs new file mode 100644 index 0000000..ff41d46 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Form1.Designer.cs @@ -0,0 +1,83 @@ +//INSTANT C# NOTE: Formerly VB project-level imports: +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Linq; +using System.Xml.Linq; + +using Telerik.WinControls.UI; +using Telerik.WinControls; + +namespace SampleApp +{ + [Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] + public partial class Form1 : System.Windows.Forms.Form + { + + //Form overrides dispose to clean up the component list. + [System.Diagnostics.DebuggerNonUserCode()] + protected override void Dispose(bool disposing) + { + try + { + if (disposing && components != null) + { + components.Dispose(); + } + } + finally + { + base.Dispose(disposing); + } + } + + //Required by the Windows Form Designer + private System.ComponentModel.IContainer components; + + //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 void InitializeComponent() + { + this.rgData = new Telerik.WinControls.UI.RadGridView(); + ((System.ComponentModel.ISupportInitialize)this.rgData).BeginInit(); + ((System.ComponentModel.ISupportInitialize)this.rgData.MasterTemplate).BeginInit(); + this.SuspendLayout(); + // + //rgData + // + this.rgData.Dock = System.Windows.Forms.DockStyle.Fill; + this.rgData.Location = new System.Drawing.Point(0, 0); + this.rgData.Name = "rgData"; + this.rgData.Size = new System.Drawing.Size(852, 481); + this.rgData.TabIndex = 0; + // + //Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6.0F, 13.0F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(852, 481); + this.Controls.Add(this.rgData); + this.Name = "Form1"; + this.Text = "Form1"; + ((System.ComponentModel.ISupportInitialize)this.rgData.MasterTemplate).EndInit(); + ((System.ComponentModel.ISupportInitialize)this.rgData).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + +//INSTANT C# NOTE: Converted event handler wireups: + rgData.CellEndEdit += new Telerik.WinControls.UI.GridViewCellEventHandler(rgData_CellEndEdit); + rgData.EditorRequired += new Telerik.WinControls.UI.EditorRequiredEventHandler(rgData_EditorRequired); + base.Load += new System.EventHandler(Form1_Load); + + } + internal Telerik.WinControls.UI.RadGridView rgData; + + } + +} \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Form1.cs b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Form1.cs new file mode 100644 index 0000000..12a9a08 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Form1.cs @@ -0,0 +1,148 @@ +//INSTANT C# NOTE: Formerly VB project-level imports: +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; +using System.Xml.Linq; +using Telerik.WinControls; +using Telerik.WinControls.UI; + +namespace SampleApp +{ + public partial class Form1 + { + internal Form1() + { + InitializeComponent(); + } + + private LoadOnDemandCellEditor _loadOnDemandCellEditor; + + private void Form1_Load(object sender, System.EventArgs e) + { + InitializeLinesGrid(); + + LoadGrid(); + } + + //Load the grid columns, set grid properties, etc. + private void InitializeLinesGrid() + { + GridViewMultiComboBoxColumn gridMultiColumnComboColumn = null; + + rgData.MasterTemplate.Columns.Clear(); + rgData.MasterTemplate.AutoGenerateColumns = false; + + gridMultiColumnComboColumn = CreateGridMultiComboBoxColumn("COUNTRY", "COUNTRY", "Country", null, "COUNTRY", "COUNTRY", 400); + rgData.MasterTemplate.Columns.Add(gridMultiColumnComboColumn); + + //Set MasterGridViewTemplate properties + rgData.MasterTemplate.AllowEditRow = true; + rgData.MasterTemplate.AllowAddNewRow = false; + rgData.MasterTemplate.EnableGrouping = false; + rgData.MasterTemplate.AllowColumnChooser = false; + rgData.MasterTemplate.AllowColumnHeaderContextMenu = false; + + rgData.MultiSelect = true; + rgData.SelectionMode = GridViewSelectionMode.FullRowSelect; + rgData.ShowGroupPanel = false; + } + + //Create GridViewMultiComboBoxColumn with values passed in + private GridViewMultiComboBoxColumn CreateGridMultiComboBoxColumn(string Name, string fieldName, string headerText, BindingSource dataSource, string valueMember, string displayMember, int width) + { + GridViewMultiComboBoxColumn multiComboBoxColumn = new GridViewMultiComboBoxColumn(); + + multiComboBoxColumn.Name = Name; + multiComboBoxColumn.FieldName = fieldName; + multiComboBoxColumn.HeaderText = headerText; + multiComboBoxColumn.DataSource = dataSource; + multiComboBoxColumn.ValueMember = valueMember; + multiComboBoxColumn.DisplayMember = displayMember; + multiComboBoxColumn.Width = width; + + //Set default values + multiComboBoxColumn.HeaderTextAlignment = ContentAlignment.BottomLeft; + multiComboBoxColumn.DropDownStyle = RadDropDownStyle.DropDown; + + return multiComboBoxColumn; + } + + //Load the grid + private void LoadGrid() + { + GridViewRowInfo rowInfo = null; + + rowInfo = rgData.Rows.AddNew(); + rowInfo.Cells["COUNTRY"].Value = "United States of America"; + + rowInfo = rgData.Rows.AddNew(); + rowInfo.Cells["COUNTRY"].Value = "Malta"; + + rowInfo = rgData.Rows.AddNew(); + rowInfo.Cells["COUNTRY"].Value = "Canada"; + + rowInfo = rgData.Rows.AddNew(); + rowInfo.Cells["COUNTRY"].Value = "Spain"; + + rowInfo = rgData.Rows.AddNew(); + rowInfo.Cells["COUNTRY"].Value = "Italy"; + } + + //This event fires when a field is put into edit mode. + private void rgData_EditorRequired(object sender, Telerik.WinControls.UI.EditorRequiredEventArgs e) + { + int currentColumnIndex = 0; + int currentRowIndex = 0; + object country = null; + int columnWidth = 0; + + currentColumnIndex = rgData.Columns.IndexOf(rgData.CurrentColumn.Name); + + //INSTANT C# NOTE: The following VB 'Select Case' included either a non-ordinal switch expression or non-ordinal, + //range-type, or non-constant 'Case' expressions and was converted to C# 'if-else' logic: + // Select Case currentColumnIndex + + //ORIGINAL LINE: Case rgData.Columns("COUNTRY").Index + if (currentColumnIndex == rgData.Columns["COUNTRY"].Index) + { + currentRowIndex = rgData.Rows.IndexOf(rgData.CurrentRow); + country = rgData.Rows[currentRowIndex].Cells[currentColumnIndex].Value; + columnWidth = rgData.Columns[currentColumnIndex].Width; + + _loadOnDemandCellEditor = new LoadOnDemandCellEditor(country, columnWidth, rgData); + e.Editor = _loadOnDemandCellEditor; + } + } + + //Fires when a cell is taken out of edit mode + private void rgData_CellEndEdit(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) + { + if (e.ColumnIndex == rgData.Columns["COUNTRY"].Index) + { + //Set the editor text from editor element and update the cell value (sometimes the grid did not hold + //the updated value) + rgData.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = _loadOnDemandCellEditor.EditorElement.Text; + + _loadOnDemandCellEditor.Dispose(); + } + } + + private static Form1 _DefaultInstance; + + public static Form1 DefaultInstance + { + get + { + if (_DefaultInstance == null) + _DefaultInstance = new Form1(); + + return _DefaultInstance; + } + } + } +} \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Form1.resx b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Form1.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/LoadOnDemandCS.csproj b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/LoadOnDemandCS.csproj new file mode 100644 index 0000000..a70359d --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/LoadOnDemandCS.csproj @@ -0,0 +1,236 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {26129175-42DE-46AE-A44E-B406AA9D24EA} + WinExe + SampleApp.My.MyApplication + Properties + SampleApp + SampleApp + 512 + WindowsForms + v4.0 + On + true + + + + + 3.5 + http://localhost/SampleApp/ + true + Web + true + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true + + + + true + full + DEBUG;TRACE + bin\Debug\ + SampleApp.xml + 1 + MinimumRecommendedRules.ruleset + + + pdbonly + TRACE + true + bin\Release\ + SampleApp.xml + MinimumRecommendedRules.ruleset + + + + + ..\..\..\..\..\Windows\Microsoft.NET\Framework64\v2.0.50727\System.dll + + + + + + + + 3.0 + + + 3.0 + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + ..\..\..\..\..\Program Files (x86)\Progress\Telerik UI for WinForms 2024 Q1\Bin40\Telerik.WinControls.dll + + + ..\..\..\..\..\Program Files (x86)\Progress\Telerik UI for WinForms 2024 Q1\Bin40\Telerik.WinControls.GridView.dll + + + ..\..\..\..\..\Program Files (x86)\Progress\Telerik UI for WinForms 2024 Q1\Bin40\Telerik.WinControls.UI.dll + + + ..\..\..\..\..\Program Files (x86)\Progress\Telerik UI for WinForms 2024 Q1\Bin40\TelerikCommon.dll + + + + + + + + + + + + + + + + + + Form + + + Form1.cs + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + True + True + Reference.map + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + + + + MyApplicationCodeGenerator + Application.Designer.cs + + + SettingsSingleFileGenerator + My + Settings.Designer.cs + + + + + False + .NET Framework Client Profile + false + + + False + .NET Framework 2.0 %28x86%29 + false + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + False + .NET Framework 3.5 SP1 + true + + + False + SQL Server Compact 3.5 + true + + + False + Windows Installer 3.1 + true + + + + + + MSDiscoCodeGenerator + Reference.cs + + + + + + + + + + + + + Dynamic + Web References\localhost\ + http://localhost:4384/WebService1/Service.asmx + + + + + MySettings + SampleApp_localhost_Service + + + + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/LoadOnDemandCellEditor.cs b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/LoadOnDemandCellEditor.cs new file mode 100644 index 0000000..4fc4180 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/LoadOnDemandCellEditor.cs @@ -0,0 +1,294 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; +using System.Xml.Linq; +using Telerik.WinControls.UI; + +namespace SampleApp +{ + public class LoadOnDemandCellEditor : RadMultiColumnComboBoxElement + { + private const int MinDropDownWidth = 320; + private const int ShortNameWidth = 25; + private const int GridOffset = 70; + private const int TimerInterval = 425; + private const string ItemInfoTableName = "ITEMS"; + + private System.Timers.Timer _timer; + + private bool _showDropDown; + + private bool ShowDropDown + { + get + { + return _showDropDown; + } + set + { + //This property can be updated on a background thread, so we need to ensure thread-safety + lock (this) + { + _showDropDown = value; + } + } + } + + private bool _newItemsLoaded; + + private bool NewItemsLoaded + { + get + { + return _newItemsLoaded; + } + set + { + //This property can be updated on a background thread, so we need to ensure thread-safety + lock (this) + { + _newItemsLoaded = value; + } + } + } + + private string _currentText = null; + + private string CurrentText + { + get + { + return _currentText; + } + set + { + _currentText = value; + } + } + + public LoadOnDemandCellEditor(object text, int columnWidth, RadGridView ownerGrid) + : base() + { + InitializeCellEditor(text, columnWidth, ownerGrid); + } + + //Initialize the cell editor (set properties and load matching data) + private void InitializeCellEditor(object text, int columnWidth, RadGridView ownerGrid) + { + RadGridView grid = null; + + if (!(text is DBNull) && !(string.IsNullOrEmpty(text.ToString()))) + { + CurrentText = text.ToString(); + } + + this.DisplayMember = "COUNTRY"; + this.ValueMember = "COUNTRY"; + this.Virtualized = false; + + //Make sure the drop down is at least minDropDownWidth + if (columnWidth > MinDropDownWidth) + { + this.DropDownWidth = columnWidth; + } + else + { + this.DropDownWidth = MinDropDownWidth; + } + + grid = this.EditorControl; + + //Setup the grid that is displayed in the drop down list + InitializeGrid(ref grid, this.DropDownWidth); + + //Only load data if we have at least 3 characters + if (CurrentText != null && CurrentText.Length >= 3) + { + GetMatchingItems_AsyncBegin(CurrentText, false); + + //Text of the combo gets cleared when the items are loaded, so make sure to set it here + this.TextBoxElement.Text = CurrentText; + } + + //KeyUp and KeyDown events will allow us to load matching data on-demand + this.KeyDown += DropDown_KeyDown; + this.KeyUp += DropDown_KeyUp; + + InitializeTimer(ownerGrid); + } + + //Configure the grid that is displayed within the drop down list. + private void InitializeGrid(ref RadGridView grid, int gridWidth) + { + GridViewTextBoxColumn gridTextBoxColumn = null; + + //Set the grid to fill the drop down list + grid.Width = gridWidth; + + grid.AutoSizeRows = true; + grid.VirtualMode = false; + + grid.MasterTemplate.AutoGenerateColumns = false; + grid.MasterTemplate.ShowColumnHeaders = false; + grid.MasterTemplate.AllowColumnResize = false; + grid.MasterTemplate.AllowRowResize = false; + + grid.MasterTemplate.Columns.Clear(); + + gridTextBoxColumn = CreateGridTextBoxColumn("SHORTNAME", "SHORTNAME", "SHORTNAME"); + gridTextBoxColumn.Width = ShortNameWidth; + grid.MasterTemplate.Columns.Add(gridTextBoxColumn); + + gridTextBoxColumn = CreateGridTextBoxColumn("COUNTRY", "COUNTRY", "COUNTRY"); + + //Set the column to fill the remaining space in the drop down + gridTextBoxColumn.Width = gridWidth - ShortNameWidth - GridOffset; + gridTextBoxColumn.WrapText = true; + grid.MasterTemplate.Columns.Add(gridTextBoxColumn); + } + + //Initialize the Timer that is used to buffer the requests to the web service. So instead of firing + //off a request on every keystroke, we will build in a short wait to make sure the user is done typing. + private void InitializeTimer(RadGridView ownerGrid) + { + _timer = new System.Timers.Timer(); + _timer.Interval = TimerInterval; + + //The GridViewMultiComboBoxElement does not implement the InvokeRequired property or Invoke() method. + //These are needed to update a control that was created on another thread. So we will need to + //synchronize the timer with the another control so that we can update the UI in the timers Elasped + //event handler, since the timer runs on a background thread. We can't access the grid that hosts this + //control from the control itself, so we us a reference to the grid that is passed in the constructor. + _timer.SynchronizingObject = ownerGrid; + + _timer.Elapsed += Timer_Elapsed; + } + + //Make an asynchronous call into the web service to get items that match the text that is passed in + private void GetMatchingItems_AsyncBegin(string text, bool showDropDownFlag) + { + using (localhost.Service ws = new localhost.Service()) + { + ShowDropDown = showDropDownFlag; + ws.GetMatchingItemsCompleted += GetMatchingItems_AsyncCompleted; + ws.GetMatchingItemsAsync(text); + } + } + + //Asynchronous callback event handler for the GetMatchingItemsAsync call to the web service + private void GetMatchingItems_AsyncCompleted(object sender, localhost.GetMatchingItemsCompletedEventArgs e) + { + RadGridView grid = null; + DataSet returnDataSet = null; + DataTable itemInfo = null; + + if (e.Error != null || e.Result == null) + { + //WS call errored out, or nothing was returned + return; + } + + returnDataSet = (DataSet)e.Result; + itemInfo = returnDataSet.Tables[ItemInfoTableName]; + + grid = this.EditorControl; + grid.DataSource = itemInfo; + + if (ShowDropDown) + { + this.ShowPopup(); + } + + NewItemsLoaded = true; + } + + //Handles the KeyDown event for the drop down editor. + private void DropDown_KeyDown(object sender, KeyEventArgs e) + { + //Store the current text so that we can tell if it has changed in the KeyUp event. + CurrentText = this.Text; + + //If the down key was pressed, there are items loaded in the drop down and an item has not already + //been selected, then force the selection. This is to workaround an issue where pressing the down + //key would not force focus to the grid (allowing the user to scroll through the items). + if (e.KeyCode == Keys.Down) + { + if (this.EditorControl.Rows.Count > 0 && NewItemsLoaded == true) + { + this.SelectedIndex = 0; + this.ShowPopup(); + } + + //Reset NewItemsLoaded for next iteration + NewItemsLoaded = false; + } + } + + //Handles the KeyUp event for the drop down editor. We load any matching items. + private void DropDown_KeyUp(object sender, KeyEventArgs e) + { + //Force the timer to stop. We will only start the timer if the text is valid + _timer.Stop(); + + //Escape navigation keys (ex. up/down arrow) so we don't reload the drop down when the + //user scrolls through the items in the grid. + switch (e.KeyCode) + { + case Keys.Up: + case Keys.Down: + return; + } + + //Just exit if the text has not changed (user could have pressed F1, CTRL, SHIFT, etc.) + if (CurrentText == this.Text) + { + return; + } + + if (!(string.IsNullOrEmpty(this.Text))) + { + //Restart timer + _timer.Start(); + } + else + { + //Not text, close drop down + this.ClosePopup(); + } + } + + //This event fires after the specified Timer.Interval has passed. + private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + _timer.Stop(); + GetMatchingItems_AsyncBegin(this.Text, true); + } + + //Generic function to create a gridViewTextBoxColumn with common attributes set + private GridViewTextBoxColumn CreateGridTextBoxColumn(string Name, string fieldName, string headerText) + { + GridViewTextBoxColumn gridViewTextBoxColumn = new GridViewTextBoxColumn(); + + gridViewTextBoxColumn.Name = Name; + gridViewTextBoxColumn.FieldName = fieldName; + gridViewTextBoxColumn.HeaderText = headerText; + gridViewTextBoxColumn.ReadOnly = true; + gridViewTextBoxColumn.HeaderTextAlignment = ContentAlignment.BottomLeft; + + return gridViewTextBoxColumn; + } + + //Fires when the cell is moved out of edit mode. Perform cleanup. + public override bool EndEdit() + { + _timer.Stop(); + _timer.Dispose(); + return base.EndEdit(); + } + } +} \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Application.Designer.cs b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Application.Designer.cs new file mode 100644 index 0000000..beff363 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Application.Designer.cs @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.3082 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + + + +//INSTANT C# NOTE: Formerly VB project-level imports: +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Linq; +using System.Xml.Linq; + +namespace SampleApp +{ + 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. + // + internal partial class MyApplication : Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase + { + + [global::System.Diagnostics.DebuggerStepThroughAttribute()] + public MyApplication() : base(Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + { + this.IsSingleInstance = false; + this.EnableVisualStyles = true; + this.SaveMySettingsOnExit = true; + this.ShutdownStyle = Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses; + } + + [global::System.Diagnostics.DebuggerStepThroughAttribute()] + protected override void OnCreateMainForm() + { + this.MainForm = global::SampleApp.Form1.DefaultInstance; + } + + private static MyApplication MyApp; + internal static MyApplication Application + { + get + { + return MyApp; + } + } + + [STAThread] + static void Main(string[] args) + { + System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); + MyApp = new MyApplication(); + MyApp.Run(args); + } + + } + } + +} \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Application.myapp b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Application.myapp new file mode 100644 index 0000000..1243847 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Application.myapp @@ -0,0 +1,11 @@ + + + true + Form1 + false + 0 + true + 0 + 0 + true + diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/AssemblyInfo.cs b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ac67d4e --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/AssemblyInfo.cs @@ -0,0 +1,51 @@ +//INSTANT C# NOTE: Formerly VB project-level imports: +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Linq; +using System.Xml.Linq; + +using System.Reflection; +using 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("SampleApp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyCompany("Acuity Brands Lighting")] +[assembly: AssemblyProduct("SampleApp")] +[assembly: AssemblyCopyright("Copyright © Acuity Brands Lighting 2009")] +[assembly: AssemblyTrademark("")] + +[assembly: ComVisible(false)] + +//The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5ae2a86c-2bdc-4ad0-89f5-d1d2e0d170fa")] + +// 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.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + + +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/DataSources/System.Data.DataSet.datasource b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/DataSources/System.Data.DataSet.datasource new file mode 100644 index 0000000..208df22 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/DataSources/System.Data.DataSet.datasource @@ -0,0 +1,10 @@ + + + + System.Data.DataSet, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Resources.Designer.cs b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Resources.Designer.cs new file mode 100644 index 0000000..55a10de --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SampleApp.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SampleApp.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Resources.resx b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Settings.Designer.cs b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Settings.Designer.cs new file mode 100644 index 0000000..3910904 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Settings.Designer.cs @@ -0,0 +1,56 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace My { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] + [global::System.Configuration.DefaultSettingValueAttribute("Data Source=|DataDirectory|\\Database1.sdf")] + public string Database1ConnectionString { + get { + return ((string)(this["Database1ConnectionString"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] + [global::System.Configuration.DefaultSettingValueAttribute("Data Source=|DataDirectory|\\TestDb1.sdf")] + public string TestDb1ConnectionString { + get { + return ((string)(this["TestDb1ConnectionString"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)] + [global::System.Configuration.DefaultSettingValueAttribute("http://localhost:4384/WebService1/Service.asmx")] + public string SampleApp_localhost_Service { + get { + return ((string)(this["SampleApp_localhost_Service"])); + } + } + } +} diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Settings.settings b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Settings.settings new file mode 100644 index 0000000..f924f1c --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Properties/Settings.settings @@ -0,0 +1,25 @@ + + + + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=|DataDirectory|\Database1.sdf</ConnectionString> + <ProviderName>Microsoft.SqlServerCe.Client.3.5</ProviderName> +</SerializableConnectionString> + Data Source=|DataDirectory|\Database1.sdf + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=|DataDirectory|\TestDb1.sdf</ConnectionString> + <ProviderName>Microsoft.SqlServerCe.Client.3.5</ProviderName> +</SerializableConnectionString> + Data Source=|DataDirectory|\TestDb1.sdf + + + http://localhost:4384/WebService1/Service.asmx + + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/SampleApp.xml b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/SampleApp.xml new file mode 100644 index 0000000..35a2a9a --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/SampleApp.xml @@ -0,0 +1,54 @@ + + + + SampleApp + + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + + Returns the cached ResourceManager instance used by this class. + + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Reference.cs b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Reference.cs new file mode 100644 index 0000000..5f3e844 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Reference.cs @@ -0,0 +1,151 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// +// This source code was auto-generated by Microsoft.VSDesigner, Version 4.0.30319.42000. +// +#pragma warning disable 1591 + +namespace SampleApp.localhost { + using System.Diagnostics; + using System; + using System.Xml.Serialization; + using System.ComponentModel; + using System.Web.Services.Protocols; + using System.Web.Services; + using System.Data; + + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.9032.0")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Web.Services.WebServiceBindingAttribute(Name="ServiceSoap", Namespace="http://tempuri.org/")] + public partial class Service : System.Web.Services.Protocols.SoapHttpClientProtocol { + + private System.Threading.SendOrPostCallback GetMatchingItemsOperationCompleted; + + private bool useDefaultCredentialsSetExplicitly; + + /// + public Service() { + this.Url = "http://localhost:4384/WebService1/Service.asmx"; + if ((this.IsLocalFileSystemWebService(this.Url) == true)) { + this.UseDefaultCredentials = true; + this.useDefaultCredentialsSetExplicitly = false; + } + else { + this.useDefaultCredentialsSetExplicitly = true; + } + } + + public new string Url { + get { + return base.Url; + } + set { + if ((((this.IsLocalFileSystemWebService(base.Url) == true) + && (this.useDefaultCredentialsSetExplicitly == false)) + && (this.IsLocalFileSystemWebService(value) == false))) { + base.UseDefaultCredentials = false; + } + base.Url = value; + } + } + + public new bool UseDefaultCredentials { + get { + return base.UseDefaultCredentials; + } + set { + base.UseDefaultCredentials = value; + this.useDefaultCredentialsSetExplicitly = true; + } + } + + /// + public event GetMatchingItemsCompletedEventHandler GetMatchingItemsCompleted; + + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetMatchingItems", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public System.Data.DataSet GetMatchingItems(string startOfText) { + object[] results = this.Invoke("GetMatchingItems", new object[] { + startOfText}); + return ((System.Data.DataSet)(results[0])); + } + + /// + public void GetMatchingItemsAsync(string startOfText) { + this.GetMatchingItemsAsync(startOfText, null); + } + + /// + public void GetMatchingItemsAsync(string startOfText, object userState) { + if ((this.GetMatchingItemsOperationCompleted == null)) { + this.GetMatchingItemsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetMatchingItemsOperationCompleted); + } + this.InvokeAsync("GetMatchingItems", new object[] { + startOfText}, this.GetMatchingItemsOperationCompleted, userState); + } + + private void OnGetMatchingItemsOperationCompleted(object arg) { + if ((this.GetMatchingItemsCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetMatchingItemsCompleted(this, new GetMatchingItemsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// + public new void CancelAsync(object userState) { + base.CancelAsync(userState); + } + + private bool IsLocalFileSystemWebService(string url) { + if (((url == null) + || (url == string.Empty))) { + return false; + } + System.Uri wsUri = new System.Uri(url); + if (((wsUri.Port >= 1024) + && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) { + return true; + } + return false; + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.9032.0")] + public delegate void GetMatchingItemsCompletedEventHandler(object sender, GetMatchingItemsCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "4.8.9032.0")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetMatchingItemsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetMatchingItemsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public System.Data.DataSet Result { + get { + this.RaiseExceptionIfNecessary(); + return ((System.Data.DataSet)(this.results[0])); + } + } + } +} + +#pragma warning restore 1591 \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Reference.map b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Reference.map new file mode 100644 index 0000000..d36afee --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Reference.map @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Service.disco b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Service.disco new file mode 100644 index 0000000..e305c74 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Service.disco @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Service.wsdl b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Service.wsdl new file mode 100644 index 0000000..cf19207 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/Web References/localhost/Service.wsdl @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/app.config b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/app.config new file mode 100644 index 0000000..1475e97 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandCS/app.config @@ -0,0 +1,43 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://localhost:4384/WebService1/Service.asmx + + + + diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Form1.Designer.vb b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Form1.Designer.vb new file mode 100644 index 0000000..f61851b --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Form1.Designer.vb @@ -0,0 +1,54 @@ + _ +Partial Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + 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. + _ + Private Sub InitializeComponent() + Me.rgData = New Telerik.WinControls.UI.RadGridView + CType(Me.rgData, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.rgData.MasterTemplate, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'rgData + ' + Me.rgData.Dock = System.Windows.Forms.DockStyle.Fill + Me.rgData.Location = New System.Drawing.Point(0, 0) + Me.rgData.Name = "rgData" + Me.rgData.Size = New System.Drawing.Size(852, 481) + Me.rgData.TabIndex = 0 + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(852, 481) + Me.Controls.Add(Me.rgData) + Me.Name = "Form1" + Me.Text = "Form1" + CType(Me.rgData.MasterTemplate, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.rgData, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents rgData As Telerik.WinControls.UI.RadGridView + +End Class diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Form1.resx b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Form1.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Form1.vb b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Form1.vb new file mode 100644 index 0000000..b073ea3 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Form1.vb @@ -0,0 +1,127 @@ +Imports Telerik.WinControls.UI +Imports Telerik.WinControls + +Public Class Form1 + + Private _loadOnDemandCellEditor As LoadOnDemandCellEditor + + Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + + InitializeLinesGrid() + + LoadGrid() + + End Sub + + 'Load the grid columns, set grid properties, etc. + Private Sub InitializeLinesGrid() + Dim gridMultiColumnComboColumn As GridViewMultiComboBoxColumn + + With rgData.MasterTemplate + + .Columns.Clear() + .AutoGenerateColumns = False + + gridMultiColumnComboColumn = CreateGridMultiComboBoxColumn("COUNTRY", "COUNTRY", "Country", Nothing, "COUNTRY", "COUNTRY", 400) + .Columns.Add(gridMultiColumnComboColumn) + + 'Set MasterGridViewTemplate properties + .AllowEditRow = True + .AllowAddNewRow = False + .EnableGrouping = False + .AllowColumnChooser = False + .AllowColumnHeaderContextMenu = False + + End With + + rgData.MultiSelect = True + rgData.SelectionMode = GridViewSelectionMode.FullRowSelect + rgData.ShowGroupPanel = False + + End Sub + + 'Create GridViewMultiComboBoxColumn with values passed in + Private Function CreateGridMultiComboBoxColumn(ByVal Name As String, ByVal fieldName As String, ByVal headerText As String, ByVal dataSource As BindingSource, ByVal valueMember As String, ByVal displayMember As String, ByVal width As Integer) As GridViewMultiComboBoxColumn + Dim multiComboBoxColumn As New GridViewMultiComboBoxColumn + + With multiComboBoxColumn + + .Name = Name + .FieldName = fieldName + .HeaderText = headerText + .DataSource = dataSource + .ValueMember = valueMember + .DisplayMember = displayMember + .Width = width + + 'Set default values + .HeaderTextAlignment = ContentAlignment.BottomLeft + .DropDownStyle = RadDropDownStyle.DropDown + + End With + + Return multiComboBoxColumn + + End Function + + 'Load the grid + Private Sub LoadGrid() + Dim rowInfo As GridViewRowInfo + + rowInfo = rgData.Rows.AddNew + rowInfo.Cells("COUNTRY").Value = "United States of America" + + rowInfo = rgData.Rows.AddNew + rowInfo.Cells("COUNTRY").Value = "Malta" + + rowInfo = rgData.Rows.AddNew + rowInfo.Cells("COUNTRY").Value = "Canada" + + rowInfo = rgData.Rows.AddNew + rowInfo.Cells("COUNTRY").Value = "Spain" + + rowInfo = rgData.Rows.AddNew + rowInfo.Cells("COUNTRY").Value = "Italy" + + End Sub + + 'This event fires when a field is put into edit mode. + Private Sub rgData_EditorRequired(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.EditorRequiredEventArgs) Handles rgData.EditorRequired + Dim currentColumnIndex As Integer + Dim currentRowIndex As Integer + Dim country As Object + Dim columnWidth As Integer + + currentColumnIndex = rgData.Columns.IndexOf(rgData.CurrentColumn) + + Select Case currentColumnIndex + + Case rgData.Columns("COUNTRY").Index + + currentRowIndex = rgData.Rows.IndexOf(rgData.CurrentRow) + country = rgData.Rows(currentRowIndex).Cells(currentColumnIndex).Value + columnWidth = rgData.Columns(currentColumnIndex).Width + + _loadOnDemandCellEditor = New LoadOnDemandCellEditor(country, columnWidth, rgData) + e.Editor = _loadOnDemandCellEditor + + End Select + + End Sub + + 'Fires when a cell is taken out of edit mode + Private Sub rgData_CellEndEdit(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles rgData.CellEndEdit + + If e.ColumnIndex = rgData.Columns("COUNTRY").Index Then + + 'Set the editor text from editor element and update the cell value (sometimes the grid did not hold + 'the updated value) + rgData.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = _loadOnDemandCellEditor.EditorElement.Text + + _loadOnDemandCellEditor.Dispose() + + End If + + End Sub + +End Class \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/LoadOnDemandCellEditor.vb b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/LoadOnDemandCellEditor.vb new file mode 100644 index 0000000..87795ce --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/LoadOnDemandCellEditor.vb @@ -0,0 +1,272 @@ +Imports Telerik.WinControls.UI + +Public Class LoadOnDemandCellEditor + Inherits RadMultiColumnComboBoxElement + + Private Const MinDropDownWidth As Integer = 320 + Private Const ShortNameWidth As Integer = 25 + Private Const GridOffset As Integer = 70 + Private Const TimerInterval = 425 + Private Const ItemInfoTableName As String = "ITEMS" + + Private _timer As System.Timers.Timer + + Private _showDropDown As Boolean + Private Property ShowDropDown() As Boolean + Get + Return _showDropDown + End Get + Set(ByVal value As Boolean) + 'This property can be updated on a background thread, so we need to ensure thread-safety + SyncLock Me + _showDropDown = value + End SyncLock + End Set + End Property + + Private _newItemsLoaded As Boolean + Private Property NewItemsLoaded() As Boolean + Get + Return _newItemsLoaded + End Get + Set(ByVal value As Boolean) + 'This property can be updated on a background thread, so we need to ensure thread-safety + SyncLock Me + _newItemsLoaded = value + End SyncLock + End Set + End Property + + Private _currentText As String = Nothing + Private Property CurrentText() As String + Get + Return _currentText + End Get + Set(ByVal value As String) + _currentText = value + End Set + End Property + + Public Sub New(ByVal text As Object, ByVal columnWidth As Integer, ByVal ownerGrid As RadGridView) + MyBase.New() + InitializeCellEditor(text, columnWidth, ownerGrid) + End Sub + + 'Initialize the cell editor (set properties and load matching data) + Private Sub InitializeCellEditor(ByVal text As Object, ByVal columnWidth As Integer, ByVal ownerGrid As RadGridView) + Dim grid As RadGridView + + If Not (TypeOf text Is DBNull) AndAlso Not String.IsNullOrEmpty(text) Then + CurrentText = text.ToString + End If + + With Me + .DisplayMember = "COUNTRY" + .ValueMember = "COUNTRY" + .Virtualized = False + + 'Make sure the drop down is at least minDropDownWidth + If columnWidth > MinDropDownWidth Then + .DropDownWidth = columnWidth + Else + .DropDownWidth = MinDropDownWidth + End If + + grid = .EditorControl + + 'Setup the grid that is displayed in the drop down list + InitializeGrid(grid, Me.DropDownWidth) + + 'Only load data if we have at least 3 characters + If CurrentText IsNot Nothing AndAlso CurrentText.Length >= 3 Then + + GetMatchingItems_AsyncBegin(CurrentText, False) + + 'Text of the combo gets cleared when the items are loaded, so make sure to set it here + Me.TextBoxElement.Text = CurrentText + + End If + + 'KeyUp and KeyDown events will allow us to load matching data on-demand + AddHandler Me.KeyDown, AddressOf DropDown_KeyDown + AddHandler Me.KeyUp, AddressOf DropDown_KeyUp + + End With + + InitializeTimer(ownerGrid) + + End Sub + + 'Configure the grid that is displayed within the drop down list. + Private Sub InitializeGrid(ByRef grid As RadGridView, ByVal gridWidth As Integer) + Dim gridTextBoxColumn As GridViewTextBoxColumn + + 'Set the grid to fill the drop down list + grid.Width = gridWidth + + grid.AutoSizeRows = True + grid.VirtualMode = False + + With grid.MasterTemplate + + .AutoGenerateColumns = False + .ShowColumnHeaders = False + .AllowColumnResize = False + .AllowRowResize = False + + .Columns.Clear() + + gridTextBoxColumn = CreateGridTextBoxColumn("SHORTNAME", "SHORTNAME", "SHORTNAME") + gridTextBoxColumn.Width = ShortNameWidth + .Columns.Add(gridTextBoxColumn) + + gridTextBoxColumn = CreateGridTextBoxColumn("COUNTRY", "COUNTRY", "COUNTRY") + + 'Set the column to fill the remaining space in the drop down + gridTextBoxColumn.Width = gridWidth - ShortNameWidth - GridOffset + gridTextBoxColumn.WrapText = True + .Columns.Add(gridTextBoxColumn) + + End With + + End Sub + + 'Initialize the Timer that is used to buffer the requests to the web service. So instead of firing + 'off a request on every keystroke, we will build in a short wait to make sure the user is done typing. + Private Sub InitializeTimer(ByVal ownerGrid As RadGridView) + + _timer = New System.Timers.Timer + _timer.Interval = TimerInterval + + 'The GridViewMultiComboBoxElement does not implement the InvokeRequired property or Invoke() method. + 'These are needed to update a control that was created on another thread. So we will need to + 'synchronize the timer with the another control so that we can update the UI in the timers Elasped + 'event handler, since the timer runs on a background thread. We can't access the grid that hosts this + 'control from the control itself, so we us a reference to the grid that is passed in the constructor. + _timer.SynchronizingObject() = ownerGrid + + AddHandler _timer.Elapsed, AddressOf Timer_Elapsed + + End Sub + + 'Make an asynchronous call into the web service to get items that match the text that is passed in + Private Sub GetMatchingItems_AsyncBegin(ByVal text As String, ByVal showDropDownFlag As Boolean) + + Using ws As New localhost.Service + ShowDropDown = showDropDownFlag + AddHandler ws.GetMatchingItemsCompleted, AddressOf GetMatchingItems_AsyncCompleted + ws.GetMatchingItemsAsync(text) + End Using + + End Sub + + 'Asynchronous callback event handler for the GetMatchingItemsAsync call to the web service + Private Sub GetMatchingItems_AsyncCompleted(ByVal sender As Object, ByVal e As localhost.GetMatchingItemsCompletedEventArgs) + Dim grid As RadGridView + Dim returnDataSet As DataSet + Dim itemInfo As DataTable + + If e.Error IsNot Nothing OrElse e.Result Is Nothing Then + 'WS call errored out, or nothing was returned + Exit Sub + + End If + + returnDataSet = CType(e.Result, DataSet) + itemInfo = returnDataSet.Tables(ItemInfoTableName) + + grid = Me.EditorControl + grid.DataSource = itemInfo + + If ShowDropDown Then + Me.ShowPopup() + End If + + NewItemsLoaded = True + + End Sub + + 'Handles the KeyDown event for the drop down editor. + Private Sub DropDown_KeyDown(ByVal sender As System.Object, ByVal e As KeyEventArgs) + + 'Store the current text so that we can tell if it has changed in the KeyUp event. + CurrentText = Me.Text + + 'If the down key was pressed, there are items loaded in the drop down and an item has not already + 'been selected, then force the selection. This is to workaround an issue where pressing the down + 'key would not force focus to the grid (allowing the user to scroll through the items). + If e.KeyCode = Keys.Down Then + + If Me.EditorControl.Rows.Count > 0 AndAlso _ + NewItemsLoaded = True Then + + Me.SelectedIndex = 0 + Me.ShowPopup() + + End If + + 'Reset NewItemsLoaded for next iteration + NewItemsLoaded = False + + End If + + End Sub + + 'Handles the KeyUp event for the drop down editor. We load any matching items. + Private Sub DropDown_KeyUp(ByVal sender As System.Object, ByVal e As KeyEventArgs) + + 'Force the timer to stop. We will only start the timer if the text is valid + _timer.Stop() + + 'Escape navigation keys (ex. up/down arrow) so we don't reload the drop down when the + 'user scrolls through the items in the grid. + Select Case e.KeyCode + Case Keys.Up, Keys.Down + Exit Sub + End Select + + 'Just exit if the text has not changed (user could have pressed F1, CTRL, SHIFT, etc.) + If CurrentText = Me.Text Then + Exit Sub + End If + + If Not String.IsNullOrEmpty(Me.Text) Then + 'Restart timer + _timer.Start() + Else + 'Not text, close drop down + Me.ClosePopup() + End If + + End Sub + + 'This event fires after the specified Timer.Interval has passed. + Private Sub Timer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) + _timer.Stop() + GetMatchingItems_AsyncBegin(Me.Text, True) + End Sub + + 'Generic function to create a gridViewTextBoxColumn with common attributes set + Private Function CreateGridTextBoxColumn(ByVal Name As String, ByVal fieldName As String, ByVal headerText As String) As GridViewTextBoxColumn + Dim gridViewTextBoxColumn As New GridViewTextBoxColumn + + With gridViewTextBoxColumn + .Name = Name + .FieldName = fieldName + .HeaderText = headerText + .ReadOnly = True + .HeaderTextAlignment = ContentAlignment.BottomLeft + End With + + Return gridViewTextBoxColumn + + End Function + + 'Fires when the cell is moved out of edit mode. Perform cleanup. + Public Overrides Function EndEdit() As Boolean + _timer.Stop() + _timer.Dispose() + MyBase.EndEdit() + End Function + +End Class \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/LoadOnDemandVB.vbproj b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/LoadOnDemandVB.vbproj new file mode 100644 index 0000000..6bb948e --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/LoadOnDemandVB.vbproj @@ -0,0 +1,242 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {C86FFBA3-2E62-4025-80EB-7F0AC9581EF1} + WinExe + SampleApp.My.MyApplication + SampleApp + SampleApp + 512 + WindowsForms + v4.0 + On + Binary + Off + On + true + + + + + 3.5 + http://localhost/SampleApp/ + true + Web + true + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true + + + + true + full + true + true + bin\Debug\ + SampleApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355 + MinimumRecommendedRules.ruleset + + + pdbonly + false + true + true + bin\Release\ + SampleApp.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,42353,42354,42355 + MinimumRecommendedRules.ruleset + + + + ..\..\..\..\..\Windows\Microsoft.NET\Framework64\v2.0.50727\System.dll + + + + + + + + 3.0 + + + 3.0 + + + + + + + 3.5 + + + 3.5 + + + 3.5 + + + ..\..\..\..\..\Program Files (x86)\Progress\Telerik UI for WinForms 2024 Q1\Bin40\Telerik.WinControls.dll + + + ..\..\..\..\..\Program Files (x86)\Progress\Telerik UI for WinForms 2024 Q1\Bin40\Telerik.WinControls.GridView.dll + + + ..\..\..\..\..\Program Files (x86)\Progress\Telerik UI for WinForms 2024 Q1\Bin40\Telerik.WinControls.UI.dll + + + ..\..\..\..\..\Program Files (x86)\Progress\Telerik UI for WinForms 2024 Q1\Bin40\TelerikCommon.dll + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + Application.myapp + True + + + True + True + Resources.resx + + + True + Settings.settings + True + + + True + True + Reference.map + + + + + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework Client Profile + false + + + False + .NET Framework 2.0 %28x86%29 + false + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + False + .NET Framework 3.5 SP1 + true + + + False + SQL Server Compact 3.5 + true + + + False + Windows Installer 3.1 + true + + + + + + MSDiscoCodeGenerator + Reference.vb + + + + + + + + + + + + + Dynamic + Web References\localhost\ + http://localhost:4384/WebService1/Service.asmx + + + + + MySettings + SampleApp_localhost_Service + + + + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Application.Designer.vb b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Application.Designer.vb new file mode 100644 index 0000000..b275f9f --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Application.Designer.vb @@ -0,0 +1,44 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +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 + + _ + 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 + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.SampleApp.Form1 + End Sub + + _ + Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean + Me.MinimumSplashScreenDisplayTime = 0 + Return MyBase.OnInitialize(commandLineArgs) + End Function + End Class +End Namespace diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Application.myapp b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Application.myapp new file mode 100644 index 0000000..1243847 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Application.myapp @@ -0,0 +1,11 @@ + + + true + Form1 + false + 0 + true + 0 + 0 + true + diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/AssemblyInfo.vb b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..5894a17 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/AssemblyInfo.vb @@ -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 + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' 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: +' + + + diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/DataSources/System.Data.DataSet.datasource b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/DataSources/System.Data.DataSet.datasource new file mode 100644 index 0000000..208df22 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/DataSources/System.Data.DataSet.datasource @@ -0,0 +1,10 @@ + + + + System.Data.DataSet, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Resources.Designer.vb b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Resources.Designer.vb new file mode 100644 index 0000000..6840e48 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +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. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + 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("SampleApp.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Resources.resx b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Settings.Designer.vb b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Settings.Designer.vb new file mode 100644 index 0000000..3b19cdd --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Settings.Designer.vb @@ -0,0 +1,103 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + 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 + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, 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 + + _ + Public ReadOnly Property Database1ConnectionString() As String + Get + Return CType(Me("Database1ConnectionString"),String) + End Get + End Property + + _ + Public ReadOnly Property TestDb1ConnectionString() As String + Get + Return CType(Me("TestDb1ConnectionString"),String) + End Get + End Property + + _ + Public ReadOnly Property SampleApp_localhost_Service() As String + Get + Return CType(Me("SampleApp_localhost_Service"),String) + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.SampleApp.My.MySettings + Get + Return Global.SampleApp.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Settings.settings b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Settings.settings new file mode 100644 index 0000000..f924f1c --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/My Project/Settings.settings @@ -0,0 +1,25 @@ + + + + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=|DataDirectory|\Database1.sdf</ConnectionString> + <ProviderName>Microsoft.SqlServerCe.Client.3.5</ProviderName> +</SerializableConnectionString> + Data Source=|DataDirectory|\Database1.sdf + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=|DataDirectory|\TestDb1.sdf</ConnectionString> + <ProviderName>Microsoft.SqlServerCe.Client.3.5</ProviderName> +</SerializableConnectionString> + Data Source=|DataDirectory|\TestDb1.sdf + + + http://localhost:4384/WebService1/Service.asmx + + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Reference.map b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Reference.map new file mode 100644 index 0000000..d36afee --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Reference.map @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Reference.vb b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Reference.vb new file mode 100644 index 0000000..0792435 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Reference.vb @@ -0,0 +1,150 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict Off +Option Explicit On + +Imports System +Imports System.ComponentModel +Imports System.Data +Imports System.Diagnostics +Imports System.Web.Services +Imports System.Web.Services.Protocols +Imports System.Xml.Serialization + +' +'This source code was auto-generated by Microsoft.VSDesigner, Version 4.0.30319.42000. +' +Namespace localhost + + ''' + _ + Partial Public Class Service + Inherits System.Web.Services.Protocols.SoapHttpClientProtocol + + Private GetMatchingItemsOperationCompleted As System.Threading.SendOrPostCallback + + Private useDefaultCredentialsSetExplicitly As Boolean + + ''' + Public Sub New() + MyBase.New + Me.Url = Global.SampleApp.My.MySettings.Default.SampleApp_localhost_Service + If (Me.IsLocalFileSystemWebService(Me.Url) = true) Then + Me.UseDefaultCredentials = true + Me.useDefaultCredentialsSetExplicitly = false + Else + Me.useDefaultCredentialsSetExplicitly = true + End If + End Sub + + Public Shadows Property Url() As String + Get + Return MyBase.Url + End Get + Set + If (((Me.IsLocalFileSystemWebService(MyBase.Url) = true) _ + AndAlso (Me.useDefaultCredentialsSetExplicitly = false)) _ + AndAlso (Me.IsLocalFileSystemWebService(value) = false)) Then + MyBase.UseDefaultCredentials = false + End If + MyBase.Url = value + End Set + End Property + + Public Shadows Property UseDefaultCredentials() As Boolean + Get + Return MyBase.UseDefaultCredentials + End Get + Set + MyBase.UseDefaultCredentials = value + Me.useDefaultCredentialsSetExplicitly = true + End Set + End Property + + ''' + Public Event GetMatchingItemsCompleted As GetMatchingItemsCompletedEventHandler + + ''' + _ + Public Function GetMatchingItems(ByVal startOfText As String) As System.Data.DataSet + Dim results() As Object = Me.Invoke("GetMatchingItems", New Object() {startOfText}) + Return CType(results(0),System.Data.DataSet) + End Function + + ''' + Public Overloads Sub GetMatchingItemsAsync(ByVal startOfText As String) + Me.GetMatchingItemsAsync(startOfText, Nothing) + End Sub + + ''' + Public Overloads Sub GetMatchingItemsAsync(ByVal startOfText As String, ByVal userState As Object) + If (Me.GetMatchingItemsOperationCompleted Is Nothing) Then + Me.GetMatchingItemsOperationCompleted = AddressOf Me.OnGetMatchingItemsOperationCompleted + End If + Me.InvokeAsync("GetMatchingItems", New Object() {startOfText}, Me.GetMatchingItemsOperationCompleted, userState) + End Sub + + Private Sub OnGetMatchingItemsOperationCompleted(ByVal arg As Object) + If (Not (Me.GetMatchingItemsCompletedEvent) Is Nothing) Then + Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = CType(arg,System.Web.Services.Protocols.InvokeCompletedEventArgs) + RaiseEvent GetMatchingItemsCompleted(Me, New GetMatchingItemsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)) + End If + End Sub + + ''' + Public Shadows Sub CancelAsync(ByVal userState As Object) + MyBase.CancelAsync(userState) + End Sub + + Private Function IsLocalFileSystemWebService(ByVal url As String) As Boolean + If ((url Is Nothing) _ + OrElse (url Is String.Empty)) Then + Return false + End If + Dim wsUri As System.Uri = New System.Uri(url) + If ((wsUri.Port >= 1024) _ + AndAlso (String.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) = 0)) Then + Return true + End If + Return false + End Function + End Class + + ''' + _ + Public Delegate Sub GetMatchingItemsCompletedEventHandler(ByVal sender As Object, ByVal e As GetMatchingItemsCompletedEventArgs) + + ''' + _ + Partial Public Class GetMatchingItemsCompletedEventArgs + Inherits System.ComponentModel.AsyncCompletedEventArgs + + Private results() As Object + + Friend Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object) + MyBase.New(exception, cancelled, userState) + Me.results = results + End Sub + + ''' + Public ReadOnly Property Result() As System.Data.DataSet + Get + Me.RaiseExceptionIfNecessary + Return CType(Me.results(0),System.Data.DataSet) + End Get + End Property + End Class +End Namespace diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Service.disco b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Service.disco new file mode 100644 index 0000000..e305c74 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Service.disco @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Service.wsdl b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Service.wsdl new file mode 100644 index 0000000..cf19207 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/Web References/localhost/Service.wsdl @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/app.config b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/app.config new file mode 100644 index 0000000..1475e97 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/LoadOnDemandVB/app.config @@ -0,0 +1,43 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://localhost:4384/WebService1/Service.asmx + + + + diff --git a/GridView/LoadOnDemandComboBoxInGrid/WebService1/App_Code/DataSet1.xsd b/GridView/LoadOnDemandComboBoxInGrid/WebService1/App_Code/DataSet1.xsd new file mode 100644 index 0000000..1aaa519 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/WebService1/App_Code/DataSet1.xsd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/WebService1/App_Code/DataSet1.xss b/GridView/LoadOnDemandComboBoxInGrid/WebService1/App_Code/DataSet1.xss new file mode 100644 index 0000000..16580e4 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/WebService1/App_Code/DataSet1.xss @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/GridView/LoadOnDemandComboBoxInGrid/WebService1/App_Code/Service.vb b/GridView/LoadOnDemandComboBoxInGrid/WebService1/App_Code/Service.vb new file mode 100644 index 0000000..7d28594 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/WebService1/App_Code/Service.vb @@ -0,0 +1,187 @@ +Imports System.Web +Imports System.Web.Services +Imports System.Web.Services.Protocols +Imports System.ComponentModel +Imports System.Data + +' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. +' _ + _ + _ + _ +Public Class Service + Inherits System.Web.Services.WebService + + _ + Public Function GetMatchingItems(ByVal startOfText As String) As DataSet + Dim dr As DataRow + Dim dt As New DataTable + Dim dv As DataView + Dim ds As New DataSet + + 'Load data + dt.CaseSensitive = False + dt.Columns.Add("COUNTRY") + dt.Columns.Add("SHORTNAME") + + dr = dt.NewRow + dr("COUNTRY") = "United States of America" + dr("SHORTNAME") = "US" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "United Kingdom" + dr("SHORTNAME") = "UK" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Ukraine" + dr("SHORTNAME") = "UA" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Uruguay" + dr("SHORTNAME") = "UY" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Malta" + dr("SHORTNAME") = "MT" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Mali" + dr("SHORTNAME") = "ML" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Madagasgar" + dr("SHORTNAME") = "UA" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Morocco" + dr("SHORTNAME") = "MA" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Monaco" + dr("SHORTNAME") = "MC" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Mexico" + dr("SHORTNAME") = "MX" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Maldives" + dr("SHORTNAME") = "MV" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Malawi" + dr("SHORTNAME") = "MW" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Malaysia" + dr("SHORTNAME") = "MY" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Canada" + dr("SHORTNAME") = "CA" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Cambodia" + dr("SHORTNAME") = "KH" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Congo" + dr("SHORTNAME") = "CG" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Chile" + dr("SHORTNAME") = "CL" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Cameroon" + dr("SHORTNAME") = "CM" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Cuba" + dr("SHORTNAME") = "CU" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Spain" + dr("SHORTNAME") = "EP" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Sri Lanka" + dr("SHORTNAME") = "LK" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Sudan" + dr("SHORTNAME") = "SD" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Sweden" + dr("SHORTNAME") = "SE" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Italy" + dr("SHORTNAME") = "IT" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Ireland" + dr("SHORTNAME") = "IE" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "India" + dr("SHORTNAME") = "IN" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Israel" + dr("SHORTNAME") = "IL" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Iceland" + dr("SHORTNAME") = "IS" + dt.Rows.Add(dr) + + dr = dt.NewRow + dr("COUNTRY") = "Indonesia" + dr("SHORTNAME") = "ID" + dt.Rows.Add(dr) + + 'Filter the result set to find the matching rows + dv = dt.DefaultView + dv.RowFilter = "COUNTRY LIKE '" & startOfText.ToLower & "%'" + + 'Convert the dataView back to a dataTable + dt = dv.ToTable() + dt.TableName = "ITEMS" + + 'Add the dataTable to the dataSet + ds.Tables.Add(dt) + + Return ds + + End Function + +End Class diff --git a/GridView/LoadOnDemandComboBoxInGrid/WebService1/Service.asmx b/GridView/LoadOnDemandComboBoxInGrid/WebService1/Service.asmx new file mode 100644 index 0000000..0508ce6 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/WebService1/Service.asmx @@ -0,0 +1 @@ +<%@ WebService Language="vb" CodeBehind="~/App_Code/Service.vb" Class="Service" %> diff --git a/GridView/LoadOnDemandComboBoxInGrid/WebService1/web.config b/GridView/LoadOnDemandComboBoxInGrid/WebService1/web.config new file mode 100644 index 0000000..dbf65d0 --- /dev/null +++ b/GridView/LoadOnDemandComboBoxInGrid/WebService1/web.config @@ -0,0 +1,148 @@ + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file