Serialcoder en Français Serialcoder in English
TEL : +33 (0)8 77 91 48 38

How to make a Right click to select a ListViewItem in a Windows Forms ListView (C#)

It is the normal behavior on windows, but not in the ListView control, I'm wondering why ... maybe an option that I've miss somewhere ?

anyway, here is my solution, you can either override the listview, or put an event handler on the mouseUp event:

 

First way:

    public class MyListView : System.Windows.Forms.ListView
{
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);

if (e.Button == MouseButtons.Right)
{
ListViewItem item = this.GetItemAt(e.X, e.Y);
if (item != null)
{
item.Selected = true;
}
}
}
}

 


Second way :


 

this.listView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnListViewMouseUp);

 

        private void OnListViewMouseUp(object sender, MouseEventArgs e)
{
ListView listView = sender as ListView;

if (e.Button == MouseButtons.Right)
{
ListViewItem item = listView.GetItemAt(e.X, e.Y);
if (item != null)
{
item.Selected = true;
}
}
}

mercredi 24 septembre 2008 | Predicate<T>



Articles techniques technologie microsoft .Net :

How to get rounded corner windows forms

You can use a function available in gdi32.dll, by calling it in the constructor of the form.

From my experience the Border seems to not apply on the rounded corners.

 

    public partial 
En savoir plus

vendredi 05 septembre 2008 | Predicate<T>

Un petit test de vitesse au clavier ?
32 wordsUn petit conseil pour augmenter son score, il ne faut pas faire de faute d?orthographe sinon le mot n?est pas compté, les accents comptent aussi. je retourne m?entrainer ;)

Speed testEn savoir plus

lundi 18 août 2008 | ERP 360

Microsoft Visual Basic Power Packs 3.0
Overview

The new DataRepeater control included in this version of the Visual Basic Power Packs allows you use standard Windows Forms controls to display rows of your data in a scrollable container giving you more flexibility and customization than standard grid controls.
The Line and...

En savoir plus

mardi 12 août 2008 | Predicate<T>

Show All tasks In visual studio 2008

Finnally Microsoft has fixed that !

 

In earlier versions of Visual Studio, the task list is populated by using the ToDo tasks that are specified in open files. In this service pack, the Visual C# IDE extends this functionality. The Visual C# IDE populates the task lis...

En savoir plus

lundi 11 août 2008 | Predicate<T>

Microsoft Visual Studio 2008 Service Pack 1

Disponible en t?l?chargement, en fran?ais.

 

Pr?sentation

Ce t?l?chargement installe Visual Studio 2008 SP1 et .NET Framework 3.5 Service Pack 1 (SP1). Le SP1 traite les probl?mes remont?s par le biais des commentaires des clients et des partenaires ou tro...

En savoir plus

lundi 11 août 2008 | Predicate<T>

ERP 360 Compatible SQL Serveur 2008

 

Nous avons le bonheur de pouvoir annoncer que ERP 360 est 100% compatible SQL 2008 autant au niveau du moteur d?execution que du nouveau format de base de données 10.0.

Au programme des performances accrues et un nouveau systeme de tracking des modifications, et surtout la pos...

En savoir plus

samedi 09 août 2008 | ERP 360

Visual studio command line to open a file into running instance

here is it:

devenv /Edit "c:\test.txt"

 

if you omit the /Edit swith then another instance is opened.En savoir plus

samedi 26 juillet 2008 | Predicate<T>

string Extension method - Part 2

Here is a usefull string extension method, in order to validate a string input against a regular expression pattern:

 

        public static bool IsMatch(
En savoir plus

dimanche 06 juillet 2008 | Predicate<T>

linq extension methods that extend every classes with reflection helpers

Here is my simple extension method that quickly obtain the list of property name on any object, and another one to get the property value.

No more getType().GetProperties() over and over again :-D

 

    public 
En savoir plus

jeudi 03 juillet 2008 | Predicate<T>

FFClickOnce Firefox 3 version (hack)

The famous FireFox extension is not yet compliant with Firefox, so here is a hack of FFClickonce 0.7 that works with Firefox 3.

 

Download FFClickonce for Firefox 3En savoir plus

mercredi 02 juillet 2008 | Predicate<T>

ERP 360: Mise à jour du 14 Juin 2008 (Build 2716)
ERP 360: Mise à jour du 14 Juin 2008 (Build 271...En savoir plus

samedi 14 juin 2008 | Predicate<T>

Mise à jour du 14 Juin 2008 (Build 2716)

 

Les elements suivants ont été mis en place lors de cette mise à jour.

Nouvelles fonctionnalités :
  • Nouvelle centrale de livraison orientée sur un process de traitement par produit et mise a disposition d?un document de parcours dans l?entrepot pour pr...
En savoir plus

samedi 14 juin 2008 | ERP 360

C# Save an Image to a byte[] array

I use this to get the data to put in database:

 

 
//Load a picture
Image image = Image.LoadFromFile("toto.jpg");
...
En savoir plus

mercredi 04 juin 2008 | Predicate<T>

C# Load an Image from a byte[] array

Usefull when you store your image in a database.

 

byte[] data = null; // Load that from your database
MemoryStream stream = new Me...

En savoir plus

mercredi 04 juin 2008 | Predicate<T>

How to create fixed length string in c#

 

I needed this one to create a csv file. Here is my little method, maybe it should be a class ?

 

        public static string GetFixedLengthString(<...
En savoir plus

mercredi 28 mai 2008 | Predicate<T>

How to integrate Araxis Merge with TortoiseSVN

 

Araxis merge is an awesome merge/diff tool, which is something unvaluable when you work with a source code repository.

Here is how to integrate it with tortoisesvn, in order to replace the internal diff and merge tools.

En savoir plus

mardi 13 mai 2008 | Predicate<T>

c# : How to hash a string to MD5

 

MD5 hash is a method to obtain a unique "signature" from a string. It is very usefull in order to store password, but be aware that there is no way to get back to the original string, starting from the hash.

I use it for creating unique filename for caching url crawli...

En savoir plus

lundi 12 mai 2008 | Predicate<T>

Mise à jour du 13 Mai 2008 (Build 2382)

Les elements suivants ont été mis en place lors de cette mise à jour.

Nouvelles fonctionnalités :

  • CRM (Gestion de la relation client) , possibilité d'associer à chaque etape du workflow de vente des tickets de retour client ou de tache a accomplir, un article dedié...
En savoir plus

mardi 15 avril 2008 | ERP 360

Cher Entreprenaute, vous pouvez trouver ici votre passeport pour l'economie numerique

Latest releases

Keyword studio 1.1
Générez des nouveaux mots clés pour vos campagnes PPC et découvrez qui de vos concurrents les achetent.
keyword generator and suggestion tool download Download now
Visual Log Parser 1.0
GUI for the powerfull log parser.
download Visual Log Parser GUI Download now
Open Shopping Cart 1.0
Open Shopping Cart, composant asp.net pour la gestion d'un panier de commande
download open shopping cart for asp.net component Download now
.Net search engine
Search through .Net contents.
.net search engine Try now
.NET (dotnet) FAQ
A growing knowledge base about ASP.NET, Windows Forms and .NET 2.
ASP.NET FAQ Check it now
.netTiers support
and developpement

Smart Code Generator

Serialcoder participe activement au projet opensource Smart Code Generator

smartcodegenerator