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

AutoComplete object and GridGroupingControl

Thread ID:

Created:

Updated:

Platform:

Replies:

76148 Aug 25,2008 02:31 PM UTC Jun 22,2017 04:50 AM UTC WinForms 15
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 25, 2008 02:31 PM UTC

Hi,

It is possible to have an autocompletion object attached to a textbox in a gridgroupingcontrol?

I'm trying to attach this object with the function SetAutoComplete(control, mode) but nothing happend when I'm typing some text into the cell. Do you have any suggestion to do this?

Thanks,

Fred


SubhaSheela R [Syncfusion]
Replied On August 26, 2008 05:53 AM UTC

Hi Julien,

Thanks for using Syncfusion Products.

GridConditionalFormatDescriptor only allow you to row formatting. If you want to format any one cell, then you need to use QueryCellStyleInfo or PrepareViewStyleInfo event to achieve that. Below is the example that shows to change backcolor of a negative value cell and bracket for nagative value cell. Please refer to the below code in which QueryCellStyleInfo event is used to achieve your need.


this.gridGroupingControl1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell
|| e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
{
if (e.TableCellIdentity.Column.MappingName == "B")
{
int cellvalue = Convert.ToInt32(e.Style.CellValue);
if (cellvalue < 0)
{
e.Style.BackColor = Color.Red;
e.Style.Format = "{#,##}"; // You can set your own format
}
}
}
}


Please refer to the sample given below which illustrates the above:

http://websamples.syncfusion.com/samples/Grid.Windows/I41286/main.htm

Please let me know if you have any question.

Regards,
Subhasheela R




Administrator [Syncfusion]
Replied On August 26, 2008 12:58 PM UTC

Hi,

Thanks for your answer but, I'm not sure you understand my question. I know how to use the QueryCellStyleInfo but I don't know how to use the AutoComplete object with a textbox inside the function QueryCellStyleInfo. When the user will use my grid, I want to suggest some keywords when he will enter some character in a textbox inside the gridgroupingcontrol.

How can I do that?

Fred


Sri Rajan [Syncfusion]
Replied On August 29, 2008 01:27 PM UTC

Hi Fred,

Thank you for your interest in Syncfusion products.

Here is the minimal sample which shows you how to add AutoComplete in GridGroupingControl Cell.

http://websamples.syncfusion.com/samples/grid.windows/I76148Aug29/main.htm

Please let me know if this helps.

Best Regards,
Srirajan.


Administrator [Syncfusion]
Replied On September 2, 2008 06:45 PM UTC

Thanks for your answer.

Your example is good but I don't want to use another textbox control inside the GGC. I want to use the default grid cell and associate an autocomplete object with it ...

I want to do something like that :

e.Style.CellType = "MaskEdit"

this.autocomplete1.SetAutoComplete(e.Inner.Control, MyMethod);


All cells in the GGC will be "MaskEdit". I want an autocomplete object associated with each cells.

How can I do that?

Thanks,

Fred


>Hi Fred,

Thank you for your interest in Syncfusion products.

Here is the minimal sample which shows you how to add AutoComplete in GridGroupingControl Cell.

http://websamples.syncfusion.com/samples/grid.windows/I76148Aug29/main.htm

Please let me know if this helps.

Best Regards,
Srirajan.




Nisha Arockiya A [Syncfusion]
Replied On September 10, 2008 12:47 PM UTC

Hi Fred,

Thanks for being patience.

Making Autocomplete functionality as a property of Grid cell, as you requested is not possible.We can make a Grid cellType as Control and can access the autocomplete property.Sorry for the inconveniece caused. Please let me know any further queries.

Regards,
Nisha

>Thanks for your answer.

Your example is good but I don't want to use another textbox control inside the GGC. I want to use the default grid cell and associate an autocomplete object with it ...

I want to do something like that :

e.Style.CellType = "MaskEdit"

this.autocomplete1.SetAutoComplete(e.Inner.Control, MyMethod);


