Archive for the Category development

 
 

Validating properties in a PropertyGrid control

The easiest way to validate a certain property is using the PropertyValueChanged event.The code bellow shows how to limit the valid range of Age property to be 1-150

using System.Windows.Forms; 
namespace WindowsApplication1 
{ 
    public partial class Form1 : Form 
    { 
        public Form1() 
        { 
            InitializeComponent(); 
            //init person object  
            Person person = new Person(); 
            person.FirstName = "George"; 
            person.Age = 33; 
            propertyGrid.SelectedObject = person; 
            propertyGrid.PropertyValueChanged+=  new PropertyValueChangedEventHandler( propertyGrid_PropertyValueChanged ); 
        } 
 
        private void propertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) 
        { 
            if (e.ChangedItem.Label == "Age" && !IsAgeValid((int)e.ChangedItem.Value) ) 
            { 
                // the entered age value is wrong - show error message 
                e.ChangedItem.PropertyDescriptor.SetValue( propertyGrid.SelectedObject, e.OldValue); 
                MessageBox.Show("Wrong age", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 
            } 
        } 
 
        ///<summary>
        /// Determines whether age is valid 
        /// </summary>  
        /// <param name="age">The age.</param>  
        /// <returns>  
        /// <c>true</c> if is age valid ; otherwise, <c>false</c>. 
        /// </returns>  
        private static bool IsAgeValid( int age ) 
        { 
            return ((age > 0) && (age < 150)); 
        } 
    } 
}

 

Technorati tags: propertygrid, dotnet, programming

Interesting blog posts

Jon Galloway – Google Personalized Homepage (IG) – Read a post inline

David Hayden – Validation Application Block Presentation and New Features – Enterprise Library 3.0

ScottGu’s Blog – ASP.NET AJAX 1.0 Released

Dmitryr’s blog – Finding out the current trust level in ASP.NET

Michael’s Blog – Transforms, Opacity Masks and Animation to Create an Animated Reflection in WPF/E

 

Technorati tags: blogging, programming, c#, asp.net

The second CTP of Enterprise Library 3.0 is now available to download

Tom Hollander has posted that the second CTP of Enterprise Library 3.0 is now available to download on CodePlex community site.

New In This Release

  • Validation Application Block
    • Near-complete validator library
    • Configuration tool support
    • ASP.NET integration
    • Winforms integration
    • Quickstarts and preliminary documentation
  • Data Access Application Block
    • TransactionScope enlistment
  • Logging Application Block
    • Rolling Flat File Trace Listener
    • WCF integration
  • Application Block Software Factory
    • VB code generation
  • Configuration Tool
    • Selectable assembly sets

 

Technorati tags: dotnet, c#, development, library

Object Relational Mapping and persistence framework for .NET 2.0

DataBlock is a Object Relational Mapping and persistence framework for .NET 2.0.When working with DataBlock your job should be to create business object that handle the specific business issues instead of writing SQL, juggling with ADO.NET objects or making sure that a specific piece of code is running in a transaction.

DataBlock comes with DataBlock Modeler, a GUI tool which makes mapping objects a few seconds job.

DataBlock is a open source project released under the GPL license.You can include a binary copy of DataBlock in a commercial project.

Features

  • The generated code works without modifications on MS Access, Sql Server, MySql and PostgreSQL .
  • Supports any CLI 2.0 compliant language
  • Supports 1:1, 1:m and m:m relations
  • It doesn’t require any special constructs in your relational model nor extra tables or columns. No locks are hold/set at runtime or during a transaction, other then the locks set by the RDBMS itself. All mapping data is contained in memory at runtime.
  • Easily generate code using the DataBlock Modeler tool.
  • Supports reading/creating/deleting/updating of single and graphs of objects
  • All entity classes are based on lightweight custom classes, not on datasets or datatables.
  • The code is grouped using the Domain Driven pattern which isolates every entity.
  • The QueryCriteria API allows you to model, in an OOP way, SQL queries.
  • Powerful data access layer which works in both connected and disconnected mode
  • By default the DataBlock Framework is using “stronged referenced” providers but it can be easily changed (thru the configuration file) to use a new provider
  • No external xml mapping files
  • Support for running stored procedures and interoperation with already written ADO.NET code
  • Support for long running transactions

Download DataBlock

[Via Larkware News]

Technorati tags: ORM, dotnet, database

How the design time infrastructure works

If you are not familiar with the DataSourceControls and if you don’t know how the design time infrastructure works, take a look to the following articles:

 

Technorati tags: DataSourceControls, dotnet, c#, data


Page 13 of 37« First...1112131415...2030...Last »