C# Tutorials
How do I declare an image property in the ORM Data Model Designer
See step by step solution at DevExpress.com |
ObjectClassInfo of XPCollection component does not show available XPO objects from referenced assembly
I have a WinForm on which I drag an XPCollection component. A separate Class Library project contains all my XPO objects. This class library is referenced by the WinForm application. The ObjectClassInfo of the XPCollection component allows me to choose which type of object the collection contains. The dropdown in the property editor does not list my XPO objects from the class library. How can I make them available in the dropdown? Solution The XPCollection lists classes from the compiled project. You should use any class of your referenced assembly in your project, e.g. declare a variable of your persistent object, and rebuild your project. Then reopen the form designer with your XPCollection component. Now you can select persistent classes declared in your assembly for the ObjectClassInfo property via the Property Window. |
DevExpress XPO Data Model Image Field
I am using the Data Model Xpo Data Model Designer, I need to store images in the Database, what is the field type for this case? Solution To accomplish this task, create a property of the ByteArray type and apply the [DevExpress.Xpo.ValueConverter(typeof(DevExpress.Xpo.Metadata.ImageValueConverter))] attribute to it via the designer's Custom Attributes property. See Also: |
Trap Enter Key
private void txtTextbox_KeyPress(object sender, EventArgs e) { //Trap the enter key string info = e.KeyChar.ToString(); if (info == "\r") { //Your code here //This signals the event that you have managed the outcome e.Handled = true; } } |
Common Mask for DevExpress TextEdit Control
Simple Mask Type: Phone - (999) 000-0000 RegEx Mask Type: Email - [a-zA-Z0-9.-]+@[a-zA-Z0-9-]+\.[A-Za-z]{2,} |
How to use CSLA NameList
using System; using Csla; using System.Data.SqlClient; using System.Data; using Csla.Data; namespace CSLASample.NameList { [Serializable] public class FindItemCollection : NameValueListBase<string, string> { #region Factory Methods private static FindItemCollection _list; public static FindItemCollection GetFindItemCollection() { if (_list == null) _list = DataPortal.Fetch<FindItemCollection>(); return _list; } public static void InvalidateCache() { _list = null; } private FindItemCollection() { /* require use of factory methods */ } #endregion #region Data Access private void DataPortal_Fetch() { RaiseListChangedEvents = false; IsReadOnly = false; //Load Values using (SqlConnection cn = new SqlConnection(Database.Connection)) { cn.Open(); using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getFindItemList"; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { while (dr.Read()) { Add(new NameValueListBase<string, string>.NameValuePair( dr.GetString("IMA_ItemID"), dr.GetString("IMA_ItemName"))); } } } } IsReadOnly = true; RaiseListChangedEvents = true; } #endregion } } |
Restrict textbox to numeric only
Instructions: Place the code below into a KeyPress event for the textbox you wish to restrict Code Snippet: //The first "if" statement is for numeric only. The second section "else if" allows one decimal place. //You may leave off the "else if" if you do not wish to allow a decimal. if (char.IsNumber(e.KeyChar) || char.IsControl(e.KeyChar)) { //Allow } else if (e.KeyChar == Convert.ToChar(".") && textbox1.Text.IndexOf(".") == -1) { //Allow } else { e.Handled = true; } |