ValueResetFlags.Local does not work, however ValueResetFlags.None does. Why?

3 Answers 112 Views
ListView
Clint
Top achievements
Rank 1
Iron
Iron
Iron
Clint asked on 14 Sep 2021, 02:52 PM

In my ListViewType.DetailsView, RadListView control, I have a simple item format method as follows.

        private static void RlvScanMeterNumber_VisualItemFormatting(object sender, ListViewVisualItemEventArgs e)
        {

            if (e.VisualItem.Selected)
            {
                e.VisualItem.BackColor = Color.Red;
            }
            else
            {
                e.VisualItem.ResetValue(VisualElement.BackColorProperty, ValueResetFlags.None);
            }
        }

Before when I had the reset flag of that ResetValue function set to ValueResetFlags.Local, it DID NOT WORK.

However, after some experimentation, I found that if I used ValueResetFlags.None, it does work!

I am manually adding the list items to the list view, as per the unbound data scenario. So would that have something to do with it?

Why is that?

What do these ValueResetFlags mean?

3 Answers, 1 is accepted

Sort by
0
Stoyan
Telerik team
answered on 15 Sep 2021, 10:08 AM

Hi Clint,

After looking into your issue, I would need more information in order to help you.

Would you please explain what exactly is not working in the different scenarios?

As far as I see, you are trying to set a selected item's background to Red and to reset it, if it is not selected. If that is the case, you should use ValueResetFlags.Local. 

Our property system supports several layers of values, depending on how the property is set. So the ValueResetFlags are used to specify, which layer to reset. ValueResetFlags.None does not reset the value - it straight forward returns from the ResetValue method. 

If ValueResetFlags.Local or something else is not working, please provide a complete code snippet with the scenario that is not working, if possible. That would be greatly appreciated and will help us resolve your issue.

I am looking forward to hearing from you.

Regards,
Stoyan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Clint
Top achievements
Rank 1
Iron
Iron
Iron
answered on 15 Sep 2021, 04:51 PM
I am not sure what you wanted, so I included the entire winform file. 

When I am adding the list view data item, that is where I am setting the colour. So that might be why it's not working with local.


                ListViewDataItem msItem = new ListViewDataItem();
                msItem[0] = ma.Barcode;
                msItem[1] = ma.Class;
                msItem[2] = ma.FormFactor;
                msItem[3] = false;

                msItem.BackColor = Color.Khaki;
                msItem.NumberOfColors = 1;
Also, how can I toggle the selection on and off by clicking on a row. First click selects, second click to same row, unselects.
0
Stoyan
Telerik team
answered on 16 Sep 2021, 11:55 AM

Hello Clint,

As far as I understand, you want to reset the color back to Color.Khaki. If this is the case, I would recommend to set it in the else, instead of resetting the value:

        private static void RlvScanMeterNumber_VisualItemFormatting(object sender, ListViewVisualItemEventArgs e)
        {

            if (e.VisualItem.Selected)
            {
                e.VisualItem.BackColor = Color.Red;
            }
            else
            {
                e.VisualItem.BackColor = Color.Khaki;
            }
        }

Using ResetValue with ValueResetFlags.Local will set the local value of BackColorProperty to unidentified value. In this case, the default value or the style value will be used as BackColor. 

I hope this information helps you with your project.

As for your second issue, I see the Dess already answered your question, so you can use her suggestion.

Regards,
Stoyan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
ListView
Asked by
Clint
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Stoyan
Telerik team
Clint
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or