473,377 Members | 1,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,377 software developers and data experts.

I want to add ComboBox inside ListView on mouse double click event.

I want to add ComboBox inside ListView on mouse double click event. On each double click, a new ComboBox should be added on the next row.

I tried it with the code below, but its not working.

Expand|Select|Wrap|Line Numbers
  1.  private void form_DblClick(object sender, form_DblClickEvent e)
  2.  {
  3.       ComboBox c;
  4.       this.Controls.Add(c = new ComboBox());
  5.       c.Items.Add("Input");
  6.       c.Items.Add("Delay");
  7.       c.Items.Add("Message");
  8.       c.Items.Add("comment");
  9.       listView1.Controls.Add(c);
  10.  }
actually i want to add combobox will all of the above elements in one combobox..when i double click it again..in next line another combobox will be added with all elements...
can any one help me in solving this problem..
Apr 9 '13 #1
1 7331
vijay6
158 100+
Hey sanjeev89cs, you forgot to specify the location of combobox, so that by default all comboboxes uses same position. That's why you're seeing only one combobox at runtime even though you added more than one combobox.

Mouse double click event on what? Form or ListView or something else? Try this code, i wrote it on mouse double click on Form.

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Windows.Forms;
  3.  
  4. namespace WindowsFormsApplication1
  5. {
  6.     public partial class Form1 : Form
  7.     {
  8.         ListView listview1;
  9.         int x, y;
  10.  
  11.         public Form1()
  12.         {
  13.             InitializeComponent();
  14.         }
  15.  
  16.         private void Form1_Load(object sender, EventArgs e)
  17.         {
  18.             this.MouseDoubleClick += Form1_MouseDoubleClick;
  19.  
  20.             x = y = 0;
  21.  
  22.             listview1 = new ListView();
  23.             listview1.Location = new System.Drawing.Point(12, 12);
  24.             Controls.Add(listview1);
  25.         }
  26.  
  27.         void Form1_MouseDoubleClick(object sender, MouseEventArgs e)
  28.         {
  29.             ComboBox cb = new ComboBox();
  30.             cb.Items.Add("Input");
  31.             cb.Items.Add("Delay");
  32.             cb.Items.Add("Message");
  33.             cb.Items.Add("comment");
  34.             cb.Location = new System.Drawing.Point(x, y);
  35.             x = cb.Location.X;
  36.             y = cb.Location.Y + cb.Height;
  37.             listview1.Controls.Add(cb);
  38.         }
  39.     }
  40. }
Apr 10 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Uninvisible | last post by:
I have put together a db for a law firm to keep track of counterfeit activities. There are four parent tables: tblContact tblTransaction tblAction tblFile I have created a form,...
4
by: Harry J. Smith | last post by:
How can you detect a mouse double click on a text box? I tried the following but it does not work. private void richTextOut_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) //...
1
by: Alex K. | last post by:
I am using combo box with DropDownStyle = simple. Tried to use double click event but it does not work. I've got this.comboItems.DoubleClick += new...
1
by: Sakharam Phapale | last post by:
Hi All, How to capture Mouse Single click and mouse double click event on Commnad Button. I am doing as follows. Private void Button1_MouseUp(Object sender,...
1
by: active | last post by:
I've been working on a problem for a few days now. I do not get a Double-Click event fired for a ListView when I double click. I now find that if I double click with the right button it works OK....
2
by: techsatish | last post by:
Hi, I want the double click event to call(here not able to get the MouseEventArgs) and execute the mouseup event code or any one tell me how to make my treecontrol double click nodes to behave...
3
by: Techsatish | last post by:
how to make a mouseup event called only once during a double click event? here double click is made on a tree node in a tree control. I have the code inside mouseup event....in runtime the...
2
by: cumars | last post by:
Hello Friends, I want to trigger both the click event and double click event in a single button separately. (i.e.) the user can trigger both the single click and the double...
4
by: Jeff User | last post by:
Hi Using .NET 1.1, C#, web app I (actually our client) would like to be able to double click a selection in a listbox and have it postback to server . There I would want to access the item that...
4
by: raaman rai | last post by:
i wanna know if listview have the item double click event procedure in vb. pls enlighten me
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.