473,394 Members | 2,020 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,394 software developers and data experts.

combobox problem

Hai,
Ihave a combobox and button in my application.When i select an item in the combobox and click the button the item will be deleted and the message box shown the item deleted.My problem is that when i deleted the last item them will not deleted it exist in the combobox but the message box shown the item deleted.Then iagain open then the combobox is empty.What can i do? Please help me..........
Jan 25 '08 #1
7 1083
debasisdas
8,127 Expert 4TB
kindly post your code for reference of our experts please.
Jan 25 '08 #2
Expand|Select|Wrap|Line Numbers
  1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2.         Dim a As String
  3.         If ComboBox1.SelectedIndex <> -1 Then
  4.             a = ComboBox1.SelectedItem
  5.             ComboBox1.Items.Remove(ComboBox1.SelectedItem)
  6.             MsgBox(a)
  7.  
  8.  
  9.  
  10.         End If
  11.  
  12.  
  13.  
  14.     End Sub
Jan 25 '08 #3
Shashi Sadasivan
1,435 Expert 1GB
Hai,
Ihave a combobox and button in my application.When i select an item in the combobox and click the button the item will be deleted and the message box shown the item deleted.My problem is that when i deleted the last item them will not deleted it exist in the combobox but the message box shown the item deleted.Then iagain open then the combobox is empty.What can i do? Please help me..........
So items should be deleted when they are selected?

You did say that the combobox is empty after the last titem is selected!
Whats the issue?
Jan 25 '08 #4
sir
If I delete last element from the combobox it is deleting ,but the element is displayed in combobox ie it is not clearing the textarea of combobox

for ex
if i have elements 1 to 5 in combobox and if I delete serially the last element 5 is deleted but in combobox 5 is displayed

plz neglect the previous code
Jan 25 '08 #5
Shashi Sadasivan
1,435 Expert 1GB
sir
If I delete last element from the combobox it is deleting ,but the element is displayed in combobox ie it is not clearing the textarea of combobox

for ex
if i have elements 1 to 5 in combobox and if I delete serially the last element 5 is deleted but in combobox 5 is displayed

plz neglect the previous code
What is your code then?

the previous code looks as if it will do the job
Jan 25 '08 #6
Expand|Select|Wrap|Line Numbers
  1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2.         Dim a As String
  3.              ComboBox1.Items.Remove(ComboBox1.SelectedItem)
  4.          combobox1.refresh()
  5.         If ComboBox1.items.count=0 Then
  6.              combobox1.items.clear()
  7.               End If
  8. End Sub

here is my code if I delete element one by one while deleting last element my combobox is not cleared
Jan 25 '08 #7
Shashi Sadasivan
1,435 Expert 1GB
Ok, I got what you meant
the issue is that the text that is selected is different to selected items. the text can be edited regardless of the contents of the combo box

try this (hope you can convert it to vb .net)

Expand|Select|Wrap|Line Numbers
  1. private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             this.comboBox1.Items.Remove(this.comboBox1.SelectedItem);
  4.             if (this.comboBox1.Items.Count > 0)
  5.             {
  6.                 this.comboBox1.SelectedIndex = 0;
  7.             }
  8.             else
  9.                 this.comboBox1.Text = "";
  10.         }
Jan 25 '08 #8

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

Similar topics

4
by: Chandra | last post by:
Hello Sir, This is Chandra and Working as Software Engineer. I got a really weird problem with ComboBoxes. I have set the ComboBox DroppedDown Property to true. Now the actual problem is...
7
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: anonymous | last post by:
I've been trying to put a them, please help me out. Here's the major parts of my code: public Form1() { DataSet myDataSet = new DataSet("myDataSet"); DataTable testTable = new...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
0
by: tupolev | last post by:
Hi, I already post this item but now I know whats wrong: I want to allow the user to edit the items in a combobox. The problem is that the textchange event works just one time (for the first...
4
by: Keith | last post by:
Hello - this started out as a minor annoyance - and now is starting to bother me more and more - I'm hoping someone can help me. I would like to have a combobox display - NOT initially be blank...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
5
by: Peter M. | last post by:
I'm struggling with combobox databinding with something I consider a bug... I'm binding my combobox to an array of structs. The struct exposes two public properties, ID and Name, to be used as...
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: 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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.