All cells in the GGC will be "MaskEdit". I want an autocomplete object associated with each cells.

How can I do that?

Thanks,

Fred


>Hi Fred,

Thank you for your interest in Syncfusion products.

Here is the minimal sample which shows you how to add AutoComplete in GridGroupingControl Cell.

http://websamples.syncfusion.com/samples/grid.windows/I76148Aug29/main.htm

Please let me know if this helps.

Best Regards,
Srirajan.






hieudt
Replied On June 12, 2017 01:47 AM UTC

Hi Fred,

Thank you for your interest in Syncfusion products.

Here is the minimal sample which shows you how to add AutoComplete in GridGroupingControl Cell.

http://websamples.syncfusion.com/samples/grid.windows/I76148Aug29/main.htm

Please let me know if this helps.

Best Regards,
Srirajan.


Hi,

Can you re-upload a sample. I want to know how to add AutoComplete TextBox in GridGroupingControl Cell.

Thanks.

Arulpriya Ramalingam [Syncfusion]
Replied On June 12, 2017 09:42 AM UTC

Hi Customer, 

Thanks for your update. 

We have provided the sample for TextBox with AutoComplete property. Please find the below attached sample, 

 
Please let us know if you need any further assistance. 

Regards, 
Arulpriya 


hieudt
Replied On June 13, 2017 02:05 AM UTC

Hi Customer, 

Thanks for your update. 

We have provided the sample for TextBox with AutoComplete property. Please find the below attached sample, 

 
Please let us know if you need any further assistance. 

Regards, 
Arulpriya 


Hi,

Thanks for your sample, but I have two additional questions

1. how I use BindingSource instead of ChoiceList, I try gridGroupingControl1.TableDescriptor.Columns["Note"].Appearance.AnyRecordFieldCell.DataSource = SomeBindingSource, but not working

2. gridGroupingControl1.TableDescriptor.Columns["Note"].Appearance.AnyRecordFieldCell.AutoCompleteInEditMode = GridComboSelectionOptions.AutoSuggest; : it do not show the list when I type

Regards

Arulpriya Ramalingam [Syncfusion]
Replied On June 13, 2017 06:22 PM UTC

Hi Customer, 

Thanks for your update. 

Query 
Response 
how I use BindingSource instead of ChoiceList, I try gridGroupingControl1.TableDescriptor.Columns["Note"] .Appearance.AnyRecordFieldCell.DataSource = SomeBindingSource, but not working 
The DataSource is set as binding source and the data are binds to the column. Please refer the attached video. 
Can you please provide the below details which will help us to analyze further and provide you a better solution. 
  • Can you please provide your product version and frame work version to analyze further and provide you a better solution.
  • Can you please confirm us that whether you are facing any Exception issue or not.
 
The AutoSuggestion will have the support only for the below DataSources 
  • StringCollection (i.e. ChoiceList)
  • DataTable
  • ArrayList
So, if you are setting the DataSource as BindibingSource, Please ensure that the datasource of the Binding source should be DataTable or ArrayList. 

We have modified the sample as per your requirement. Set the BindingSource.DataSource as DataSource for the Column to set the AutoSuggestTextBox column. Please make use of below code and sample, 
gridGroupingControl1.TableDescriptor.Columns["ID"].Appearance.AnyRecordFieldCell.DataSource = bindingSource.DataSource; 
gridGroupingControl1.TableDescriptor.Columns["Note"] .Appearance.AnyRecordFieldCell.AutoCompleteInEditMode = GridComboSelectionOptions.AutoSuggest; : it do not show the list when I type 
The DropDown will not be opened when the ComboBox button is hidden. The AutoSuggestion will be shown only when the DropDown is opened. In order to open the DropDown on KeyPress, the CurrentCellKeyPress event can be used. In that event, ShowDropDown() method can be used to open the DropDown. Please make use of below code and sample, 

//Event triggering 
gridGroupingControl1.TableControlCurrentCellKeyPress += GridGroupingControl1_TableControlCurrentCellKeyPress; 
 
