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
close icon

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

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
                        }
                    }

5 Replies

TV Thangapriya V Syncfusion Team 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


RD Robert Dondo 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?


TV Thangapriya V Syncfusion Team 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


RD Robert Dondo June 18, 2013 01:02 PM UTC

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


TV Thangapriya V Syncfusion Team 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

Loader.
Live Chat Icon For mobile
Up arrow icon