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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I set the properties of a control in a Template from the QueryCellInfo event?

Thread ID:

Created:

Updated:

Platform:

Replies:

108575 Apr 30,2013 10:22 AM UTC Jun 24,2013 05:21 AM UTC WPF 5
loading
Tags: GridControl
Robert Dondo
Asked On April 30, 2013 10:22 AM UTC

How can I get the a control in the DataTemplate of the current row from within the 
QueryCellInfo event?

I want to set a strike-through on a combo-box which I am using in a template. I have the following (not working) code so far:

   private void grdResultsModelOnQueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
        {
 if (e.Style.CellType == "GridDataBoundTemplate")
                    {                      
                        var cboUsername = (ComboBox) e.Style.CellItemTemplate.FindName("cboUsername", this);
                        if (cboUsername != null){
                        //strike through here
                        }
                    }

Thangapriya V [Syncfusion]
Replied On May 14, 2013 11:57 AM UTC

Hi Robert,

 

Thanks for the patience.

We have analyzed your query. You can set the properties of a control in a Template from the QueryCellInfo event as follows.

Code snippet [C#]:

        void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)

        {

           CellUIElements  cell=dataGrid.Model.CurrencyManager.CurrentCell.Grid.GetCellUIElements(e.Style.RowIndex, e.Style.ColumnIndex);

           if (cell != null)

           {

               Console.WriteLine(cell.UIElements.Count);

               if (cell.UIElements.Count > 0)

               {

                   GridCell gridcell = cell.UIElements[0] as GridCell;

                   if (gridcell != null)

                   {

                       ContentPresenter myContentPresenter = FindVisualChild<ContentPresenter>(gridcell);

                       DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

                       var checkval = myDataTemplate.FindName("customersCombo", myContentPresenter);

 

                       if (checkval != null)

                       {

                           ComboBox combo = checkval as ComboBox;

                           if (combo != null)

                           {

                                // set properties for combobox

                                combo.Background = Brushes.LightPink;

                                combo.FontStyle = FontStyles.Italic;

                            

                           }

                       }

                   }

               }

           }

 

 

        }

 

   

 

 

 

We have prepared a sample based on this. You can find the sample under the following location.

 

Please let us know if you have any queries.

 

Regards,

 

Thangapriya

 



DataBound_ead17b44.zip

Robert Dondo
Replied On May 16, 2013 01:25 PM UTC

Thank you for the sample. I am currently using version 9.404.0.62, do you have a sample that works with this version?

Thangapriya V [Syncfusion]
Replied On May 31, 2013 12:23 PM UTC

Hi Robert,

We have modified the sample to work with the version 9.404.0.62. Please find the sample in the following location.

Please let us know if you have any queries.

Regards,

Thangapriya



DataBound_3c05f8d1.zip

Robert Dondo
Replied On June 18, 2013 01:02 PM UTC

I am unable to download the attached file. Can you maybe email it to me?

Thangapriya V [Syncfusion]
Replied On June 24, 2013 05:21 AM UTC

Hi Robert,

The file you are looking for is not available due to a server failure at one of our hosting sites. We are making every effort to retrieve this file and other files that are unavailable as a result of this outage. We regret this inconvenience. We will inform you when the file has been recovered. Please contact us for further assistance.

However we have attached the sample and please find the sample in the following location.

Regards,

Thangapriya



DataBound1_48dc45c4.zip

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

;