This is a migrated thread and some comments may be shown as answers.

List Box selected index change not firing

12 Answers 724 Views
ListControl
This is a migrated thread and some comments may be shown as answers.
Muthu
Top achievements
Rank 1
Muthu asked on 23 Mar 2011, 07:40 AM
Hi,
I'm using telerik Radlistbox (winforms controls)..
The scenario is,when we select an item in Radlistbox then all the related values for the item should be loaded in the window from db..
The corresponding code is written in selecteditemchanged event of the list box..
The Radlistbox is dynamically populated at runtime from db based on the letters we type in as particular textbox(like autocomplete) 
    with the top item selected by default...
The issue is when we select the items other than the item at the top(which is selected by default) then the 
    selectedindexhange event gets fired, the values are loaded in the window.. But if we click the item at the top(which is 
    selected by default) then the selectedindexhange event doesn't gets fired...
We tried click,mousedown events but when we use that where ever we click on the Radlistbox the (apart from the iitems especially in the scroll bars) the item at the top is loading..

pls guide us on this issue(whether any events that we can use or any way to avoid the default selection when using the click event)...

12 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 23 Mar 2011, 12:28 PM
Hello,

Unless I have misunderstood, I'm not able to replicate your issue. Please can you try the following code (written against the latest Q1 2011 release)

private void Form1_Load(object sender, EventArgs e)
{
    this.radListControl1.Items.Add("Item 1");
    this.radListControl1.Items.Add("Item 2");
    this.radListControl1.Items.Add("Item 3");
    this.radListControl1.Items.Add("Item 4");
    this.radListControl1.Items.Add("Item 5");
    this.radListControl1.SelectedItem = this.radListControl1.Items[0];
    this.radListControl1.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(radListControl1_SelectedIndexChanged);
}
void radListControl1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
    MessageBox.Show(this.radListControl1.Items[e.Position].Text);
}

Look forward to hearing back from you
Richard
0
Muthu
Top achievements
Rank 1
answered on 24 Mar 2011, 10:27 AM
Hi to put my query in simple terms.. selected index changed event not firing on clicking a listboxitem that is already selected/ selected by default...

Regards,
0
Richard Slade
Top achievements
Rank 2
answered on 24 Mar 2011, 10:38 AM
Hello,

Please see my sample above and the following one. This will show that the SelectedIndexChanged fires every time the item is changed.

private void Form1_Load(object sender, EventArgs e)
{
    this.radListControl1.SelectionMode = SelectionMode.One;
    this.radListControl1.Items.Add("Item 1");
    this.radListControl1.Items.Add("Item 2");
    this.radListControl1.Items.Add("Item 3");
    this.radListControl1.Items.Add("Item 4");
    this.radListControl1.Items.Add("Item 5");
     
    this.radListControl1.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(radListControl1_SelectedIndexChanged);
    this.radListControl1.SelectedItem = this.radListControl1.Items[0];
}
void radListControl1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
    MessageBox.Show(this.radListControl1.Items[e.Position].Text);
}

Please try this sample and if you have further issues, please include a sample that demonstrates your issue.
Thanks
Richard
0
Muthu
Top achievements
Rank 1
answered on 24 Mar 2011, 12:07 PM
Hi,
we tried based on your code snippet.. but it doesnot seem to solve the issue..
note: my query is regarding listbox and not list control.(but we also tried by changing the control to radlistcontrol and using the suggested eventhandler).

let me repeat the scenario again:  We are using a Radlistbox, we populate it dynamically at runtime. After getting populated the item at the top gets selected by default. When we click on that top most item we want that item value to be placed in a textbox, for that we wrote some code in the selectedindexchanged event of the listbox. But when we select the item at the top the selectedindexchanged event doesnot gets fired. But if we select other items in the list box(say one item that is not selected by default) then the selectedindexchanged event gets fired. pls let me know why this is happening and what is the solution for it?

Pls find the sample code for data population in radlistbox
private void txtOwnerFirstName_TextChanged(object sender, EventArgs e)
        {
                DataTable dt = cgd.GetOwnerInfoSearch(CommonUtils.Constants.OwnerFirstName, txtOwnerFirstName.Text);
                if (dt != null && dt.Rows.Count > 0)
                {
                    radCmbNames.DataSource = dt;
                    radCmbNames.DisplayMember = "NAME";
                    radCmbNames.ValueMember = "Time";
                      
                }
}


Pls find the sample code on selectedindexchanged in listbox
private void radCmbNames_SelectedIndexChanged(object sender, EventArgs e)
        {
if (radCmbNames.SelectedItem != null)
                {
                    DataTable dt = GetData(radCmbNames.SelectedValue.ToString());
                    if (dt.Rows.Count != 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            txtEmail.Text = dr["OWNER_EMAIL"].ToString();
                       }
                    }
                }
}

Pls let me know if anything requires clarification
0
Richard Slade
Top achievements
Rank 2
answered on 24 Mar 2011, 12:16 PM
Hello,

