How to select a item on rightclick using devexpress ListboxControl

To select a item on rightclick using devexpress ListboxControl you need to use the MouseDown Event.
See the samples below.

Sample C#

private void listBoxControl1_MouseDown(object sender, MouseEventArgs e)
{
	listBoxControl1.SelectedIndex = listBoxControl1.IndexFromPoint(new Point(e.X, e.Y));
}

Sample VB.NET

Private Sub listBoxControl1_MouseDown(sender As Object, e As MouseEventArgs)
	listBoxControl1.SelectedIndex = listBoxControl1.IndexFromPoint(New Point(e.X, e.Y))
End Sub

Please rate this snippet

How to remove an element using Javascript

To remove an element using javascript, you can use one of the following snippets.

Sample Javascript

//usage document.getElementById("ElementId").remove();
Element.prototype.remove = function() {
	this.parentElement.removeChild(this);
}

Sample Javascript

//usage document.getElementsByClassName("Elements").remove();
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
	for(var index = 0, length = this.length; index < length; index++) {
		if(this[index] && this[index].parentElement) {
			this[index].parentElement.removeChild(this[index]);
		}
	}
}

removeChild() is the only method supported by the DOM to remove a element in Javascript (see -> Mozilla MDN Node.removeChild()).

Please rate this snippet

How to delete a file or folder in Powershell

To delete a file or Folder in Powershell you can use the following snippet.

Sample Powershell

if you want to delete a file use

remove-item -path "C:\Users\Codesnippets\Desktop\Test.xml" -force -recurse

if you want to delete a folder use

remove-item -path "C:\Users\Codesnippets\Desktop\Folder1" -force -recurse

for more informations see Using the Remove-Item Cmdlet

Please rate this snippet

IndexOf method for Javascript

With the snippet below you can use the IndexOf method for Javascript.

Sample JS

Array.prototype.IndexOf = Array.prototype.IndexOf || function (element) {
    for (var i=0; i < this.length; i++) {
        if(this[i] === element) return i;
    }
    return -1;
};

Please rate this snippet

How to check if array contains string case insensitive in PHP

To check if array contains string case insensitive in PHP you can use the following snippet.

function ArrayContainsStringCaseInsensitve($searchString, $array){
    foreach($array as $element){
        if(strcasecmp($searchString, $element)==0){
            return true;
        }
    }
    return false;
}

Please rate this snippet