nAfter long research on this – came up with something like this , however there are lots of approaches already available on net which shows you to do the same using SharePoint designer or by creating new column.
nThanks to improved SharePoint 2010 APIs which gives the SPField.ListItemMenu property , but one thing to note here is setting this property to true does not reflect the changes , before setting this property – MSDN documentation says that you need to set the SPField.ListItemMenuAllowed to Required.
n
n
n
nThanks to improved SharePoint 2010 APIs which gives the SPField.ListItemMenu property , but one thing to note here is setting this property to true does not reflect the changes , before setting this property – MSDN documentation says that you need to set the SPField.ListItemMenuAllowed to Required.
n
n
n
ntry
n
n{
n
n SPContext.Current.Web.AllowUnsafeUpdates = true;
n
n
n
n SPList list = SPContext.Current.Web.Lists.TryGetList(“Cities”);
n
n SPField countryField = list.Fields.GetField(“Country”);
n
n if (countryField.ListItemMenuAllowed == SPField.ListItemMenuState.Prohibitedn|| countryField.ListItemMenuAllowed == SPField.ListItemMenuState.Allowed)
n
n {
n
n countryField.ListItemMenuAllowedn= SPField.ListItemMenuState.Required;
n
n }
n
n countryField.ListItemMenun= true;
n
n countryField.Update();
n
n list.Update();
n
n SPContext.Current.Web.Update();
n
n
n
n SPContext.Current.Web.AllowUnsafeUpdates = false;
n
n
n
n }
n
n catch (Exceptionnex)
n
n {
n
n this.Controls.Add(newnLiteralControl(“Error:n” + ex.Message));
n
n }
n
n
n
nHope this helps someone.
n