//Event customization 
private void GridGroupingControl1_TableControlCurrentCellKeyPress(object sender, GridTableControlKeyPressEventArgs e) 
{ 
    if (this.gridGroupingControl1.TableControl.CurrentCell.Renderer is GridComboBoxCellRenderer) 
        this.gridGroupingControl1.TableControl.CurrentCell.ShowDropDown(); 
} 


Regards, 
Arulpriya 


hieudt
Replied On June 14, 2017 09:56 AM UTC

Hi,

Thanks for your help, it workings, but I have two problems

1. Case sensitive : if list contains capital character and I type lowercase character, grid will not filter

2. If I choose value (eg. A0) and leave cell, come back cell and type different character (eg. B or C), grid will not filter until I delete all and type again

I have attached a sample for you

Regards
Attachment: AutoSuggestSample_6a457277.rar

Arulpriya Ramalingam [Syncfusion]
Replied On June 15, 2017 04:43 PM UTC

Hi Customer, 
 
Thanks for your update. 
 
Query 
Response 
 
Case sensitive : if list contains capital character and I type lowercase character, grid will not filter 
 
In order to set a AutoComplete TextBox as Case-insensitive, the TableConrolCurrentCellKeyPress and TableControlCurrentCellKeyUp events can be used. Please make use of below code and sample, 
 
//Event Triggering 
this.gridGroupingControl1.TableControlCurrentCellKeyPress += gridGroupingControl1_TableControlCurrentCellKeyPress; 
 
//Event Customization 
 void gridGroupingControl1_TableControlCurrentCellKeyPress(object sender, GridTableControlKeyPressEventArgs e) 
 { 
     GridCurrentCell currentCell = e.TableControl.CurrentCell; 
     GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(currentCell.RowIndex, currentCell.ColIndex); 
 
     if (style.CellType == "ComboBox") 
     { 
         GridComboBoxCellRenderer renderer = currentCell.Renderer as GridComboBoxCellRenderer; 
         if (renderer.ControlText == string.Empty) 
         { 
             text = e.Inner.KeyChar.ToString(); 
         } 
 
         if (renderer.ControlText != string.Empty) 
         { 
             text = renderer.ControlText + e.Inner.KeyChar; 
         } 
         rowFilterText = "[" + dataTable.Columns[dataTable.Columns[style.DisplayMember].Ordinal].ColumnName + "]" + " LIKE '" + "%" + text + "%'"; 
         listDataView = new DataView(this.dataTable, rowFilterText, null, DataViewRowState.CurrentRows); 
         if (listDataView.Count > 0) 
         { 
             renderer.ListBoxPart.DataSource = listDataView; 
             currentCell.ShowDropDown(); 
         } 
     } 
 } 
 
//Event Triggering 
this.gridGroupingControl1.TableControlCurrentCellKeyUp += gridGroupingControl1_TableControlCurrentCellKeyUp; 
 
//Event customization 
 void gridGroupingControl1_TableControlCurrentCellKeyUp(object sender, GridTableControlKeyEventArgs e) 
 { 
     GridCurrentCell currentCell = e.TableControl.CurrentCell; 
     GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(currentCell.RowIndex, currentCell.ColIndex); 
     if (style.CellType == "ComboBox") 
     { 
         GridComboBoxCellRenderer renderer = currentCell.Renderer as GridComboBoxCellRenderer; 
         if (renderer.ControlText == string.Empty) 
         { 
             renderer.ListBoxPart.DataSource = dataTable; 
         } 
     } 
 } 
 
If I choose value (eg. A0) and leave cell, come back cell and type different character (eg. B or C), grid will not filter until I delete all and type again 
We have created a simple sample as per your requirement. In order to display the suggested values as per your scenario, CustomComboBoxCellModel and CustomComboBoxCellRenderer can be created. In CustomComboBoxCellRenderer the OnKeyPress method can be overridden to filter the values on key press (i.e. as per your scenario). Please make use of below code and sample, 
 
