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.
Unfortunately, activation email could not send to your email. Please try again.

How to set grid bound data grid columns As a Auto complete in sync fusion in c#

Thread ID:

Created:

Updated:

Platform:

Replies:

116433 May 24,2014 12:23 AM Nov 30,2016 07:27 AM Windows Forms 5
loading
Tags: GridDataBoundGrid(Classic)
Venkaiah
Asked On May 24, 2014 12:23 AM

Hi Viewers,

Here I am trying to set  grid  bound data grid  column as a Auto complete how i can do give me guidance please 
(here grid  bound data grid having 5 columns Among those columns Column 1 i need to set as a Auto complete )


thank in Advance 





Neelakandan Kannan [Syncfusion]
Replied On May 27, 2014 08:52 AM

Hi Venkaiah,

 

Thanks for your interest in Syncfusion Products.

 

Query:

Auto complete

 

We would like to let you know that the reported scenario can be achieved by assigning ComboBox celltype type to that particular column.


Please refer the following UG link.

 

http://help.syncfusion.com/ug/windows%20forms/grid/default.htm#!Documents/autocompletesupportf.htm
 


Please let us know if you have any concerns.

 

Regards,

Neelakandan

 


Revathi K [Syncfusion]
Replied On May 29, 2014 01:04 AM

From: venky star [mailto:venkystr5@gmail.com]
Sent: Thursday, May 29, 2014 12:02 AM
To: Syncfusion Support
Subject: Re: Syncfusion support community forum 116433, How to set grid bound data grid columns As a Auto complete in sync fusion in c#, has been updated.

 

Hi Viewer,

 

 Your answer is use full for Data bound data grid columns once As a Combo box its possible to set Auto complete easily, But What i am asking is In Data bound data grid having text box/(original text box)  default right so that  column i need to set as a Auto complete  So please  give me guidance for this task.

 

 

 

thank you in Advance 


Neelakandan Kannan [Syncfusion]
Replied On June 4, 2014 12:39 AM

Hi Venkaiah,

 

Thanks for your updates.

 

 

 

 

Query

Auto Complete Text Box in GridControl

 

 

 

       ShowButtons property ensures  that  show or hide  the cell button in Grid. So, If we set this property to hide, we can display combo box cell as a text box.

         AutoCompleteInEditMode Property ensures  that enabling auto complete. So, You can make use of below code,

 

CODESNIPPET[C#]:

 

private void Form1_Load(object sender, EventArgs e)

        {

            AutoCompleteStringCollection stringcol=new AutoCompleteStringCollection();

            stringcol.Add("One");

            stringcol.Add("Two");

            stringcol.Add("Three");

            this.gridControl1[1, 1].CellType = GridCellTypeName.ComboBox;

            this.gridControl1[1, 1].DataSource = stringcol;

            gridControl1[1,1].DropDownStyle = GridDropDownStyle.Editable;

            gridControl1[1, 1].AutoCompleteInEditMode = GridComboSelectionOptions.AutoComplete;

            gridControl1[1, 1].ShowButtons = GridShowButtons.Hide;

 

   }

 

 

Please let us know if you have any concerns,

 

Regards,

Neelakandan


Mukesh Rebari
Replied On November 29, 2016 10:51 AM

HI,

 Ok, So if we decide to use Combobox then also tell us how could we assign DataSource for Combobox dynamically i.e. filtered data in datasource based on what user has typed in.

Piruthiviraj Malaimelraj [Syncfusion]
Replied On November 30, 2016 07:27 AM

Hi Mukesh, 

Thanks for the update. 

We have analyzed your scenario and created the simple sample as per your requirement. By default, particular cell style cannot be changed at run time for the GridDataBoundGrid without using QueryCellInfo event. So the datasource of the particular cell cannot be changed on run time. 

In order to change the data source of the ComboBoxCell based on the text typed in the cell dynamically, custom cell renderer and cell model which is derived fromComboBoxCellRenderer and ComboBoxCellModel can be used. 

Code example: 

//Adding cellmodel 
this.gridDataBoundGrid1.Model.CellModels.Add("CustomComboBox", new CustomComboxBoxCellModel(this.gridDataBoundGrid1.Model)); 
//Assigning CellType 
this.gridDataBoundGrid1.Model.ColStyles["Description"].CellType = "CustomComboBox"; 
 
public class CustomComboxBoxCellModel : GridComboBoxCellModel 
{ 
    public CustomComboxBoxCellModel(GridModel grid) 
        : base(grid) 
    { 
    } 
    /// <summary> 
    /// Creates a cell renderer. 
    /// </summary> 
    /// <param name="control">The grid control.</param> 
    /// <returns>Cell renderer.</returns> 
    public override GridCellRendererBase CreateRenderer(GridControlBase control) 
    { 
        return new CustomComboBoxCellRenderer(control, this); 
    } 
} 
 
public class CustomComboBoxCellRenderer : GridComboBoxCellRenderer 
{ 
    GridStyleInfo cellStyle = null; 
 
    public CustomComboBoxCellRenderer(GridControlBase grid, GridCellModelBase cellModel) 
        : base(grid, cellModel) 
    { 
        cellStyle = GridStyleInfo.Default; 
    } 
    Hashtable styleCollection = new Hashtable(); 
 
    protected override void OnSetControlText(string text) 
    { 
        if (text == "Desc6") 
        { 
            if (!styleCollection.ContainsKey(GridRangeInfo.Cell(this.RowIndex, this.ColIndex))) 
            { 
                GridStyleInfo style = GridStyleInfo.Empty; 
                style.CopyFrom(this.StyleInfo); 
                DataTable table = new DataTable(); 
                table.Columns.Add("Description"); 
                table.Columns.Add("Desc_ID"); 
                table.Rows.Add("Desc1", 1); 
                table.Rows.Add("Desc2", 2); 
                table.Rows.Add("Desc3", 3); 
                style.DataSource = table.DefaultView; 
 
                style.DisplayMember = "Description"; 
                style.ValueMember = "Desc_ID"; 
 
                styleCollection.Add(GridRangeInfo.Cell(this.RowIndex, this.ColIndex), style); 
            } 
        } 
 
        base.OnSetControlText(text); 
    } 
 
    protected override void OnKeyPress(KeyPressEventArgs e) 
    { 
        this.Grid.CurrentCell.ShowDropDown(); 
        base.OnKeyPress(e); 
    } 
 
    public override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e) 
    { 
        base.OnPrepareViewStyleInfo(e); 
 
        if (styleCollection.Contains(GridRangeInfo.Cell(e.RowIndex, e.ColIndex))) 
        { 
            GridStyleInfo modifiedStyle = ((GridStyleInfo)styleCollection[GridRangeInfo.Cell(e.RowIndex, e.ColIndex)]); 
            e.Style.DataSource = modifiedStyle.DataSource; 
            e.Style.DisplayMember = modifiedStyle.DisplayMember; 
            e.Style.ValueMember = modifiedStyle.ValueMember; 
        } 
    } 

} 

Please refer to the below KB , 

https://www.syncfusion.com/kb/6951/how-to-change-the-datasource-for-combobox-cell-dynamically  

Sample link: 

http://www.syncfusion.com/downloads/support/forum/116433/ze/GDBG_Sample1683522447 

Regards, 
Piruthiviraj 


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.

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.

;