Issue related to combobox....

I have used a combobox to display a list of options like 1 Month,2 Months,3 Months and last option Other.
Wen i click on "Other" , calender opens and i have to select the date.
The problem is after i select the date and the calender closes i am unable to set the combobox1.text property to the date i selected..
Please help me with this. :-|

From your code I see that you are not adding the date chosen to the combobox.

You gotta do two things

1.You should ADD the string to the combo box.To be honest with you,I dont know how to handle combo box,I was thinking combo box and dropdownlist are the same until I read your post and I saw you using something like cboExpiryDate.Text which is not possible in dropdownlist.

In a dropdownlist you can add a new item to the webcontrol by using something like

DropDownList1.Items.Add("My value")

or in your case

DropDownList1.Items.Add(m_strExpDate)

2.Then you gotta ASSIGN the value to the webcontrol by using something like this.

From your code I see that you are not adding the date chosen to the combobox.

You gotta do two things

1.You should ADD the string to the combo box.To be honest with you,I dont know how to handle combo box,I was thinking combo box and dropdownlist are the same until I read your post and I saw you using something like cboExpiryDate.Text which is not possible in dropdownlist.

In a dropdownlist you can add a new item to the webcontrol by using something like

DropDownList1.Items.Add("My value")

or in your case

DropDownList1.Items.Add(m_strExpDate)

2.Then you gotta ASSIGN the value to the webcontrol by using something like this.

DropDownList1.SelectedItem.Text = m_strExpDate

Hope it helps.

Oh thanks a lot, But to be honest i tried with this after i posted this on this forum and got the results. BUt from ur reply i gotto know that v need to add the item first to the list before assigning it to the text area which i was not doin before.

I think I may have a similar issue, but I am searching for a different solution.

I'm using VB.NET 2005 (beta) and I'm trying to assign a value to a Combobox's Text property during a SelectedIndexChanged event. I've placed a ComboBox on a form without changing any of its properties and added the following code:

I first noticed that "Select an item" appears fine, even though it's not added as an item. However, "Value retrieved..." does not appear when "Other" is selected from the dropdownlist. When stepping through the code, the value of ComboBox1.Text is "Value retrieved...", but when SelectedIndexChanged completes the ComboBox reads "Other".

I know this could be done in VB6. Is this a bug with VB.NET? With VS 2005? Or am I doing something wrong?

With a recent project, I received multiple WM_PAINT messages before the iSelectChangeCommit variable was reset. This caused an infinite loop, raising SelectionChangeComplete continuously. The following code reflects the correct order of operations (Note that I reset the variable as soon as I enter the If block).

Hey guys, I have a solution for this ridiculous issue. Its pretty infuriating and I have wasted a few hours now working around it. I saw a similar post and here's a way you can do it without having to inherit the combobox as posted above (although that does work):

You cannot set the text property during the selectedindexchanged event. Period. Sucks hard, but its the truth. But, you can do it by causing another event to fire on the combobox control. An easy one is the mouse move event.

....

'This moves the mouse over the combobox to cause the mousemove event to fire. Sets the text property, then puts the cursor back where it was
'FIRST MAKE 2 PROPERTIES, ONE IS IsAlteringComboText as Boolean
'SECOND ONE IS OldMousePosition
'IN THE SELECTEDINDEXCHANGED EVENT OF THE COMBOBOX
If ComboBox.SelectedIndex = 0 then
Me.IsAlteringComboText = True
Me.OldMousePosition = Me.Cursor.Position
Me.Cursor.Position = me.PointToScreen(new point(combobox.location.x+15, combobox.location.Y+15))
end if
'IN THE MOUSEMOVE EVENT OF THE COMBOBOX
if Me.IsAlteringComboText then
Me.IsAlteringComboText = False
Me.ComboBox.Text = "Finally, the beast is dead!"
Me.Cursor.Position = Me.OldMousePosition
End If

This is kinda dirty if you ask me. You might want to put this in a module, or shared functions.