Apologies, I presumed you meant ListControl as you have posted in the ListControl forum and not the (now obsolete) ListBox forum.
Unfortunatly, I don't have access to the old control to be able to try this out for you. I would advise though that you upgrade to the latest version of the RadControls in order to take advantage of the newer ListControl and all the other fixes, enhancements and new controls that are available on the Q1 2011 Release.

As I cannot try this out, I'm unable to offer much advice, though an possible solution may be to register for a click event on each of the items in your ListBox.

If you need anything further please let me know
Regards,
Richard
0
Peter
Telerik team
answered on 25 Mar 2011, 05:21 PM
Hi,

Thank you for the question.

As of Q2 2010 RadComboBox and RadListBox (and their respective elements) are obsolete and will be removed in one of our next releases. All issues reported by our customers concerning RadComboBox and RadListBox are addressed in the corresponding successor controls - RadDropDownList and RadListControl.

Specifically regarding your case, I would suggest that you replace the RadListBox with RadDropDownList.

I hope this information helps.

Best wishes,
Peter
the Telerik team
0
Kiran
Top achievements
Rank 2
answered on 20 Mar 2012, 08:09 AM
Do the  AutoPostBack="true"  for RadListBox then it will fire  event.

thanks,
kiran.

0
Jeremy
Top achievements
Rank 1
answered on 04 Aug 2014, 07:04 PM
Well, I just updated my TelerikDevTools and the RadListBox is still available, still needed and still not working as advertised.
I'm using the RadListBoxes to move items around as described in http://demos.telerik.com/aspnet-ajax/listbox/examples/overview/defaultcs.aspx#qsf-demo-source

But I also need to display information about the single selected item so the user knows if this is the right item to move.  However, the OnSelectedIndexChanged event is not firing.
<telerik:RadListBox runat="server" ID="AllGroupsRadListBox" Height="200px" Width="200px" AllowTransfer="true" SelectionMode="Single" TransferToID="SharedGroupsRadListBox" OnSelectedIndexChanged="AllGroupsRadListBox_SelectedIndexChanged" />
<telerik:RadListBox runat="server" ID="SharedGroupsRadListBox" Height="200px" Width="200px" /><br />
Users in selected group:<br />
<telerik:RadListBox runat="server" ID="UsersRadListBox" Height="200px" Width="200px" />

private void FillAllGroups()
{
BWGroups allGroups = new BWGroups();
allGroups.GetAllBWGroups();

AllGroupsRadListBox.DataTextField = "BWGroupName";
AllGroupsRadListBox.DataValueField = "BWGroupID";
AllGroupsRadListBox.DataSource = allGroups.BWGroupList;
AllGroupsRadListBox.DataBind();
}

protected void AllGroupsRadListBox_SelectedIndexChanged(object sender, EventArgs e)
{
int parseGroupId = -1; Int32.TryParse(AllGroupsRadListBox.SelectedValue.ToString(), out parseGroupId);
BWUsers usersInGroup = new BWUsers();

if(parseGroupId > 0)
usersInGroup.GetActiveBWUsersByGroupID(parseGroupId);

UsersRadListBox.DataTextField = "BWGroupName";
UsersRadListBox.DataValueField = "BWGroupID";
UsersRadListBox.DataSource = usersInGroup.BWUserList;
UsersRadListBox.DataBind();
}

The event is never fired.
0
Jeremy
Top achievements
Rank 1
answered on 04 Aug 2014, 08:44 PM
I replaced OnSelectedIndexChanged with OnClientSelectedIndexChanged but now I'm getting a script error on the JS.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 Aug 2014, 07:32 AM
Hello Jeremy,

Thank you for writing.

It seems that your question is related to RadListBox from the UI for ASP.NET AJAX suite. However, this forum concerns Telerik UI for WinForms. I would kindly ask you to post your question in the appropriate forum, where you can get adequate answer.

Thank you for your understanding.

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Sean
Top achievements
Rank 1
answered on 20 Nov 2018, 06:41 PM

Hello, 

I just updated to 2013.3.914.45 version and RadListControl doesnot seem to be available. I been looking at documentations and stuff but nothing indicates version it will be released under or if i have to do something specific to make it available. I usually do <telerik:RadListBox .... /> but saying <telerik:RadListControl  ... /> or <telerik:ListControl ... /> is not valid. I was wondering if someone could help me out. 

Thank you,

Sean

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Nov 2018, 09:39 AM
Hello, Sean, 

I would like to note that this forum is related to the Telerik UI for WinForms suite. However, your question seems to be related to another product.

Feel free to post your technical questions in the relevant forum. Thus, the appropriate community will gladly assist you: https://www.telerik.com/forums

Thank you for your understanding.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ListControl
Asked by
Muthu
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Muthu
Top achievements
Rank 1
Peter
Telerik team
Kiran
Top achievements
Rank 2
Jeremy
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Sean
Top achievements
Rank 1
Share this question
or