Angular 2 Pipe to filter array of strings with provided search string

In This Article, we will create a new Pipe for filtering array of strings with provided search/filter string.



Increasing Nuget Package Update ( Resolving Dependencies) speed

Recently I worked on a big project with lots of nuget packages installed and was trying to update and consolidate packages in many projects under one solution. And I noticed that the nuget update process was quite slow.



Angular2 Pagination Component with Bootstrap

I recently started learning Angular2 and I am loving it.  This article describes how to create a basic pagination component using bootstrap pagination.



SQLite and Entity Framework using Visual Studio 2015 ( .NET 4.6) : Model first approach

This tutorial demonstrates how to use Entity Framework 6.0 to Insert, Update and Delete from SQLite database with Model first approach.



Using SQLite with

This tutorial covers how to use Sqlite database using c#.

What is SQLITE?
SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. The code for SQLite is in the public domain and is thus free for use for any purpose, commercial or private. SQLite is the most widely deployed database in the world with more applications than we can count, including several high-profile projects.



Automatic ListView Grouping

Lets say you have lots of data your listview. Now you want to Group This data According to a Particular Subitem.

For Example:

Suppose i have some books data in my ListView.
this listview items contains Author name and Books Title.

And there are 2000 Books in list view.

Now i want to group the data in listview according to the Authors.

Now lets say there are 50 Unique Authors , meaning we will have to create 50 Groups in listview.

this seem hectic, and i don’t know if there is any inbuilt function to automatically group this items, but i have created mine To automatically do the above.

Hope it becomes useful to someone.

