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 avoid anyother text in Combo box cell type

Thread ID:

Created:

Updated:

Platform:

Replies:

95122 Jun 22,2010 05:45 AM Jun 30,2010 06:54 AM ASP.NET Web Forms (Classic) 5
loading
Tags: GridGroupingControl
Vaibhav Sanghavi
Asked On June 22, 2010 05:45 AM

I have a column which is of type ComboBox in a gridgrouping control.

Grid.TableDescriptor.Columns[ABC].Appearance.AnyCell.CellType = "ComboBox";

I have given a choice list for this combo box to choose value from. But I am able to put anyother text in this field.

Is there any settings which can prevent this?

Thanks
Vaibhav

Christopher Issac Sunder K [Syncfusion]
Replied On June 23, 2010 08:15 AM

Hi Vaibhav,

Thank you for your interest in Syncfusion products.

Preventing any other text rather than the choice list of the combo box cell in GridGroupingControl can be achieved by setting the DropDownStyle property to “AutoComplete”.


StringCollection str = new StringCollection();
str.AddRange(year);
this.gridGroupingControl1.DataSource = dt;
this.gridGroupingControl1.TableDescriptor.Columns["Year"].Appearance.AnyRecordFieldCell.CellType = "ComboBox";
this.gridGroupingControl1.TableDescriptor.Columns["Year"].Appearance.AnyRecordFieldCell.ChoiceList = str;
this.gridGroupingControl1.TableDescriptor.Columns["Year"].Appearance.AnyRecordFieldCell.DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.AutoComplete; // set this to avoid any other text.


Please refer the following sample which illustrates the above.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GGC_AutoComplete284425996.zip

Please let me know if you have any other concerns.

Regards,
Christopher K.

Vaibhav Sanghavi
Replied On June 28, 2010 06:10 AM

Thanks. Works beautifully.

Is there also a way to avoid same drop down value if its already selected in any other record for the same column?

Vaibhav

Christopher Issac Sunder K [Syncfusion]
Replied On June 29, 2010 10:12 AM

Hi Vaibhav,

Thanks for the update.

You could achieve the desired behavior in combo box cell by handling the PrepareViewStyleInfo event with the following code. Here I have created two methods named “IntersectCollection()” and “GetCellValues()” to filter the cell values.


this.gridGroupingControl1.TableControlPrepareViewStyleInfo += new GridTableControlPrepareViewStyleInfoEventHandler(gridGroupingControl1_TableControlPrepareViewStyleInfo);

void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridTableCellStyleInfoIdentity id = this.gridGroupingControl1.TableModel[e.Inner.RowIndex, e.Inner.ColIndex].CellIdentity as GridTableCellStyleInfoIdentity; if(id.Column!=null && id.Column.Name.Equals("Year"))
{
e.Inner.Style.ChoiceList = IntersectCollection();
}
}

public StringCollection IntersectCollection()
{
int row, col;
this.gridGroupingControl1.TableDescriptor.ColumnToRowColIndex("Year", out row, out col);

StringCollection str = new StringCollection();
StringCollection s = GetCellValues(col + 1);

if (s.Count > 0)
{
foreach (string st in year)
{
if (!s.Contains(st) && !str.Contains(st))
str.Add(st);
}
}
return str;
}

public StringCollection GetCellValues(int colIndex) // separate the available choices
{
StringCollection str1 = new StringCollection();
if (this.gridGroupingControl1.TableModel.CurrentCellInfo != null)
{
for (int i = 3; i < this.gridGroupingControl1.TableModel.RowCount + 1; i++)
{
string value = "";
if (this.gridGroupingControl1.TableModel[i, colIndex].CellValue != null)
value = this.gridGroupingControl1.TableModel[i, colIndex].CellValue.ToString();
str1.Add(value);
}
}
return str1;
}


Please refer the following sample which illustrates the above.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GGC_Separate528536529.zip

Please let me know if you have any other concerns.

Regards,
Christopher K.

Vaibhav Sanghavi
Replied On June 30, 2010 02:07 AM

Thanks. I was just interested if there is any property which will prevent me selecting any option from choice list whihc has been already selected for other recoreds. But looks like there is none. I already wrote thich check by capturing RecordValueChanging event.


Jisha Joy [Syncfusion]
Replied On June 30, 2010 06:54 AM

Hi Vaibhav,

Thank you for your update. There is no property setting available to prevent selection of option from choicelist which has been already selected for other records. You need to achieve the desired behavior like one done in the previous update.

Regards,
Jisha

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.

;