473,473 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ComboBox and ListView Combination

8 New Member
Actually, i m working on Windows Application where i have to use the ComboBox and listview in a way , as first we will click the comboBox and then as you click , ListView appear and when we select something , that will be selected at comboBox also and ListView will disappear, and comboBox item should get selected.
Here i m having a problem as comboBox gets empty when list View will apear
Focus and thatswhy selection become Error,

So plz help what should i do for this ,

ComboBox Click Event
]
Expand|Select|Wrap|Line Numbers
  1. private void cmbSta1So1_Click(object sender, EventArgs e)
  2.         {
  3.  
  4.             ListView lv = new ListView();
  5.  
  6.             if (((ComboBox)sender).Tag.ToString() == "Start")
  7.                 lv = (ListView)lvChannels;
  8.             //else
  9.             //    lv = (ListView)lstCoeff;
  10.  
  11.  
  12.             //lv.Tag = Aindex.ToString();
  13.             lv.Left = ((ComboBox)sender).Left;
  14.             lv.Top = ((ComboBox)sender).Top + ((ComboBox)sender).Height;
  15.             lv.Visible = true;
  16.             lv.Focus();
  17.             if (((ComboBox)sender).Text == "")
  18.                 lv.Items[0].Selected = true;
  19.             else
  20.             {
  21.                 lv.Items[lv.FindItemWithText(((ComboBox)sender).Text).Index].Selected = true;
  22.             }
  23.         }
  24.  
  25.  
ListView CLick event
Expand|Select|Wrap|Line Numbers
  1.    private void lvChannels_Click(object sender, EventArgs e)
  2.         {
  3.              getChannels(((ListView)sender));
  4.  
  5.         }
  6.  
  7.         private void getChannels(ListView lstV)
  8.         {
  9.              //int Aindex = Int16.Parse(lstV.Tag.ToString());
  10.             lstV.Visible = false;
  11.  
  12.             if (lstV.SelectedItems.Count > 0 && lstV.Name == "lvChannels")
  13.             {
  14.                 MessageBox.Show(cmbCondSta1So1.Items.Count.ToString() );  
  15.  
  16.                     //cmbCondSta1So1.SelectedIndex = lstV.SelectedItems[0].Index ;
  17.                     MessageBox.Show(cmbCondSta1So1.Items.Count.ToString());
  18.                     cmbCondSta1So1.Focus();
  19.  
  20.             }
  21.             lstV.Visible = false;
  22.  
  23.         }
Sep 11 '08 #1
0 1430

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

Similar topics

4
by: Ben Coats | last post by:
Hey, I'm trying to find code for an Explorer-style Directory ComboBox. (You know, it display "Desktop", "My Computer", all drives, etc., but it has a treeview control inside the combobox so that...
1
by: nate axtell | last post by:
I need something that looks like a ListView but will allow SubItems of the ListView to be ComboBoxes, or allow the contents to be a ComboBox. So for each row in the ListView one of the columns...
1
by: Mamatha | last post by:
Hi I have one application ,that diplays data from database into the listview control.While adding data to the listview i want to display an icon to the leftside of the first column's data.Here...
1
by: Ken Yu | last post by:
Hi, How can create image in ListView and ComboBox ? tks a lot ! Ken
0
by: reidarT | last post by:
I have found a good combobox with multiple fields The example shows filling the combobox from a listview, but I want to fill it with zip-code and cities from a database. The example is as follows:...
0
by: morfasie | last post by:
Hi, I ewas wondering, is it possible to add a combobox to the subitems of a listview or listbox? like: column1 | column 2| column 3 | -----------------------------------------------...
0
by: ER | last post by:
Hi Guys Started having a play with WPF and need some direction with a grid. I am trying to build a list of products in a grid view with combox boxes as column headers that allow filtering and...
1
by: Shimon Sim | last post by:
I can't figure out how to bind ComboBox inside of ListView or ListBox. How do I set ComboBox.ItemsSource property? I don't see the way to do it in code and not in XAML. I have Collection that is...
3
by: Simon van Beek | last post by:
Dear reader, What can be wrong in my ComboBox, the property "Auto Expand" is set to Yes, but by typing in the ComboBox it doesn't expand. Is this because the source of the ComboBox is a...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.