Use the following snippet to extend the C# listBox to a readOnly List box.
using System.Windows.Forms;
namespace ReadOnlyListBox
{
public class ReadOnlyListBox : ListBox
{
private bool _readOnly = false;
public bool ReadOnly
{
get { return _readOnly; }
set { _readOnly = value; }
}
protected override void DefWndProc(ref Message m)
{
// If ReadOnly is set to true, then block any messages
// to the selection area from the mouse or keyboard.
// Let all other messages pass through to the
// Windows default implementation of DefWndProc.
if (!_readOnly || ((m.Msg <= 0x0200 || m.Msg >= 0x020E)
&& (m.Msg <= 0x0100 || m.Msg >= 0x0109)
&& m.Msg != 0x2111
&& m.Msg != 0x87))
{
base.DefWndProc(ref m);
}
}
}
}
Wednesday, February 4, 2009
Screen Right Bottom Co-Ordinates
Hi,
Use the following snippet to get the right bottom coordinates in the screen. This will be useful when you write apps which alerts the user from the system Tray.
Me.Left = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
Me.Top = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
Use the following snippet to get the right bottom coordinates in the screen. This will be useful when you write apps which alerts the user from the system Tray.
Me.Left = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
Me.Top = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
Subscribe to:
Posts (Atom)