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
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
Regards,
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
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
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
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.
Peter
the Telerik team
thanks,
kiran.
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.
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
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
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