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. Image for the cookie policy date

How to set the datatable which has been binded to a column




I had binded a datatable to a datagrouping's column
            DataTable t = new DataTable();

            this.gridGroupingControl1.TableDescriptor.Columns["UserID"].Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.GridListControl;
            this.gridGroupingControl1.TableDescriptor.Columns["UserID"].Appearance.AnyRecordFieldCell.DataSource = t;

And I use the CurrentCellShowingDropDown event
  private void drugListGridGroupingControl_TableControlCurrentCellShowingDropDown(object sender, GridTableControlCurrentCellShowingDropDownEventArgs e)
        {
            
            if (e.TableControl.CurrentCell.Renderer is GridDropDownGridListControlCellRenderer)
            {
                GridDropDownGridListControlCellRenderer renderer = e.TableControl.CurrentCell.Renderer as GridDropDownGridListControlCellRenderer;
                renderer.ListControlPart.ItemHeight = 30;
                renderer.ListControlPart.AutoSizeColumns = true;
            }
        }


I want to set the table in the dropdown list.
1、How should I set the column's witdth.
2、How should I set the column headrow's height.
3、How should I set the cell into readonly except user uses the dropdown list.
thanks!

Attachment: Xshot0004_99e0ce40.zip

3 Replies

AK Adhikesevan Kothandaraman Syncfusion Team September 25, 2015 04:44 PM UTC

Hi Ligyste,

Thanks for contacting Syncfusion Support.

To customize the dropdown GridListControl’s column width and the row height, we need to get the renderer of the GridDropDownGridListControlCellRenderer cell using this renderer we can customize the grid of the ListControlPart. Please refer to the following code example,

Code Example:

GridDropDownGridListControlCellRenderer cellRenderer = this.gridGroupingControl1.TableControl.CellRenderers["GridListControl"] as GridDropDownGridListControlCellRenderer;

cellRenderer.ListControlPart.Grid.ColWidths[1] = 200;

cellRenderer.ListControlPart.Grid.RowHeights[0] = 30;

To restrict the edit mode of the cell we can set the ReadOnly for the cell in the query cell info event. Please refer to the following code example,

Code Example:
this.gridGroupingControl1.QueryCellStyleInfo += gridGroupingControl1_QueryCellStyleInfo;

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)

{

    if (e.TableCellIdentity != null && e.TableCellIdentity.Column != null

        && e.TableCellIdentity.Column.Name == "City")

    {

        GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;

        if (cc.HasCurrentCellAt(e.TableCellIdentity.RowIndex, e.TableCellIdentity.ColIndex))

        {

            if (cc.IsDroppedDown)

                e.Style.ReadOnly = false;

            else

                e.Style.ReadOnly = true;

        }

    }
}

Sample:
https://www.syncfusion.com/downloads/support/forum/120554/ze/CS-221767763

Regards,
Adhi



LI ligyste September 26, 2015 12:17 AM UTC

Thank you ,it's very helpful for me


AK Adhikesevan Kothandaraman Syncfusion Team September 28, 2015 06:17 AM UTC

Hi Ligyste,

We are happy that the provided information was helpful to you. Please contact us if you need any further assistance.

Regards,
Adhi

Loader.
Live Chat Icon For mobile
Up arrow icon