We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridFilterBar - Selecting an item in the ListBox

Thread ID:

Created:

Updated:

Platform:

Replies:

50761 Oct 18,2006 03:02 PM UTC Oct 18,2006 04:17 PM UTC WinForms 1
loading
Tags: GridControl
Daniel Roesch
Asked On October 18, 2006 03:02 PM UTC

Hi!

How can I select an item in a GridFilterBar's ListBox programmatically?

listBox.SelectedItem, listBox.SelectedIndex and listBox.SelectedValue don't work.

protected override void OnCreatingColumnHeader(GridFilterBarCreatingColumnHeaderEventArgs e) {
GridCurrentCell cc = _grid.CurrentCell;

if(cc.RowIndex == 1 && cc.ColIndex > 0) {
GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
if(cr == null) {
return;
}
ListBox lb = cr.ListBoxPart;
if(lb == null) {
return;
}


ArrayList al = ActiveFilters[e.ColName] as ArrayList;
if(al != null) {
if(al.Count == 1 && !e.ColName.Equals(CommonGlobals.FLD_STATUS)) {
DataRowView selectedItem = null;
foreach(DataRowView drv in lb.Items) {
if(drv[0].ToString().Equals(al[0].ToString())) {
selectedItem = drv;
}
}
if(selectedItem != null) {
lb.Items.Add(selectedItem);
lb.SelectedItem = selectedItem;
}
}
}
}

// base.OnCreatingColumnHeader (e);
}

Thanks for your help!!
Dan

Administrator [Syncfusion]
Replied On October 18, 2006 04:17 PM UTC

Hi Dan,

If you want to programmatically apply filter, you can set the FilterBar.RowFilter property. Try the code below to do this.

// get the columnindex on which filter must be applied
int col = this.gridDataBoundGrid1.Binder.NameToColIndex("Column Name");

this.gridDataBoundGrid1.Model[1, col].Text = "value"; // filter value
filterBar.RowFilter = "[Column Name] = 'value'";

Let me know if this is not what you needed.
Thanks,
Rajagopal

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;