From ec20f5bf7d5747e9925100d5f4f9650d32826569 Mon Sep 17 00:00:00 2001 From: Desislava Yordanova Date: Mon, 7 Jun 2021 13:03:45 +0300 Subject: [PATCH] RestoreRowValues --- .../RestoreRowValuesCSharp.sln | 20 ++ .../RestoreRowValuesCSharp/Form1.Designer.cs | 64 ++++++ .../RestoreRowValuesCSharp/Form1.cs | 115 +++++++++++ .../RestoreRowValuesCSharp/Form1.resx | 120 +++++++++++ .../RestoreRowValuesCSharp/Program.cs | 19 ++ .../Properties/AssemblyInfo.cs | 36 ++++ .../Properties/Resources.Designer.cs | 63 ++++++ .../Properties/Resources.resx | 117 +++++++++++ .../Properties/Settings.Designer.cs | 26 +++ .../Properties/Settings.settings | 7 + .../RestoreRowValuesCSharp.csproj | 89 ++++++++ .../RestoreRowValuesCSharp/app.config | 3 + .../RestoreRowValuesVBNET.sln | 20 ++ .../RestoreRowValuesVBNET/App.config | 6 + .../ApplicationEvents.vb | 1 + .../RestoreRowValuesVBNET/Form1.Designer.vb | 54 +++++ .../RestoreRowValuesVBNET/Form1.resx | 120 +++++++++++ .../RestoreRowValuesVBNET/Form1.vb | 121 +++++++++++ .../My Project/Application.Designer.vb | 38 ++++ .../My Project/Application.myapp | 10 + .../My Project/AssemblyInfo.vb | 35 ++++ .../My Project/Resources.Designer.vb | 63 ++++++ .../My Project/Resources.resx | 117 +++++++++++ .../My Project/Settings.Designer.vb | 73 +++++++ .../My Project/Settings.settings | 7 + .../My Project/app.manifest | 48 +++++ .../RestoreRowValuesVBNET.vbproj | 190 ++++++++++++++++++ 27 files changed, 1582 insertions(+) create mode 100644 GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp.sln create mode 100644 GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Form1.Designer.cs create mode 100644 GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Form1.cs create mode 100644 GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Form1.resx create mode 100644 GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Program.cs create mode 100644 GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/AssemblyInfo.cs create mode 100644 GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Resources.Designer.cs create mode 100644 GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Resources.resx create mode 100644 GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Settings.Designer.cs create mode 100644 GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Settings.settings create mode 100644 GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/RestoreRowValuesCSharp.csproj create mode 100644 GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/app.config create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET.sln create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/App.config create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/ApplicationEvents.vb create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/Form1.Designer.vb create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/Form1.resx create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/Form1.vb create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Application.Designer.vb create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Application.myapp create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/AssemblyInfo.vb create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Resources.Designer.vb create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Resources.resx create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Settings.Designer.vb create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Settings.settings create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/app.manifest create mode 100644 GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/RestoreRowValuesVBNET.vbproj diff --git a/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp.sln b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp.sln new file mode 100644 index 0000000..57bb796 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestoreRowValuesCSharp", "RestoreRowValuesCSharp\RestoreRowValuesCSharp.csproj", "{16BF5B20-5FBC-4A45-8089-0266D65AE094}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {16BF5B20-5FBC-4A45-8089-0266D65AE094}.Debug|x86.ActiveCfg = Debug|x86 + {16BF5B20-5FBC-4A45-8089-0266D65AE094}.Debug|x86.Build.0 = Debug|x86 + {16BF5B20-5FBC-4A45-8089-0266D65AE094}.Release|x86.ActiveCfg = Release|x86 + {16BF5B20-5FBC-4A45-8089-0266D65AE094}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Form1.Designer.cs b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Form1.Designer.cs new file mode 100644 index 0000000..fd711d9 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Form1.Designer.cs @@ -0,0 +1,64 @@ +namespace CustomRowBehaviorCSharp +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.radGridView1 = new Telerik.WinControls.UI.RadGridView(); + ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterTemplate)).BeginInit(); + this.SuspendLayout(); + // + // radGridView1 + // + this.radGridView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.radGridView1.Location = new System.Drawing.Point(0, 0); + this.radGridView1.Name = "radGridView1"; + this.radGridView1.Size = new System.Drawing.Size(284, 262); + this.radGridView1.TabIndex = 0; + this.radGridView1.Text = "radGridView1"; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 262); + this.Controls.Add(this.radGridView1); + this.Name = "Form1"; + this.Text = "Form1"; + ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterTemplate)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Telerik.WinControls.UI.RadGridView radGridView1; + } +} + diff --git a/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Form1.cs b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Form1.cs new file mode 100644 index 0000000..ca712ea --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Form1.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using Telerik.WinControls.UI; + +namespace CustomRowBehaviorCSharp +{ + public partial class Form1 : Form + { + List items = new List(); + + public Form1() + { + InitializeComponent(); + + this.radGridView1.TableElement.CurrentRowHeaderImage = null; + + this.radGridView1.RowValidating += radGridView1_RowValidating; + this.radGridView1.RowValidated += radGridView1_RowValidated; + this.radGridView1.CurrentRowChanged += radGridView1_CurrentRowChanged; + this.radGridView1.CellValidating += radGridView1_CellValidating; + this.radGridView1.PreviewKeyDown += radGridView1_PreviewKeyDown; + + for (int i = 0; i < 10; i++) + { + items.Add(new Item(i, "Item" + i, i % 2 == 0, DateTime.Now.AddDays(i))); + } + + this.radGridView1.DataSource = items; + this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; + } + + private void radGridView1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + { + if (this.radGridView1.CurrentRow is GridViewDataRowInfo && e.KeyData == Keys.Escape) + { + //revert the previous cell value which is stored in advance. + if (this.radGridView1.ActiveEditor == null && this.radGridView1.Tag == "RowNotValidated") + { + foreach (KeyValuePair cell in initialValues) + { + this.radGridView1.CurrentRow.Cells[cell.Key].Value = cell.Value; + } + this.radGridView1.CurrentRow.ErrorText = string.Empty; + } + } + } + + private void radGridView1_RowValidated(object sender, RowValidatedEventArgs e) + { + this.radGridView1.Tag = null; + } + + private void radGridView1_CellValidating(object sender, CellValidatingEventArgs e) + { + if (this.radGridView1.CurrentCell != null) + { + int cellIndex = e.ColumnIndex; + object initialCellValue = e.Row.Cells[cellIndex].Value; + if (!initialValues.ContainsKey(cellIndex)) + { + initialValues.Add(cellIndex, initialCellValue); + } + } + } + + private void radGridView1_CurrentRowChanged(object sender, CurrentRowChangedEventArgs e) + { + if (e.CurrentRow != null) + { + initialValues = new Dictionary(); + } + } + + private void radGridView1_RowValidating(object sender, RowValidatingEventArgs e) + { + e.Row.ErrorText = string.Empty; + if (e.Row is GridViewDataRowInfo) + { + if (e.Row.Cells[1].Value == null || String.IsNullOrEmpty(e.Row.Cells[1].Value.ToString())) + { + e.Row.ErrorText = "Empty value is not allowed"; + e.Cancel = true; + this.radGridView1.Tag = "RowNotValidated"; + } + } + } + + //Cell index as a Key, cell value as Value + Dictionary initialValues; + + public class Item + { + public int Id { get; set; } + + public string Title { get; set; } + + public bool IsActive { get; set; } + + public DateTime CreatedOn { get; set; } + + public Item(int id, string title, bool isActive, DateTime createdOn) + { + this.Id = id; + this.Title = title; + this.IsActive = isActive; + this.CreatedOn = createdOn; + } + } + } +} \ No newline at end of file diff --git a/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Form1.resx b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Form1.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/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/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Program.cs b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Program.cs new file mode 100644 index 0000000..f8173e1 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Windows.Forms; + +namespace CustomRowBehaviorCSharp +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/AssemblyInfo.cs b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..43ea155 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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. +[assembly: AssemblyTitle("CustomRowBehaviorCSharp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CustomRowBehaviorCSharp")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c99a7d55-5395-417b-8df4-fbbbe7c1ef10")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Resources.Designer.cs b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Resources.Designer.cs new file mode 100644 index 0000000..71e9c72 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.18444 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace RestoreRowValuesVBNET.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", "4.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("RestoreRowValuesVBNET.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/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Resources.resx b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/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/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Settings.Designer.cs b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Settings.Designer.cs new file mode 100644 index 0000000..c42e267 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.18444 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace RestoreRowValuesVBNET.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.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; + } + } + } +} diff --git a/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Settings.settings b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/RestoreRowValuesCSharp.csproj b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/RestoreRowValuesCSharp.csproj new file mode 100644 index 0000000..155fe75 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/RestoreRowValuesCSharp.csproj @@ -0,0 +1,89 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {16BF5B20-5FBC-4A45-8089-0266D65AE094} + WinExe + Properties + RestoreRowValuesVBNET + RestoreRowValuesVBNET + v2.0 + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/app.config b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/app.config new file mode 100644 index 0000000..e59af44 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesCSharp/RestoreRowValuesCSharp/app.config @@ -0,0 +1,3 @@ + + + diff --git a/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET.sln b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET.sln new file mode 100644 index 0000000..ebd1fbf --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RestoreRowValuesVBNET", "RestoreRowValuesVBNET\RestoreRowValuesVBNET.vbproj", "{50CA9E61-1A9B-44C4-B961-58850AFF0D19}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {50CA9E61-1A9B-44C4-B961-58850AFF0D19}.Debug|x86.ActiveCfg = Debug|x86 + {50CA9E61-1A9B-44C4-B961-58850AFF0D19}.Debug|x86.Build.0 = Debug|x86 + {50CA9E61-1A9B-44C4-B961-58850AFF0D19}.Release|x86.ActiveCfg = Release|x86 + {50CA9E61-1A9B-44C4-B961-58850AFF0D19}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/App.config b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/App.config new file mode 100644 index 0000000..ae12da2 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/ApplicationEvents.vb b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/ApplicationEvents.vb new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/ApplicationEvents.vb @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/Form1.Designer.vb b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/Form1.Designer.vb new file mode 100644 index 0000000..9754e70 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/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.RadGridView1 = New Telerik.WinControls.UI.RadGridView() + CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.RadGridView1.MasterTemplate, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'RadGridView1 + ' + Me.RadGridView1.Dock = System.Windows.Forms.DockStyle.Fill + Me.RadGridView1.Location = New System.Drawing.Point(0, 0) + Me.RadGridView1.Name = "RadGridView1" + Me.RadGridView1.Size = New System.Drawing.Size(284, 262) + Me.RadGridView1.TabIndex = 0 + Me.RadGridView1.Text = "RadGridView1" + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(284, 262) + Me.Controls.Add(Me.RadGridView1) + Me.Name = "Form1" + Me.Text = "Form1" + CType(Me.RadGridView1.MasterTemplate, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + + End Sub + Friend WithEvents RadGridView1 As Telerik.WinControls.UI.RadGridView + +End Class diff --git a/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/Form1.resx b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/Form1.vb b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/Form1.vb new file mode 100644 index 0000000..edd7828 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/Form1.vb @@ -0,0 +1,121 @@ +Imports Telerik.WinControls.UI + +Public Class Form1 + + Private items As New List(Of Item)() + + Public Sub New() + InitializeComponent() + Me.RadGridView1.TableElement.CurrentRowHeaderImage = Nothing + + AddHandler Me.RadGridView1.RowValidating, AddressOf radGridView1_RowValidating + AddHandler Me.RadGridView1.RowValidated, AddressOf radGridView1_RowValidated + AddHandler Me.RadGridView1.CurrentRowChanged, AddressOf radGridView1_CurrentRowChanged + AddHandler Me.RadGridView1.CellValidating, AddressOf radGridView1_CellValidating + AddHandler Me.RadGridView1.PreviewKeyDown, AddressOf radGridView1_PreviewKeyDown + + For i As Integer = 0 To 9 + items.Add(New Item(i, "Item" & i, i Mod 2 = 0, DateTime.Now.AddDays(i))) + Next + + Me.RadGridView1.DataSource = items + Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill + + End Sub + + Private Sub radGridView1_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs) + If TypeOf Me.radGridView1.CurrentRow Is GridViewDataRowInfo AndAlso e.KeyData = Keys.Escape Then + 'revert the previous cell value which is stored in advance. + If Me.radGridView1.ActiveEditor Is Nothing AndAlso Me.radGridView1.Tag = "RowNotValidated" Then + For Each cell As KeyValuePair(Of Integer, Object) In initialValues + Me.radGridView1.CurrentRow.Cells(cell.Key).Value = cell.Value + Next + Me.radGridView1.CurrentRow.ErrorText = String.Empty + End If + End If + End Sub + + Private Sub radGridView1_RowValidated(sender As Object, e As RowValidatedEventArgs) + Me.RadGridView1.Tag = Nothing + End Sub + + Private Sub radGridView1_CellValidating(sender As Object, e As CellValidatingEventArgs) + If Me.RadGridView1.CurrentCell IsNot Nothing Then + Dim cellIndex As Integer = e.ColumnIndex + Dim initialCellValue As Object = e.Row.Cells(cellIndex).Value + If Not initialValues.ContainsKey(cellIndex) Then + initialValues.Add(cellIndex, initialCellValue) + End If + End If + End Sub + + Private Sub radGridView1_CurrentRowChanged(sender As Object, e As CurrentRowChangedEventArgs) + If e.CurrentRow IsNot Nothing Then + initialValues = New Dictionary(Of Integer, Object)() + End If + End Sub + + Private Sub radGridView1_RowValidating(sender As Object, e As RowValidatingEventArgs) + e.Row.ErrorText = String.Empty + If TypeOf e.Row Is GridViewDataRowInfo Then + If e.Row.Cells(1).Value Is Nothing OrElse [String].IsNullOrEmpty(e.Row.Cells(1).Value.ToString()) Then + e.Row.ErrorText = "Empty value is not allowed" + e.Cancel = True + Me.RadGridView1.Tag = "RowNotValidated" + End If + End If + End Sub + + 'Cell index as a Key, cell value as Value + Dim initialValues As Dictionary(Of Integer, Object) + + Public Class Item + Public Property Id() As Integer + Get + Return m_Id + End Get + Set(value As Integer) + m_Id = value + End Set + End Property + Private m_Id As Integer + + Public Property Title() As String + Get + Return m_Title + End Get + Set(value As String) + m_Title = value + End Set + End Property + Private m_Title As String + + Public Property IsActive() As Boolean + Get + Return m_IsActive + End Get + Set(value As Boolean) + m_IsActive = value + End Set + End Property + Private m_IsActive As Boolean + + Public Property CreatedOn() As DateTime + Get + Return m_CreatedOn + End Get + Set(value As DateTime) + m_CreatedOn = value + End Set + End Property + Private m_CreatedOn As DateTime + + Public Sub New(id As Integer, title As String, isActive As Boolean, createdOn As DateTime) + Me.Id = id + Me.Title = title + Me.IsActive = isActive + Me.CreatedOn = createdOn + End Sub + End Class + +End Class diff --git a/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Application.Designer.vb b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Application.Designer.vb new file mode 100644 index 0000000..480ae22 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.18444 +' +' 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.RestoreRowValuesVBNET.Form1 + End Sub + End Class +End Namespace diff --git a/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Application.myapp b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Application.myapp new file mode 100644 index 0000000..0f12f32 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + Form1 + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/AssemblyInfo.vb b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..06a09d7 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/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/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Resources.Designer.vb b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Resources.Designer.vb new file mode 100644 index 0000000..8077147 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.18444 +' +' 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("RestoreRowValuesVBNET.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/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Resources.resx b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/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/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Settings.Designer.vb b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Settings.Designer.vb new file mode 100644 index 0000000..4c1a3ae --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.18444 +' +' 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(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.RestoreRowValuesVBNET.My.MySettings + Get + Return Global.RestoreRowValuesVBNET.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Settings.settings b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/app.manifest b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/app.manifest new file mode 100644 index 0000000..f5ca617 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/My Project/app.manifest @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/RestoreRowValuesVBNET.vbproj b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/RestoreRowValuesVBNET.vbproj new file mode 100644 index 0000000..3ea6b57 --- /dev/null +++ b/GridView/RestoreRowValues/RestoreRowValuesVB/RestoreRowValuesVBNET/RestoreRowValuesVBNET.vbproj @@ -0,0 +1,190 @@ + + + + Debug + x86 + + 2.0 + {50CA9E61-1A9B-44C4-B961-58850AFF0D19} + WinExe + RestoreRowValuesVBNET.My.MyApplication + RestoreRowValuesVBNET + RestoreRowValuesVBNET + 512 + WindowsForms + v2.0 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + x86 + true + full + true + true + bin\Debug\ + RestoreRowValuesVBNET.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + x86 + pdbonly + false + true + true + bin\Release\ + RestoreRowValuesVBNET.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + My Project\app.manifest + + + + + + + + + + + + + False + ..\..\..\Users\yordanova\Desktop\DLL\Telerik_UI_For_WinForms_2014_1_14_226_Dev_hotfix\Bin\Telerik.WinControls.dll + + + False + ..\..\..\Users\yordanova\Desktop\DLL\Telerik_UI_For_WinForms_2014_1_14_226_Dev_hotfix\Bin\Telerik.WinControls.GridView.dll + + + False + ..\..\..\Users\yordanova\Desktop\DLL\Telerik_UI_For_WinForms_2014_1_14_226_Dev_hotfix\Bin\Telerik.WinControls.UI.dll + + + False + ..\..\..\Users\yordanova\Desktop\DLL\Telerik_UI_For_WinForms_2014_1_14_226_Dev_hotfix\Bin\Telerik.WinControls.UI.Design.dll + + + False + ..\..\..\Users\yordanova\Desktop\DLL\Telerik_UI_For_WinForms_2014_1_14_226_Dev_hotfix\Bin\TelerikCommon.dll + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + Microsoft .NET Framework 4 Client Profile %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 3.1 + true + + + + + \ No newline at end of file