How to make a multicolumn listbox in C# and VB.NET

To make a multicolumn listbox in C# and VB.NET you can use the following snippet.
First you need to add the Columns to the Listview.

multicolumnslistviewcsharp_add

Adding columns to the Listview

Sample C#

listView1.Items.Add("Column1Text").SubItems.AddRange(new string[] { "col1;row1", "col2;row1", "col3;row1" });
listView1.Items.Add("Column2Text").SubItems.AddRange(new string[] { "col1;row2", "col2;row2", "col3;row2" });
listView1.Items.Add("Column3Text").SubItems.AddRange(new string[] { "col1;row3", "col2;row3", "col3;row3" });

Sample VB.NET

listView1.Items.Add("Column1Text").SubItems.AddRange(New String() {"col1;row1", "col2;row1", "col3;row1"})
listView1.Items.Add("Column2Text").SubItems.AddRange(New String() {"col1;row2", "col2;row2", "col3;row2"})
listView1.Items.Add("Column3Text").SubItems.AddRange(New String() {"col1;row3", "col2;row3", "col3;row3"})
multicolumnslistviewcsharp

Result: Listview with Multiple Columns

Please rate this snippet

How to hide the status bar while Splashscreen is Shown in IOS

To hide the status bar while Splashscreen is Shown in IOS follow these Steps.

  • 1. Open the Info.plist File.
  • 2. Search for the “Status bar is initially hidden” property and set it to checked.
  • if you do not have the “Status bar is initially hidden” property, simply add it by selecting the last line in the File and then click the plus button on the right end of the line.

    To show the status bar you can use this snippet.

    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; //UIStatusBarAnimationNone, UIStatusBarAnimationFade or UIStatusBarAnimationSlide
    

    Please rate this snippet

    How to reload or rerender the page using AngularJS

    To reload or rerender the page using AngularJS you can use the snippet below.

    Sample AngularJS

    $route.reload();
    

    Please rate this snippet

    How to define global Variables in AngularJs

    To define global Variables in AngularJs you can use one of the following ways.

    WAY1: Using $rootScope (see this JsFiddle)

    HTML:

    <div ng-controller="Testfct2">
        <div ng-controller="Testfct">This Website URL is {{name}}!</div>
    </div>
    

    Javascript:

    var myApp = angular.module('myFesslersoftSampleApp',[]);
    
    function Testfct2($scope, $rootScope) {
        $rootScope.name = 'http://codesnippets.fesslersoft.de';
    }
    
    function Testfct($scope, $rootScope) {
        $scope.name = $rootScope.name;
    }
    

    WAY2: Using a Service (see this JsFiddle)

    HTML:

    <div ng-controller="Testfct">
      This Website URL is {{name}}!
    </div>
    

    Javascript:

    var myApp = angular.module('myFesslersoftSampleApp',[]);
    myApp.factory('GlobalVarsService', function() {
        return {
            name : 'http://codesnippets.fesslersoft.de'
        };
    });
    
    function Testfct($scope, GlobalVarsService) {
        $scope.name = GlobalVarsService.name;
    }
    

    The AngularFAQ is saying:

    $rootScope exists, but it can be used for evil
    Scopes in Angular form a hierarchy, prototypally inheriting from a root scope at the top of the tree. Usually this can be ignored, since most views have a controller, and therefore a scope, of their own.

    Occasionally there are pieces of data that you want to make global to the whole app. For these, you can inject $rootScope and set values on it like any other scope. Since the scopes inherit from the root scope, these values will be available to the expressions attached to directives like ng-show just like values on your local $scope.

    Of course, global state sucks and you should use $rootScope sparingly, like you would (hopefully) use with global variables in any language. In particular, don’t use it for code, only data. If you’re tempted to put a function on $rootScope, it’s almost always better to put it in a service that can be injected where it’s needed, and more easily tested.

    Conversely, don’t create a service whose only purpose in life is to store and return bits of data.

    FOR MORE INFORMATIONS SEE Services, $rootScope

    Please rate this snippet

    How to use DebuggerDisplayAttribute in C# and VB.NET

    If you want to change the information, the debugger variable window shows for your class, you can use the DebuggerDisplayAttribute.
    Simply put the Attribut above your class declaration. The Value between {} are the name of the property or Field you want to show.

    Sample C#

    [DebuggerDisplay("Name = {Name}, Value = {Value}")]
    

    Sample VB.NET

    <DebuggerDisplay("Name = {Name}, Value = {Value}")>
    

    Result

    DebuggerDisplayAttribute

    for more informations see the DebuggerDisplayAttribute Class MSDN Entry

    Please rate this snippet

    How to scroll to the end of a TreeView in C# and VB.NET

    To scroll to the end of a TreeView in C# and VB.NET you can use the following snippet.

    Sample VB.NET / C#

    treeView1.Nodes[treeView1.Nodes.Count - 1].EnsureVisible();
    

    Please rate this snippet

    How to scroll to the end of a listview in C# and VB.NET

    To scroll to the end of a listview in C# and VB.NET you can use the following snippet.

    Sample C# / VB.NET

    listView1.EnsureVisible(listView1.Items.Count - 1);
    

    Please rate this snippet

    How to list all views in database in MSSQL

    To list all views in database in MSSQL you can use the following snippet.

    Sample MSSQL

    SELECT SCHEMA_NAME(schema_id) AS [schema],name AS [viewname] ,OBJECTPROPERTYEX(OBJECT_ID,'IsIndexed') AS [IsIndexed] ,OBJECTPROPERTYEX(OBJECT_ID,'IsIndexable') AS [IsIndexable], * FROM sys.views;
    

    Please rate this snippet