public void GroupListView(ListView lstV, int SubItemIndex) {
 bool flag = true;

 foreach(ListViewItem l in lstV.Items) {
  string strmyGroupname = l.SubItems[SubItemIndex].Text;

  foreach(ListViewGroup lvg in lstV.Groups) {
   if (lvg.Name == strmyGroupname) {
    l.Group = lvg;
    flag = false;

  if (flag == true) {
   ListViewGroup lstGrp = new ListViewGroup(strmyGroupname, strmyGroupname);
   l.Group = lstGrp;

  flag = true;

How To Use The Code:
Lets say the author’s sub item’s index is 1 and listview name is LstBooks then call the function like:

GroupListView(LstBooks,1); Version:

Public Sub GroupListView(ByVal lstV As ListView, ByVal SubItemIndex As Int16)
Dim flag As Boolean = True
For Each l As ListViewItem In lstV.Items

Dim strmyGroupname As String = l.SubItems(SubItemIndex).Text

For Each lvg As ListViewGroup In lstV.Groups

If lvg.Name = strmyGroupname Then
l.Group = lvg
flag = False
End If


If flag = True Then
Dim lstGrp As New ListViewGroup(strmyGroupname, strmyGroupname)
l.Group = lstGrp
End If

flag = True

End Sub




Auto Increment Invoice Number For

Let’s say you have some invoice numbers which contains Alphabets as well as numeric number.
And you want to increment it one by one.
For Example:

if Invoice number is “AZ99999999” then Next Invoice Number will be “BA00000001”

Notice here that , the invoice number’s length is 10 Characters out of which first 2 are Alphabets and the rest (8) are Numeric. invoice number can be of any digit with any combination of numeric and alphabets.

The function can be changed to your need very easily. but here i will demonstrate for the above example.


Public Function IncrementInvoice(ByVal strInvoiceNumber As String) As String

If strInvoiceNumber.Length <> 10 Then
Return "Error"
End If

Dim strAlphaPart(1) As Char
strAlphaPart(0) = strInvoiceNumber(0)
strAlphaPart(1) = strInvoiceNumber(1)

Dim IntPart As Int64
IntPart = strInvoiceNumber.Substring(2, 8)
If IntPart = 99999999 Then
If strAlphaPart(1) = "Z" Then
strAlphaPart(0) = Chr(Asc(strAlphaPart(0)) + 1)
strAlphaPart(1) = "A"

IntPart = 1

Return strAlphaPart(0) & strAlphaPart(1) & IntPart.ToString.PadLeft(8, "0")
strAlphaPart(1) = Chr(Asc(strAlphaPart(1)) + 1)
End If

IntPart += 1
Return strAlphaPart(0) & strAlphaPart(1) & IntPart.ToString.PadLeft(8, "0")
End If

End Function


‘outputs example:
strTemp = IncrementInvoice(“AA99999998”) ‘Output will be: “AA99999999”
strTemp = IncrementInvoice(“AA00000005”) ‘Output will be: “AA00000006”
strTemp = IncrementInvoice(“AZ00000007”) ‘Output will be: “AZ00000008”
strTemp = IncrementInvoice(“AZ99999999”) ‘Output will be: “BA00000001”


Dataset To Excel Export Function

The Function:

Public Sub ExportDatasetToExcel(ByVal ds As DataSet, ByVal strExcelFile As String)

    Dim conn As New OleDbConnection(String.Format("provider=Microsoft.Jet.OLEDB.4.0; Data Source='{0}';" & "Extended Properties='Excel 8.0;HDR=YES;'", strExcelFile))

    Dim strTableQ(ds.Tables.Count) As String

    Dim i As Integer = 0

    'making table query
    For i = 0 To ds.Tables.Count - 1

        strTableQ(i) = "CREATE TABLE [" & ds.Tables(i).TableName & "]("

        Dim j As Integer = 0
        For j = 0 To ds.Tables(i).Columns.Count - 1
            Dim dCol As DataColumn
            dCol = ds.Tables(i).Columns(j)
            strTableQ(i) &= " [" & dCol.ColumnName & "] varchar(255) , "
        strTableQ(i) = strTableQ(i).Substring(0, strTableQ(i).Length - 2)
        strTableQ(i) &= ")"

        Dim cmd As New OleDbCommand(strTableQ(i), conn)


    'making insert query
    Dim strInsertQ(ds.Tables.Count - 1) As String
    For i = 0 To ds.Tables.Count - 1
        strInsertQ(i) = "Insert Into " & ds.Tables(i).TableName & " Values ("
        For k As Integer = 0 To ds.Tables(i).Columns.Count - 1
            strInsertQ(i) &= "@" & ds.Tables(i).Columns(k).ColumnName & " , "
        strInsertQ(i) = strInsertQ(i).Substring(0, strInsertQ(i).Length - 2)
        strInsertQ(i) &= ")"

    'Now inserting data
    For i = 0 To ds.Tables.Count - 1
        For j As Integer = 0 To ds.Tables(i).Rows.Count - 1
            Dim cmd As New OleDbCommand(strInsertQ(i), conn)
            For k As Integer = 0 To ds.Tables(i).Columns.Count - 1
                cmd.Parameters.AddWithValue("@" & ds.Tables(i).Columns(k).ColumnName.ToString(), ds.Tables(i).Rows(j)(k).ToString())

End Sub

Let’s say i have my.xls in D drive. i want to export a Dataset Name dsFinal to this excel file.

ExportDatasetToExcel(dsFinal, “d:\my.xls”)


Listing Running Processes in

1. Add List box on a Forms.
2. Now add a reference to System.Diagnostics


Process[] curProcesses = Process.GetProcesses();

foreach (Process p in curProcesses)




A simple Class for Moving Controls At Runtime

Here Is The Class:

using System;
using System.Drawing;
using System.Windows.Forms;

namespace MoveControl
sealed class clsMoveControl
public enum Direction

public static void StartMoving(Control cntrl)
StartMoving(cntrl, Direction.Any);

public static void StartMoving(Control cntrl, Direction dir)
StartMoving(cntrl, cntrl, dir);

public static void StartMoving(Control cntrl, Control container, Direction dir)
bool Dragging = false;
Point DragStart = Point.Empty;
cntrl.MouseDown += delegate(object sender, MouseEventArgs e)
Dragging = true;
DragStart = new Point(e.X, e.Y);
cntrl.Capture = true;
cntrl.MouseUp += delegate(object sender, MouseEventArgs e)
Dragging = false;
cntrl.Capture = false;
cntrl.MouseMove += delegate(object sender, MouseEventArgs e)
if (Dragging)
if (dir != Direction.Vertical)
container.Left = Math.Max(0, e.X + container.Left - DragStart.X);
if (dir != Direction.Horizontal)
container.Top = Math.Max(0, e.Y + container.Top - DragStart.Y);

How to Use Example :

1. Create a simple project .
2. On the load event of the form write the following coding


This will make the form movable by clicking anywhare on the form and dragging it.
The same can be done for other controls like:


See it Live:

%d bloggers like this: