Posts

Showing posts from July, 2016

NuGet - Check Combo Box

Step 1:  Get the NuGet package https://www.nuget.org/packages/Common.CheckComboBox/ Step 2: Add the CheckComboBox Control in the toolbar. Click here Step 3: Drag the "CheckedComboBox" control from the toolbar to the form to the position where it should be placed   Step 4: Add items to the CheckedComboBox control by        for (int i = 0; i < 10; i++)             {                 checkedComboBox1.Items.Add(i);             }

How to get the list of properties of a class?

public List<string> GetPropertiesNameFromClass(object pObject) { List<string> propertyList = new List<string>(); if (pObject != null) { foreach (var prop in pObject.GetType().GetProperties()) { propertyList.Add(prop.Name); } } return propertyList; } public static Dictionary<string, object> GetPropertDictionaryFromClass(object pObject) { if (pObject == null) return new Dictionary<string, object>(); Type t = pObject.GetType(); PropertyInfo[] props = t.GetProperties(); Dictionary<string, object> dict = new Dictionary<string, object>(); foreach (PropertyInfo prp in props) { object value = prp.GetValue(pObject, new object[] { }); dict.Add(prp.Name, value); } return dic...

Convert byte array to Image and Image to byte array

Convert Image to byte[] array: public byte [] imageToByteArray(System.Drawing.Image imageIn) { MemoryStream ms = new MemoryStream(); imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif); return ms.ToArray(); } Convert byte[] array to Image : public Image byteArrayToImage( byte [] byteArrayIn) { MemoryStream ms = new MemoryStream(byteArrayIn); Image returnImage = Image.FromStream(ms); return returnImage; }