Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrolled listbox problem

Status
Not open for further replies.

anirban2k2001

Programmer
Aug 25, 2003
27
0
0
IN
Hi all,

I have a listbox in a frame. The listbox is populated with values from the backend. Since there will be many items in the list, I want to add a vertical scrollbar to the list box. I am giving below the code that I have used for the purpose, but the scrollbar does not show up as a result of which I am not able to scroll.

###########################CODE##################################

#Creating a Frame
frame .f -width 230 -height 270
pack .f
pack propagate .f 0

#creating a listbox with a scroll bar
label .f.name -text "Select consumer no." -font $fnt11b
place .f.name -x 10 -y 5
listbox .f.l -yscrollcommand {.f.s set} -font $fnt9
place .f.l -x 10 -y 40 -width 220 -height 130

#Defining a scroll bar for the listbox
scrollbar .f.s -orient vertical -command {.f.l yview}
place .f.s -x 230 -y 40 -width 10 -height 130

# Fetching and populating values from backend
set connection_no { }
set stmt "select con_no from mri;"
db1 eval $stmt {} {
lappend connection_no $con_no
.f.l insert end $con_no
}

Kindly help.

Regards,
Anirban Sarkar

 
I don't use "place" so I'm not sure. But it looks like you've placed the scrollbar outside the frame, as follows:
Your frame has a width of 230
frame .f [red]-width 230[/red] -height 270
Your listbox starts at 10 and is 220 wide
place .f.l [red]-x 10[/red] -y 40 [red]-width 220[/red] -height 130
Your scrollbar starts at 230 and is 10 wide
place .f.s [red]-x 230[/red] -y 40 [red]-width 10[/red] -height 130

It looks to me like your listbox actually extends to the edge of the frame (230) and your scrollbar starts at the edge of the frame. As I say, I don't use place so I could be reading it all wrong. What happens if you use "pack"?

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top