Ive been trying to find a solution to a very annoying problem with my combobox. When i select a item on the list the combobox is the list is still active. It is annoying because when i scoll my mouse the combox item that ive selected changes. Any thoughts on this problem.

Thanks.

This is normal and expected behaviour of a combo-box. It is not a problem for most users.
As long as the combo-box has focus the scroll wheel will change the entry.
Clicking in the text part or tabbing to a combo-box also cause this behaviour even without showing the list.

help me how to insert cuntry in my combobox using c#.net with out database

@balaji2005: Please start a new thread and give some examples of what you have already tried and someone might help you.

If you want to disable the mouse for a single control/single form:

using System;
using System.Windows.Forms;

namespace daniweb
{
  public partial class frmMouseWheel : Form
  {
    public frmMouseWheel()
    {
      InitializeComponent();
    }

    protected override bool ProcessKeyPreview(ref Message m)
    {
      //return false: normal behavior for forwarding message to the control
      //return true: stops the message from being processed

      const int mouse_wheel = 0x100;
      if ((m.Msg == mouse_wheel) && comboBox1.Focused)
        return false;
      else
        return base.ProcessKeyPreview(ref m);
    }

    private void frmMouseWheel_Shown(object sender, EventArgs e)
    {
      comboBox1.Focus();
    }
  }
}

If you want to change this behavior application wide then add a message filter to the application. I found this code on MSDN:

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsApplication1
{
  public partial class Form1 : Form, IMessageFilter
  {
    public Form1()
    {
      InitializeComponent();
      Application.AddMessageFilter(this);
    }

    public bool PreFilterMessage(ref Message m)
    {
      if (m.Msg == 0x20a)
      {
        // WM_MOUSEWHEEL, find the control at screen position m.LParam
        Point pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16);
        IntPtr hWnd = WindowFromPoint(pos);
        if (hWnd != IntPtr.Zero && hWnd != m.HWnd && Control.FromHandle(hWnd) != null)
        {
          SendMessage(hWnd, m.Msg, m.WParam, m.LParam);
          return true;
        }
      }
      return false;
    }

    // P/Invoke declarations
    [DllImport("user32.dll")]
    private static extern IntPtr WindowFromPoint(Point pt);
    [DllImport("user32.dll")]
    private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
  }
}

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/eb922ed2-1036-41ca-bd15-49daed7b637c/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.