473,386 Members | 1,758 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,386 software developers and data experts.

need help: list box showing item selected when none are

I have a list box bound to a data set, of course the datasource,datamember,
and valuemember are set, i tell it selecteditem = -1 to make nothing
selected, select mode is set to only one item at a time. When the list fills
the first item in the listbox has a background rectangle drawn but no focus
rectangle (this is NOT a custom drawn listbox, just a standard one).. now i
did set -1 as the selected item, but if i tab to the item the focus
rectangle is now showing over the background rectangle on the 1st item, then
when i tab off the listbox now nothing is selected like it should of been to
start with... what would cause this?! thanks.. the listbox is in a custom
control which is then placed onto a form... if i do it only on a form by
itself it works fine... but when its in a custom control it causes this
problem..
Nov 20 '05 #1
7 1461
test app web link incase someone has filteres up to block attachments
http://www.bhplace.com/testapp.zip
"Brian Henry" <br******@adelphia.net> wrote in message
news:el**************@TK2MSFTNGP11.phx.gbl...
I have a list box bound to a data set, of course the datasource,datamember, and valuemember are set, i tell it selecteditem = -1 to make nothing
selected, select mode is set to only one item at a time. When the list fills the first item in the listbox has a background rectangle drawn but no focus rectangle (this is NOT a custom drawn listbox, just a standard one).. now i did set -1 as the selected item, but if i tab to the item the focus
rectangle is now showing over the background rectangle on the 1st item, then when i tab off the listbox now nothing is selected like it should of been to start with... what would cause this?! thanks.. the listbox is in a custom
control which is then placed onto a form... if i do it only on a form by
itself it works fine... but when its in a custom control it causes this
problem..

Nov 20 '05 #2
Cor
Hi Brian,

Use the selectedindex

I hope this helps?

Cor
Nov 20 '05 #3
same result with selected index.... just switch it in the test project i
posted and see :\
"Cor" <no*@non.com> wrote in message
news:eN**************@TK2MSFTNGP12.phx.gbl...
Hi Brian,

Use the selectedindex

I hope this helps?

Cor

Nov 20 '05 #4
Cor
Hi Brian,

I thought in your message that you did mean that little listbox bellow, but
you did mean the listbox in the usercontrol.

You have bound that listbox in the usercontrol to that dataclass USState

And in your form you are filing that dataclass

And therefore the selectedindex is affected.

After filing of that dataclass you can set the usercontrol selectedindex

UserControl11.ListBox1.SelectedIndex = -1

You will see that it is deselected.

I hope this helps?

Cor
Nov 20 '05 #5
how about when the user control is in a ClassLibary and being refrenced
though that DLL into the form in the application... then i cant do the
usercontrol1.listbox1.selectedindex = -1 because i then no longer have the
contorls inside the user control available to me.... thats my problem at
this point...
"Cor" <no*@non.com> wrote in message
news:uv**************@TK2MSFTNGP09.phx.gbl...
Hi Brian,

I thought in your message that you did mean that little listbox bellow, but you did mean the listbox in the usercontrol.

You have bound that listbox in the usercontrol to that dataclass USState

And in your form you are filing that dataclass

And therefore the selectedindex is affected.

After filing of that dataclass you can set the usercontrol selectedindex

UserControl11.ListBox1.SelectedIndex = -1

You will see that it is deselected.

I hope this helps?

Cor

Nov 20 '05 #6
Cor
Hi Brian,

Do you mean that you want something like this in your usercontrol?

Private Sub ListBox1_BindingContextChanged(ByVal _
sender As Object, ByVal e As System.EventArgs) _
Handles ListBox1.BindingContextChanged
ListBox1.SelectedIndex = -1
End Sub

Cor
Nov 20 '05 #7
thank you so much!!! thats exactly what i was looking for

"Cor" <no*@non.com> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
Hi Brian,

Do you mean that you want something like this in your usercontrol?

Private Sub ListBox1_BindingContextChanged(ByVal _
sender As Object, ByVal e As System.EventArgs) _
Handles ListBox1.BindingContextChanged
ListBox1.SelectedIndex = -1
End Sub

Cor

Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: mt | last post by:
In a nutshell, I'd like to have a list of items, each of which fills out a small table which displays some info about a particular item(the items being a trouble ticket for a tech support ASP-built...
3
by: Paul T. Rong | last post by:
I have a listbox (of product names) control on my form. I want to pass the selected item (a product name) to a subform, and the product unitprice should apear automatically next to the product name...
2
by: student | last post by:
Hi all, I'm having trouble with my datagrid, it is suppose to display a row from a table called "Calls" based on what is selected in the dropdownlist which displays the first and last name from...
10
by: dhnriverside | last post by:
Hi guys Still having a problem with this dropdownlist. Basically, I've got 4. The first 2 work fine, then my code crashes on the 3rd. ddlEndTimeHour.Items.FindByValue(endTime).Selected =...
3
by: Larry | last post by:
I've set up a list of image filesnames in a listview control(lvSrcFileList), I'm using the selectedIndexChange event to select which file is being displayed in a picturebox control(pbImagePreview)....
1
by: Bob | last post by:
Hi, Hope you can help me with this one. I'm at my wits end. I'm trying to create an intelligent edit-box like the excellent "Customer" one at the URL: ...
3
by: Strasser | last post by:
In a nested subform in datasheet view, an interviewer of homeless people picks a descriptive CATEGORY from 20 descriptive categories. The 20 categories are displayed via a combo box. (Categories...
0
by: Geary | last post by:
I have a drop down list on an asp.net 2 page that is bound to a table. By default it displays the first item as the selected item. But I want to make sure that the user must change the selection. ...
1
by: ollielaroo | last post by:
Hi guys, Firstly I did do a search for this one first but I couldn't find anything related in this forum. I am using Dreamweaver MX and trying to build admin pages for an ASP site. My problem is...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...

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.