# ApplyExpression no longer working for me in 5.2

**URL:** <https://mapwindow.discourse.group/t/applyexpression-no-longer-working-for-me-in-5-2/993>\
**Category:** MapWinGIS\
**Created:** [May 14, 2021, 11:49am UTC](https://mapwindow.discourse.group/t/applyexpression-no-longer-working-for-me-in-5-2/993 "2021-05-14T11:49:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![robhoney](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@robhoney](https://mapwindow.discourse.group/u/robhoney)\
**Post date:** [May 14, 2021, 11:49am UTC](https://mapwindow.discourse.group/t/applyexpression-no-longer-working-for-me-in-5-2/993/1 "2021-05-14T11:49:11Z")

</div>

Hi,

I’ve upgraded from to 5.2 (from 5.0) and now find that “ApplyExpression” no longer works for me when using category expressions to show images for points in a shapefile.

I’m creating categories like below, where “key” is an identifier of the type of “node” the point is:

myCategory.Expression = “[Type] = “” + key + “””;

then calling:

myCategory.DrawingOptions.PointType = MapWinGIS.tkPointSymbolType.ptSymbolPicture;  
myCategory.DrawingOptions.Picture = MyResource.IconImages[key];

and finally:

shp.Categories.ApplyExpression(categoryIndex);

This used to work fine and has done for a long time. However now I get no symbols, just the default point style, **except** for the 63rd point/node which DOES show a symbol (but the wrong one, the first one in my IconImages list as it happens, probably not coincidence). I’ve tried a couple of fields and it was the 63rd point in each case!

Also, shp.Categories.ApplyExpressions DOES work. However, I switched to the single ApplyExpression a while ago as it is much quicker for this scenario for some reason, so I’m keen to carry on using it.

Regards,

Rob H

---

<div class="post-metadata">

**Author:** ![dgreenewalt](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@dgreenewalt](https://mapwindow.discourse.group/u/dgreenewalt)\
**Post date:** [May 20, 2021, 11:28pm UTC](https://mapwindow.discourse.group/t/applyexpression-no-longer-working-for-me-in-5-2/993/2 "2021-05-20T23:28:26Z")

</div>

Hi Rob,  
You’re right, it looks as if ApplyExpression() does not work, but ApplyExpressions() does. My code used to use:

```
 For i = 0 To 4
     sf.Categories.ApplyExpression(i)
 Next

```

Now applying all styles (categories) must be done at once:  
`sf.Categories.ApplyExpressions()`

I found no documentation of this being deprecated, and assume a bug. I reworked my code to adapt, but should have directed my concerns to the development team.

Good Luck,  
David

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [May 21, 2021, 3:48am UTC](https://mapwindow.discourse.group/t/applyexpression-no-longer-working-for-me-in-5-2/993/3 "2021-05-21T03:48:11Z")

</div>

Thank you @robhoney, and for the additional feedback @dgreenewalt

I looked at the history of that file, and a bug was indeed introduced in December of 2019 that prevents individual Categories being processed. I’ll try to submit a change that will be in the next build.

Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![robhoney](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@robhoney](https://mapwindow.discourse.group/u/robhoney)\
**Post date:** [May 21, 2021, 7:07pm UTC](https://mapwindow.discourse.group/t/applyexpression-no-longer-working-for-me-in-5-2/993/4 "2021-05-21T19:07:09Z")

</div>

Thank you both @dgreenewalt and @jerryfaust . It will be great to have a fix for this.

Regards,

Rob

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [May 24, 2021, 6:03am UTC](https://mapwindow.discourse.group/t/applyexpression-no-longer-working-for-me-in-5-2/993/5 "2021-05-24T06:03:46Z")

</div>

Jira Issue [MWGIS-236](https://mapwindow.atlassian.net/browse/MWGIS-236) has been created and a fix submitted accordingly.

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 24, 2022, 3:08pm UTC](https://mapwindow.discourse.group/t/applyexpression-no-longer-working-for-me-in-5-2/993/6 "2022-01-24T15:08:11Z")

</div>

This issue has been fixed in [MapWinGIS v5.3](https://github.com/MapWindow/MapWinGIS/releases)

I’m closing this topic.

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 24, 2022, 3:08pm UTC](https://mapwindow.discourse.group/t/applyexpression-no-longer-working-for-me-in-5-2/993/7 "2022-01-24T15:08:15Z")

</div>


