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

custom cell type

Thread ID:

Created:

Updated:

Platform:

Replies:

49800 Sep 27,2006 07:19 AM UTC Nov 6,2006 09:16 AM UTC WinForms 14
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On September 27, 2006 07:19 AM UTC

hi!

I am using GDBC, Is there any custom cell some soft like auto complete list box? For example, When the user key in ''a'' then all the data begin with ''a'' is list down in a list.

Please advices, thanks!


Administrator [Syncfusion]
Replied On September 27, 2006 09:28 AM UTC

Hi Lim,

There is no built-in support for AutoComplete Textbox in a grid. If you want to do this, you need to go for Custom CellType.

A custom CellType can be created, it requires a model class and a renderer class. The model class handles the serialization requirements for the control and creates the renderer class. The renderer class handles the UI requirements of the cell. This sample in \Syncfusion\Essential Studio\4.1.0.10\windows\Grid.Windows\Samples\In Depth\DerivedCellControlTutorial can be referred.Please look at the sample for more detail

After creating the custom celltype, it has to be registered through CellModels.Add

//register new control
this.gridDataBoundGrid1.Model.CellModels.Add("MyAutoCompleteCell", new MyGridGenericControlCellModel(this.gridDataBoundGrid1.Model));

//Then you may use
style.CellType = "MyAutoCompleteCell";

Here is a sample for implementing it.
http://www.syncfusion.com/Support/user/uploads/TestProject_39bb70eb.zip

The ComboBox cell is not designed to do this. You need to use custom cell – ComboBoxAutocomplete in a cell. Please take a look, at the below sample for more details.

http://www.syncfusion.com/support/user/uploads/ComboBox_autocomplete.zip

Let me know if you need any assistance,

Regards,
Haneef

Administrator [Syncfusion]
Replied On September 28, 2006 08:13 AM UTC

hi haneef!

It''s working but it''s not suit my case. My grid(GDBC) is perform in this ways:

1. One of the column is editable. The data entered must be validated. If it''s invalid, the e.Cancel is set to true in the Validating event.
2. My grid''s datasource is a DataTable.
3. It allows to Add and Remove.

The example that you provided is contradicted with my requirement.

1. The AutoComplete cell is emptied instead it should contains the data from the datasource.
2. The autoComplete textbox is not only applied to one cell but is entire column.

Please help! Thanks!

Administrator [Syncfusion]
Replied On September 29, 2006 10:09 AM UTC

hi haneef!

let me know if you need more information from me.

Thanks!

Administrator [Syncfusion]
Replied On September 29, 2006 01:04 PM UTC

Hi Lim,

Thanks for being patience. We are currently working on this issue, which we will update the details soon.

Best regards,
Haneef

Administrator [Syncfusion]
Replied On October 5, 2006 02:25 AM UTC

hi,

I am still waiting for your reply.

Thanks!


Administrator [Syncfusion]
Replied On October 5, 2006 08:44 AM UTC

Hi Lim,

My sincere appologies in the delay.

There is no built-in support for adding the null datasource to the AutoComplete component. But you can handle the onIntilaize method (in the TextBoxAutoCompleteCellRenderer) and add the one empty row datatable to the Autocomplete.Datasource. Please refer to the attached sample for more details.

//set the value into the cell control & initialize it
protected override void OnInitialize(int rowIndex, int colIndex)
{
// Immeditaly switch into editing mode when cell is initialized.
GridStyleInfo style = Grid.Model[rowIndex, colIndex];
try
{
AutoCompleteDataColumnInfo info = style.Tag as AutoCompleteDataColumnInfo;

object datasource = style.DataSource;
if( datasource == null)
{
DataTable dt = new DataTable("AutoCompleteTable");
dt.Columns.Add(new DataColumn("DisplayField"));
dt.Rows.Add(new object[]{string.Empty});
dt.AcceptChanges();
this.CurrentStyle.DataSource = style.DataSource = dt;
}
if( info == null )
{
info = new AutoCompleteDataColumnInfo("DisplayField",200,true);
this.CurrentStyle.Tag = style.Tag = info;
}
myTextBox.Text = style.CellValue.ToString();
this.autoComplete1.SetAutoComplete(this.myTextBox,AutoCompleteModes.Both);
this.autoComplete1.DataSource = style.DataSource;

autoComplete1.Columns.Clear();
autoComplete1.Columns.Add(style.Tag as AutoCompleteDataColumnInfo);
}
catch (Exception ex)
{
Syncfusion.Diagnostics.TraceUtil.TraceExceptionCatched(ex);
}
base.OnInitialize(rowIndex, colIndex);
}

