From this article you can learn how to resize description area in PropertyGrid. Example shows use of reflection in order to dig to private members of PropertyGrid - not accessible in normal way.
Implementation is available both in C# and VB.Net languages. Use buttons below to switch language visibility.
Implementation
System.Reflection namespace needs to be put in usings.
privatestaticvoid ChangeDescriptionHeight(PropertyGrid grid, int height){if(grid ==null)thrownew ArgumentNullException("grid");foreach(Control control in grid.Controls)if(control.GetType().Name=="DocComment"){
FieldInfo fieldInfo = control.GetType().BaseType.GetField("userSized",
BindingFlags.Instance|
BindingFlags.NonPublic);
fieldInfo.SetValue(control, true);
control.Height= height;return;}}
PrivateSharedSub ChangeDescriptionHeight(grid As PropertyGrid, height AsInteger)If grid IsNothingThenThrowNew ArgumentNullException("grid")EndIfForEach control As Control In grid.ControlsIf control.[GetType]().Name="DocComment"ThenDim fieldInfo As FieldInfo = control.[GetType]().BaseType.GetField("userSized",
BindingFlags.Instance Or BindingFlags.NonPublic)
fieldInfo.SetValue(control, True)
control.Height= height
ReturnEndIfNextEndSub
Here you can learn about finding the exact regular expression match using SQL query in Oracle. Article is made upon examples so you will be on the right track in no time.
Usually when we want to search Oracle database users table via regular expressions by email domain filter, it's easy:
SELECT*FROM users
WHERE regexp_like(mail,'@gmail\.com');
the above query will return all users which have an email in @gmail.com domain.
But lets say that we want to be more specific and we want to search the database for users whose name is John and last name is starting with "B". For this example, lets assume that some users email address format is "firstname.lastname@gmail.com".
If we use this statement:
SELECT*FROM users
WHERE regexp_like(mail,'john\.b[a-zA-Z]*@gmail\.com');
some of the results will be what we want but a lot will be just a trash pile. This statement will return users with emails like "mark.john.bradley@gmail.com" or "john.thebadboy@gmail.com.uk". Why? Because regexp_like function checks if the given string contains a substring that matches our regular expression and NOT if the entire string matches the regular expression.
The solution to this problem i very simple. We must add two special characters. One, ^ (caret), at the beginning and the other, $ (dollar), at the end of our regular expression.
Quick explanation: ^ (caret) - means that the string starts with regular expression pattern. $ (dollar) - means that the string ends with regular expression pattern.
Knowing this correct statement should look like this:
SELECT*FROM users
WHERE regexp_like(mail,'^john\.b[a-zA-Z]*@gmail\.com$');
Visit project summary page to get more details about general features.
PS3Merge in this release connects to Karmian Update Service on application startup. Keeping all features and bug fixes up to date is necessary in our opinion.
Give PS3Merge a try to see what it's really capable of!
From this article you can learn how to define and use simple helper. Example shows generic methods returning list of any type of Attribute from Assembly. AssemblyHelper class can be easily extended with further functionalities as needed.
Implementation and examples are available both in C# and VB.Net languages.
Implementation
Below you can find implementation we use in Karmian Framework as Assembly helper. All members in AssemblyHelper class should be marked as static, so no instance is needed to invoke any. Class AssemblyHelper itself is marked as sealed as we do not want to allow any inheritance. If you need to add new functionality that supports the Assembly - it should be implemented in the class AssemblyHelper. This approach allows the system to prevent duplication of helpers that are responsible for similar actions.
If you don't like to read how things work and instead you like to watch how it's done we have found some videos on PS3Splitter usage. We hope that the videos posted here will lift your dilemmas on basic questions with a series of 'how to'. Also if you know about some interesting article/tutorial about PS3Splitter please share it with us!
From this article you can learn how to define and use enum description type converter so sytem will know how to handle enum to string and string to enum values (very helpful in PropertyGrid for example).
Implementation is available both in C# and VB.Net languages.
Implementation
Below you can find implementation we use in Karmian Framework as enum description type converter. It can be easily extended to work also as localizable enum description type converter - Description attribute can be used as a key of localized resource.
EnumDescriptionTypeConverter class
usingSystem;usingSystem.ComponentModel;usingSystem.Globalization;namespace Karmian.Core.TypeConverters{publicclass EnumDescriptionTypeConverter : EnumConverter
{public EnumDescriptionTypeConverter(Type type):base(type){}publicoverridebool CanConvertFrom(ITypeDescriptorContext context, Type sourceType){return sourceType ==typeof(string)|| TypeDescriptor.GetConverter(typeof(Enum)).CanConvertFrom(context, sourceType);}publicoverrideobject ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value){if(value isstring)return GetEnumValue(EnumType, (string) value);if(value isEnum)return GetEnumDescription((Enum) value);returnbase.ConvertFrom(context, culture, value);}publicoverrideobject ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType){return value isEnum&& destinationType ==typeof(string)? GetEnumDescription((Enum)value):(value isstring&& destinationType ==typeof(string)? GetEnumDescription(EnumType, (string)value):base.ConvertTo(context, culture, value, destinationType));}publicstaticstring GetEnumDescription(Enum value){
var fieldInfo = value.GetType().GetField(value.ToString());
var attributes =(DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);return(attributes.Length>0)? attributes[0].Description: value.ToString();}publicstaticstring GetEnumDescription(Type value, string name){
var fieldInfo = value.GetField(name);
var attributes =(DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);return(attributes.Length>0)? attributes[0].Description: name;}publicstaticobject GetEnumValue(Type value, string description){
var fields = value.GetFields();foreach(var fieldInfo in fields){
var attributes =(DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);if(attributes.Length>0&& attributes[0].Description== description)return fieldInfo.GetValue(fieldInfo.Name);if(fieldInfo.Name== description)return fieldInfo.GetValue(fieldInfo.Name);}return description;}}}
Imports System.ComponentModelImports System.GlobalizationNamespace Karmian.Core.TypeConvertersPublicClass EnumDescriptionTypeConverter
Inherits EnumConverter
PublicSubNew(type As Type)MyBase.New(type)EndSubPublicOverridesFunction CanConvertFrom(context As ITypeDescriptorContext, sourceType As Type)AsBooleanReturn sourceType IsGetType(String) OrElse TypeDescriptor.GetConverter(GetType([Enum])).CanConvertFrom(context, sourceType)EndFunctionPublicOverridesFunction ConvertFrom(context As ITypeDescriptorContext, culture As CultureInfo, value AsObject)AsObjectIf TypeOf value IsStringThenReturn GetEnumValue(EnumType, DirectCast(value, String))EndIfIf TypeOf value Is[Enum]ThenReturn GetEnumDescription(DirectCast(value, [Enum]))EndIfReturnMyBase.ConvertFrom(context, culture, value)EndFunctionPublicOverridesFunction ConvertTo(context As ITypeDescriptorContext, culture As CultureInfo, value AsObject, destinationType As Type)AsObjectReturnIf(TypeOf value Is[Enum]AndAlso destinationType IsGetType(String), GetEnumDescription(DirectCast(value, [Enum])), (If(TypeOf value IsStringAndAlso destinationType IsGetType(String), GetEnumDescription(EnumType, DirectCast(value, String)), MyBase.ConvertTo(context, culture, value, destinationType))))EndFunctionPublicSharedFunction GetEnumDescription(value As[Enum])AsStringDim fieldInfo = value.[GetType]().GetField(value.ToString())Dim attributes = DirectCast(fieldInfo.GetCustomAttributes(GetType(DescriptionAttribute), False), DescriptionAttribute())ReturnIf((attributes.Length > 0), attributes(0).Description, value.ToString())EndFunctionPublicSharedFunction GetEnumDescription(value As Type, name AsString)AsStringDim fieldInfo = value.GetField(name)Dim attributes = DirectCast(fieldInfo.GetCustomAttributes(GetType(DescriptionAttribute), False), DescriptionAttribute())ReturnIf((attributes.Length > 0), attributes(0).Description, name)EndFunctionPublicSharedFunction GetEnumValue(value As Type, description AsString)AsObjectDim fields = value.GetFields()ForEach fieldInfo As FieldInfo In fields
Dim attributes = DirectCast(fieldInfo.GetCustomAttributes(GetType(DescriptionAttribute), False), DescriptionAttribute())If attributes.Length > 0AndAlso attributes(0).Description= description ThenReturn fieldInfo.GetValue(fieldInfo.Name)EndIfIf fieldInfo.Name= description ThenReturn fieldInfo.GetValue(fieldInfo.Name)EndIfNextReturn description
EndFunctionEndClassEndNamespace
We would like to cover the costs of maintaining the server for longer than a year.
We would like to extend our development environment with some commercial products.
We would like to get rid of the ads from our site.
We would like to take over Karmian.com in order to unify Karmian.
But most of all - we want to provide more free solutions, therefore consider pressing the button below as the absolute expression of your own will and... mood. ;)