//To suggest the the values on key press 
public class CustomComboBoxCellRenderer : GridComboBoxCellRenderer 
{ 
    public CustomComboBoxCellRenderer(GridControlBase grid, GridCellModelBase cellModel) 
        : base(grid, cellModel) 
    { 
    } 
    protected override void OnKeyPress(KeyPressEventArgs e) 
    { 
        
        if (this.StyleInfo.DropDownStyle == GridDropDownStyle.Editable 
                    && this.StyleInfo.AutoCompleteInEditMode == GridComboSelectionOptions.AutoSuggest) 
        { 
            ControlText = TextBox.Text.Remove(TextBox.SelectionStart, TextBox.SelectionLength); 
            base.OnKeyPress(e); 
        } 
       
 
    } 
} 
 
 
Arulpriya 


hieudt
Replied On June 19, 2017 07:00 AM UTC

Hi,

Thanks for your help. The second problem has been solved, but the case sensitive not working. Alone it works fine, but not when putting together with the second code.

I have attached  my modified sample for you.

Regards
Attachment: AutoSuggestSample_3a2734d9.rar

Arulpriya Ramalingam [Syncfusion]
Replied On June 20, 2017 01:18 PM UTC

Hi Customer, 

Thanks for your update. 

We have modified the sample with the provided solutions in our last update. The reported scenarios(Case-Insensitive and filter the values without delete all)  can be achieved by customizing the OnKeyPress overridden method of CustomGridComboBoxCellRenderer. 

Code snippet 
 
protected override void OnKeyPress(KeyPressEventArgs e) 
{ 
    CurrentCell.ShowDropDown(); 
    if (this.StyleInfo.DropDownStyle == GridDropDownStyle.Editable 
       && this.StyleInfo.AutoCompleteInEditMode == GridComboSelectionOptions.AutoSuggest) 
    { 
        ControlText = TextBox.Text.Remove(TextBox.SelectionStart, TextBox.SelectionLength); 
        SetSuggestedChoices(ListBoxPart, this.ControlText + e.KeyChar.ToString()); 
 
    } 
    ListBoxPart.SelectedIndex = 0; 
} 
internal void SetSuggestedChoices(ListBox listBoxPart, string searchText) 
{ 
   ……. 
   ……. 
} 
private void GetlistFromTable(ListBox listBoxPart, string searchText, object dataSource) 
{ 
    ….. 
    ….. 
} 
private void GetlistFromArray(ListBox listBoxPart, string searchText, object dataSource) 
{ 
    ArrayList arrayList = (ArrayList)dataSource; 
    IList list = (IList)arrayList; 
    List<string> intList = new List<string>(); 
    List<string> clist = new List<string>(); 
    string colName = listBoxPart.DisplayMember; 
 
    listBoxPart.DataSource = null; 
    listBoxPart.DisplayMember = colName; 
    listBoxPart.Items.Clear(); 
 
    foreach (object item in list) 
    { 
        //If any null item found, all the successive items will be skipped from adding it to list. 
        if (item == null) 
            break; 
        ListBoxPart.Items.Add(item); 
        clist.Add(item.ToString()); 
    } 
    listBoxPart.Items.Clear(); 
    foreach (string s in clist) 
    { 
        if (s.ToLower().Contains(searchText.ToLower())) 
            listBoxPart.Items.Add(s); 
    } 
} 
 
Note: 
The customization is based on AutoSuggest. If you want to customize it for AutoComplete, you can check the condition for GridComboSelectionOptions.AutoComplete in CustomGridComboBoxCellRenderer. 
 
 
Please let us know if you have any queries. 

Regards, 
Arulpriya 


hieudt
Replied On June 21, 2017 08:36 AM UTC

Hi,

It's working. Thanks for your great help and patience.

Regards


Arulpriya Ramalingam [Syncfusion]
Replied On June 22, 2017 04:50 AM UTC

Hi Customer,   

We are glad to hear that the provided solution is resolved your scenario.   

Please let us know if you need any further assistance.    
   
Regards,   
Arulpriya 


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

;