By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,333 Members | 1,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,333 IT Pros & Developers. It's quick & easy.

Combobox

P: n/a
Hi
I'm using this code to display the selected item in msgbox
Dim ob As Object
ob = cmbCategory.SelectedItem
MsgBox(ob.ToString())
but all what I see is "System.Data.DataRowView", and the same result with
cmbCategory.Text .

thanks

--
Regads,
Rochdi
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Oh, I forget the mention that the code is the
ComboBox1_SelectedIndexChanged event
--
Regads,
Rochdi
"Mike" wrote:
Hi
I'm using this code to display the selected item in msgbox
Dim ob As Object
ob = cmbCategory.SelectedItem
MsgBox(ob.ToString())
but all what I see is "System.Data.DataRowView", and the same result with
cmbCategory.Text .

thanks

--
Regads,
Rochdi

Nov 21 '05 #2

P: n/a
Try

MsgBox (ComboBox1.Items(ComboBox1.SelectedIndex).ToString )

HTH, Phil

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
Hi
I'm using this code to display the selected item in msgbox
Dim ob As Object
ob = cmbCategory.SelectedItem
MsgBox(ob.ToString())
but all what I see is "System.Data.DataRowView", and the same result with
cmbCategory.Text .

thanks

--
Regads,
Rochdi

Nov 21 '05 #3

P: n/a
Your objects in the combo box are of type "System.Data.DataRowView" whose
"ToString" method returns the object's type name. Also, the text placed
into the combo items will be whatever the object's "ToString" method returns
unless you are using binding. I believe that if you are binding the combo
box to a DataView object, you need to set the ValueMember and DisplayMember
properties of the combo box.
Dennis in Houston
"Mike" wrote:
Oh, I forget the mention that the code is the
ComboBox1_SelectedIndexChanged event
--
Regads,
Rochdi
"Mike" wrote:
Hi
I'm using this code to display the selected item in msgbox
Dim ob As Object
ob = cmbCategory.SelectedItem
MsgBox(ob.ToString())
but all what I see is "System.Data.DataRowView", and the same result with
cmbCategory.Text .

thanks

--
Regads,
Rochdi

Nov 21 '05 #4

P: n/a
Yes I'm binding it to a dataset like this:
cmbCategory.DataSource = Qds.Tables(0)
cmbCategory.DisplayMember = "Category"
where Category is the column that exist in the Qds.Table(0).
but how can I set the ValueMember!!!?

--
Regads,
Rochdi
"Dennis" wrote:
Your objects in the combo box are of type "System.Data.DataRowView" whose
"ToString" method returns the object's type name. Also, the text placed
into the combo items will be whatever the object's "ToString" method returns
unless you are using binding. I believe that if you are binding the combo
box to a DataView object, you need to set the ValueMember and DisplayMember
properties of the combo box.
Dennis in Houston
"Mike" wrote:
Oh, I forget the mention that the code is the
ComboBox1_SelectedIndexChanged event
--
Regads,
Rochdi
"Mike" wrote:
Hi
I'm using this code to display the selected item in msgbox
Dim ob As Object
ob = cmbCategory.SelectedItem
MsgBox(ob.ToString())
but all what I see is "System.Data.DataRowView", and the same result with
cmbCategory.Text .

thanks

--
Regads,
Rochdi

Nov 21 '05 #5

P: n/a
No, it's not working
--
Regads,
Rochdi
"Phil G." wrote:
Try

MsgBox (ComboBox1.Items(ComboBox1.SelectedIndex).ToString )

HTH, Phil

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
Hi
I'm using this code to display the selected item in msgbox
Dim ob As Object
ob = cmbCategory.SelectedItem
MsgBox(ob.ToString())
but all what I see is "System.Data.DataRowView", and the same result with
cmbCategory.Text .

thanks

--
Regads,
Rochdi


Nov 21 '05 #6

P: n/a
Oh, don't worry I have set the Valuemember and its working Thanks
--
Regads,
Rochdi
"Dennis" wrote:
Your objects in the combo box are of type "System.Data.DataRowView" whose
"ToString" method returns the object's type name. Also, the text placed
into the combo items will be whatever the object's "ToString" method returns
unless you are using binding. I believe that if you are binding the combo
box to a DataView object, you need to set the ValueMember and DisplayMember
properties of the combo box.
Dennis in Houston
"Mike" wrote:
Oh, I forget the mention that the code is the
ComboBox1_SelectedIndexChanged event
--
Regads,
Rochdi
"Mike" wrote:
Hi
I'm using this code to display the selected item in msgbox
Dim ob As Object
ob = cmbCategory.SelectedItem
MsgBox(ob.ToString())
but all what I see is "System.Data.DataRowView", and the same result with
cmbCategory.Text .

thanks

--
Regads,
Rochdi

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.