How to read a String to Textreader using C# and VB.NET

To read a String to Textreader using C# and VB.NET you can use the snippet below.

Sample C#

using(TextReader textReader = new StringReader("string"))
{
    //...
}

Sample VB.NET

Using textReader As TextReader = New StringReader("string")
    '...
End Using

Please rate this snippet

How to manually populate a multicolumn devexpress TreeList using C# and VB.NET

To manually populate a multicolumn devexpress TreeList using C# and VB.NET you can use the snippet below.

Sample C#

using System;
using System.Collections.Generic;
using DevExpress.XtraEditors;

namespace de.Fesslersoft.MultiColumnTreeList
{
    public partial class Form1 : XtraForm
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            var products = new List<ProductInfo>
            {
                new ProductInfo() {name = "Item1", desc = "Description1", price = Decimal.Zero}, 
                new ProductInfo() {name = "Item2", desc = "Description2", price = 3.0m}, 
                new ProductInfo() {name = "Item3", desc = "Description3", price = 5.45m}, 
                new ProductInfo() {name = "Item4", desc = "Description4", price = 12.32m}
            };


            foreach (var product in products)
            {
                var node = treeList1.AppendNode(null, null);
                node.SetValue(0, product.name);
                node.SetValue(1, product.desc);
                node.SetValue(2, product.price);
            }
        }
    }
    public class ProductInfo
    {
        public string name { get; set; }
        public string desc { get; set; }
        public decimal price { get; set; }
    }
}

Sample VB.NET

Imports System.Collections.Generic
Imports DevExpress.XtraEditors

Namespace de.Fesslersoft.MultiColumnTreeList
	Public Partial Class Form1
		Inherits XtraForm
		Public Sub New()
			InitializeComponent()
		End Sub

		Private Sub Form1_Load(sender As Object, e As EventArgs)
			Dim products = New List(Of ProductInfo)() From { _
				New ProductInfo() With { _
					Key .name = "Item1", _
					Key .desc = "Description1", _
					Key .price = [Decimal].Zero _
				}, _
				New ProductInfo() With { _
					Key .name = "Item2", _
					Key .desc = "Description2", _
					Key .price = 3.0D _
				}, _
				New ProductInfo() With { _
					Key .name = "Item3", _
					Key .desc = "Description3", _
					Key .price = 5.45D _
				}, _
				New ProductInfo() With { _
					Key .name = "Item4", _
					Key .desc = "Description4", _
					Key .price = 12.32D _
				} _
			}


			For Each product As var In products
				Dim node = treeList1.AppendNode(Nothing, Nothing)
				node.SetValue(0, product.name)
				node.SetValue(1, product.desc)
				node.SetValue(2, product.price)
			Next
		End Sub
	End Class
	Public Class ProductInfo
		Public Property name() As String
			Get
				Return m_name
			End Get
			Set
				m_name = Value
			End Set
		End Property
		Private m_name As String
		Public Property desc() As String
			Get
				Return m_desc
			End Get
			Set
				m_desc = Value
			End Set
		End Property
		Private m_desc As String
		Public Property price() As Decimal
			Get
				Return m_price
			End Get
			Set
				m_price = Value
			End Set
		End Property
		Private m_price As Decimal
	End Class
End Namespace

Please rate this snippet

How to drop Primary Key of a Table using MSSQL

To drop Primary Key of a Table using MSSQL you can use the snippet below.

Sample MSSQL

ALTER TABLE tblTest
DROP CONSTRAINT PK_tblTest
GO

Please rate this snippet

How to download a file using Python

To download a file using Python you can use the snippet below.

Sample Python

import urllib.request
import shutil

# file_name = target file name
with urllib.request.urlopen(url) as response, open(file_name, 'wb') as out_file:
    shutil.copyfileobj(response, out_file)

Please rate this snippet

How to search stored procedures using MS-SQL

To search stored procedures using MS-SQL you can use the snippet below.

Sample MSSQL

SELECT Name FROM sys.procedures WHERE name LIKE '%StoredProcName%'

Please rate this snippet

Top 10 reads of March 2015

These are the Top 10 reads of March 2015.

  • How to add or remove a class on hover using jQuery
  • How to use the HTML5 datalist tag
  • How to reload a ViewController in IOS using Objective-C
  • How to get current Domain of the PC in C# and VB.NET
  • What is the difference between typeof(), GetType() and IS in C# and VB.NET
  • How to split a delimited string to multiple rows using MSSQL
  • How to deep copy a IList in C# and VB.NET
  • How to make a multicolumn listbox in C# and VB.NET
  • How to open a Website in the default Browser in C# and VB.NET
  • How to delete .svn files and folders using Windows Batch Script
  • thanks to all visitors, bookmark us, share us, talk about us, Follow us!, Like us! let’s grow bigger!

    Please rate this snippet