Sample : http://www.syncfusion.com/Support/user/uploads/TextBox_autocomplete_e6ff0fc.zip

Let us know if this helps.

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On October 6, 2006 10:02 AM UTC

Thanks haneef!

The solution that your provided is almost suit my needs..

But there is still lack of something.. I''ve tried to modify by myself, but i failed to do it.
It''s too complicated for me..
Please help me to solve the problems as follow:

When i pressed a key ''S'' then the full word ''ShowData0'' is displayed. When i pressed another key ''h'' followed by the ''S'', it should be still displayed ''ShowData0'' (same like normal AutoComplete Textbox) but the unexpected output is displayed which is ''ShowData0h''.

When the autoComplete list is pop up,i cant use the arrow key to select the data in the list.

Sometime when i focus on the cell(AutoComplete) and i pressed the Esc key, my form is out of the control.. some event is keep looping. And sometime the position of the AutoCompleteListBox is at the top of the form, instead it should be at the below of the cell.

If there is two data in the list(''1'' and ''12''), when i pressed ''1'', the value that i expected in the textbox should be ''1'' but the output is ''12''.

It''s not very urgent, please take your time.
I am looking forward for your best solution.
Thanks!

Best Regards,
Lim


Administrator [Syncfusion]
Replied On October 6, 2006 10:56 AM UTC

Hi Lim,

Issue 1: Unexpected Output in autocomplete

You need to set the autoComplete.AutoCompleteModes proerty to AutoCompleteModes.AutoSugges. Below is a code snippet.

this.autoComplete1.SetAutoComplete(this.myTextBox, AutoCompleteModes.AutoSuggest);

Issue 2: PopUp Location

You need to derive the TextBox control and override the ProcessCmdKey method to handle the Escape key in a TextBox.

protected override bool ProcessCmdKey(ref Message msg,Keys keyData)
{
if(keyData == Keys.Enter)
return true;
else if(keyData == Keys.Escape)
return true;

if(msg.Msg == 0x100 && keyData != Keys.Tab) //keydown...
this.OnTextChanged(EventArgs.Empty);
return base.ProcessCmdKey(ref msg, keyData);
}

Modified Sample : http://www.syncfusion.com/Support/user/uploads/TextBox_autocomplete_af7119d4.zip

Let me know if you need any further assistance.

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On October 7, 2006 02:59 AM UTC

hi haneef!

How to i use the arrow key to select the data in the list? (Same as the normal autoComplete textbox)

The position of the ListBox is still not in the right position. You can reproduce the problem in this way: Click on the cell and press ''1'' and then use the Arrow Key to move down. The ListBox is pop up at the top left corner.

Thanks!


Administrator [Syncfusion]
Replied On October 10, 2006 12:33 PM UTC

Hi Lim,

You would have to derive the TextBox control and override the ProcessCmdKey method to handle the DownArrow key in a TextBox

protected override bool ProcessCmdKey(ref Message msg,Keys keyData)
{
if(keyData == Keys.Enter || keyData == Keys.Down )
{
this.OnKeyDown(new KeyEventArgs(keyData));
return true;
}
//Your code...
}

Sample: http://www.syncfusion.com/Support/user/uploads/TextBox_autocomplete_d38f8753.zip

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On October 12, 2006 06:29 AM UTC

hi haneef!


The position of the ListBox is still not in the right position. You can reproduce the problem in this way: Click on the cell and press ''1'' and then use the Arrow Key to move up and then press ''1'' again. The ListBox is pop up at the top left corner.

Thanks!

Administrator [Syncfusion]
Replied On October 20, 2006 07:09 AM UTC

hi haneef,

Please let me know if you need more information.

Thanks!

Administrator [Syncfusion]
Replied On November 6, 2006 02:28 AM UTC

hi,

Any solution of the problem?

Please let me know if you need more information.

Thanks!

Administrator [Syncfusion]
Replied On November 6, 2006 09:16 AM UTC

Hi Lim,

My sincere appologies in the delay.

You can override the OnKeyPress method (in the TextBoxAutoCompleteCellRenderer) and call the CurrentCell.BeginEdit(true) when the myTextBox didn't get the focused. Please find the code snippet below.

//handle initial keystroke on inactive cell, passing it to the datetimepicker
protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
if(!myTextBox.Focused)
{
CurrentCell.BeginEdit(true);
myTextBox.Focus();
SendKeys.Send( new string(e.KeyChar, 1) );
}
base.OnKeyPress(e);
}

Let me know if this helps.

Best Regards,
Haneef

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

;