CSharp/C# >> C# Windows Form Databound Listbox Problem - Help!!

by Wade Beasley » Fri, 19 Sep 2003 22:35:39 GMT

I have developed a Windows Forms application with C#. On the windows
form I have a master list box with the names of people the user can
select from and when selected it calls a Select in SQL server to gather
the appropriate information. It is then populated onto a multi-tab
portion on the right of the screen. On the 3rd tab I have 2
multi-select listboxes. The problem is on the first time I go to the
tab for the first name the 2 multi-select listboxes are not highlighting
the items that should be. If the user selects another name then
reselects the first one, it works okay. I can not figure out why it is
not highlighting on the first time????? I have tried doing refreshes
on the controls when I load the data. I have tried refreshing the tabs
too. Nothing seems to work. It is like it lost context the first time.
I am about ready to pull out the few hairs on my head. Any help would
greatly be appreciated.

Thanks,
Wade Beasley




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

CSharp/C# >> C# Windows Form Databound Listbox Problem - Help!!

by Dominic Paquette » Fri, 19 Sep 2003 23:16:25 GMT


after you filled the listbox containing the names did you try setting the
selection explicitlly like this for example:

fillNamesListBox();
myListBox.SelectedItem = 0;



XXXX@XXXXX.COM ...

Similar Threads

1. Databound listbox hangs when form is shown - CSharp/C#

2. Problem clearing selected index of databound listbox

Hi there,

I wish to clear a databound listbox of any selectedIndex when another
ListBox is focussed but using selectedIndex = -1 it simply sets the
first item as selected. I have to assign the selectedIndex -1 twice in
order for the selection to clear! Does anyone know why this is?

Heres my code:

this.RulesBox.Enter += new System.EventHandler(this.RulesBox_Enter);

LeftTables[0] = mSad2Access.ProcessQuery(
	"SELECT yada yada yada");
LeftBox.DataSource = LeftTables[0];
LeftBox.DisplayMember = LeftTables[0].Columns[1].ColumnName;
LeftBox.ValueMember = LeftTables[0].Columns[0].ColumnName;

private void RulesBox_Enter(object sender, System.EventArgs e)
{
	LeftBox.SelectedIndex = -1;//if i do this a second time it works!!!!
}

Any advice would be much appreciated,

Thanks,

Andrew

3. Databound listbox refresh problem - CSharp/C#

4. Looking for good windows forms sample in C# showing how to work with ListBox

Hello,

This seems like it should be easy...

I have a listbox on a .NET form.

I add a new item to the list box.

How can I associated a separate data value?

Can I add (and retrieve) an arbitrary data value independent of the text
displayed?

I also tried creating an object and providing a ToString override.  That did
let me add the item but I still didn't see a way to lookup based on
enumerating the list...

Thanks,
-- 
Grant Schenck


5. Windows Form Talking To Another Windows Form Help Needed - CSharp/C#

6. (VB.NET 1.1) Windows Forms Listbox help

Hi,

I have a listbox with 3000 entries, all of 4 chars, and the user needs to be 
able easily select dozens of them...

When the user is selecting items, they type for example ABB, and the listbox 
first goes to A, then B, rather than searching for ABB.

Is there any way to setup the listbox so that the user can type for example 
ABB and it will jump to ABB instead of going to AAAA, then BBBB

in other words I need the listbox to take up to 4 keystrokes and search for 
the nearsest match in the list...

is there any way to do that - or is there a sample I can look at eanywhere?

thanks

Philip

7. Windows.Forms listbox vs WebControls listbox - Asp.Net

8. Problem with databound listbox.

I have a strange problem with a databound listbox.  It may be because of how
I use it, but I am stumped by this behavior.  Here is the scenario:

I have a multiselect databound listbox that belongs to a panel control.  In
the Page_Load event, the panel listbox control may be moved from one panel
to another depending on selections that the operator makes.  Everything
seems to work fine except for one thing.  The selections that are made in
the listbox are not retained on postback.  They are always cleared.  If I
remove the databinding from the listbox and place items in it manually, then
it works fine.  I do not do databinding if Page.IsPostback is set to true.
Can someone explain why it does not retain selections on postback?  I
suspect it is because I am moving the listbox control to a new parent, but I
don't understand why this is causing a problem.


-- 
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------