Click here to Skip to main content
15,907,395 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to reference image Pin
netJP12L25-Aug-10 2:23
netJP12L25-Aug-10 2:23 
GeneralRe: how to reference image Pin
DaveyM6925-Aug-10 7:52
professionalDaveyM6925-Aug-10 7:52 
QuestionComparing various algorithms to convert GPS-coordinates to 2D-coordinates Pin
CrIpLeX24-Aug-10 11:09
CrIpLeX24-Aug-10 11:09 
AnswerRe: Comparing various algorithms to convert GPS-coordinates to 2D-coordinates Pin
Luc Pattyn24-Aug-10 11:38
sitebuilderLuc Pattyn24-Aug-10 11:38 
GeneralRe: Comparing various algorithms to convert GPS-coordinates to 2D-coordinates Pin
CrIpLeX25-Aug-10 2:00
CrIpLeX25-Aug-10 2:00 
GeneralRe: Comparing various algorithms to convert GPS-coordinates to 2D-coordinates Pin
Luc Pattyn25-Aug-10 2:27
sitebuilderLuc Pattyn25-Aug-10 2:27 
AnswerRe: Comparing various algorithms to convert GPS-coordinates to 2D-coordinates [modified] Pin
Peter_in_278024-Aug-10 11:39
professionalPeter_in_278024-Aug-10 11:39 
GeneralRe: Comparing various algorithms to convert GPS-coordinates to 2D-coordinates Pin
CrIpLeX25-Aug-10 2:01
CrIpLeX25-Aug-10 2:01 
AnswerRe: Comparing various algorithms to convert GPS-coordinates to 2D-coordinates Pin
Bernhard Hiller25-Aug-10 0:27
Bernhard Hiller25-Aug-10 0:27 
QuestionCharacter encoding when reading a text file of unknown encoding, to create an XML file Pin
JohnLBevan24-Aug-10 9:00
professionalJohnLBevan24-Aug-10 9:00 
AnswerRe: Character encoding when reading a text file of unknown encoding, to create an XML file Pin
Luc Pattyn24-Aug-10 9:52
sitebuilderLuc Pattyn24-Aug-10 9:52 
GeneralRe: Character encoding when reading a text file of unknown encoding, to create an XML file Pin
JohnLBevan24-Aug-10 22:33
professionalJohnLBevan24-Aug-10 22:33 
QuestionStrange order of events in ListView with MultiSelect set to false Pin
crypto_rsa24-Aug-10 6:28
crypto_rsa24-Aug-10 6:28 
AnswerRe: Strange order of events in ListView with MultiSelect set to false Pin
Ravi Bhavnani24-Aug-10 8:17
professionalRavi Bhavnani24-Aug-10 8:17 
AnswerRe: Strange order of events in ListView with MultiSelect set to false Pin
DaveyM6924-Aug-10 10:16
professionalDaveyM6924-Aug-10 10:16 
GeneralRe: Strange order of events in ListView with MultiSelect set to false Pin
crypto_rsa24-Aug-10 21:37
crypto_rsa24-Aug-10 21:37 
GeneralRe: Strange order of events in ListView with MultiSelect set to false Pin
johannesnestler24-Aug-10 23:05
johannesnestler24-Aug-10 23:05 
AnswerRe: Strange order of events in ListView with MultiSelect set to false Pin
DaveyM6924-Aug-10 10:41
professionalDaveyM6924-Aug-10 10:41 
GeneralRe: Strange order of events in ListView with MultiSelect set to false Pin
crypto_rsa25-Aug-10 1:12
crypto_rsa25-Aug-10 1:12 
Thanks for the proposed semi-solution. I put together different pieces and came up with this solution which seems to do what I want Smile | :) First, I leave the MultiSelect property set to false and set FullRowSelect to true. Then I use this code:

public class CustomListView : ListView
{
	public CustomListView()
	{
		InitializeComponent();
	}

	bool fakeMouseUp = false;
	bool mouseDownOnItem = false;

	protected override void OnMouseDown( MouseEventArgs e )
	{
		// if we're not on an item or subitem, we will get OnMouseUp immediately
		mouseDownOnItem = HitTest( e.Location ).Item != null;

		Debug.WriteLine( "OnMouseDown" );

		base.OnMouseDown( e );
	}

	protected override void OnMouseUp( MouseEventArgs e )
	{
		if( mouseDownOnItem || fakeMouseUp )
		{
			Debug.WriteLine( "OnMouseUp" );

			mouseDownOnItem = false;
			fakeMouseUp = false;

			base.OnMouseUp( e );
		}
	}

	protected override void WndProc( ref Message m )
	{
		if( !mouseDownOnItem && m.Msg == 0x0202 /*WM_LBUTTONUP*/ )
		{
			// send a fake MouseUp event
			fakeMouseUp = true;
			Point point = new Point( ((int) m.LParam) & 0x0000FFFF, (int) m.LParam >> 16 );
			OnMouseUp( new MouseEventArgs( MouseButtons.Left, 1, point.X, point.Y, 0 ) );
		}

		base.WndProc( ref m );
	}
}


But I always have a feeling of wasted time when I need to do such workarounds for weird .NET behaviour. Why on Earth do I get a MouseUp event when the mouse button was not physically released? Confused | :confused:
QuestionEditable datagridview Pin
saqib8224-Aug-10 5:37
saqib8224-Aug-10 5:37 
AnswerRe: Editable datagridview Pin
dan!sh 24-Aug-10 6:00
professional dan!sh 24-Aug-10 6:00 
GeneralRe: Editable datagridview Pin
saqib8224-Aug-10 6:07
saqib8224-Aug-10 6:07 
GeneralRe: Editable datagridview Pin
dan!sh 24-Aug-10 6:24
professional dan!sh 24-Aug-10 6:24 
GeneralRe: Editable datagridview Pin
saqib8224-Aug-10 6:39
saqib8224-Aug-10 6:39 
AnswerRe: Editable datagridview Pin
Mada Naga Sankar25-Aug-10 19:38
Mada Naga Sankar25-Aug-10 19:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.