VSTO Selecting and Modifying an existing Ordered List - ms-word

I have an ordered list in my Word document, and I want to add a new element between elements 2 and 3. The easiest way to do this would probably be to get the location of the end of the second element, but I don't know how to do this. Does anyone know how to do this?
All help is greatly appreciated and I always accept an answer!

Given a document consisting of just a simple ListParagraph:
List item 1
List item 2
List item 3
If you want to insert a list item between 2 and 3, you can get the second list paragraph and add a paragraph:
MSWord.Application app = (MSWord.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
MSWord.Document doc = app.ActiveDocument;
doc.ListParagraphs[2].Range.Paragraphs.Add();
this will insert a new 3rd list paragraph:
List item 1
List item 2
---->code will add this one
List item

Related

Get all items of SelectMultipleItems from request and not selected ones

In flask, in a form I add and remove some items to a list ( they are selected form other lists) then I want to treat all items added to this list as selected items and add them to the database.
items = request.form.getlist('sellist')
the above solution returns just selected items, how can I get all items? One solution is to have a javascript to select all before submission but what is the best solution and best practice for this senario? Should I use a list or another control?

Firestore Security Rule List Check Duplicate

Let's say that request.resource.data[field] is a list. I am trying to check if any of the items in the list is a duplicate of the other items. In other words, I am checking if any of the items are repeated more than once inside the list. I read the documentation and reference related to list, and did not find a way to implement this. Is this possible to do?
You can check to see if there are any duplicates in a List type field by:
Converting the List into a Set using toSet() (which cannot contain duplicates
Comparing the size of the List to the size of the Set
If the size of the set is less then the size of the list, then you know that there was at least one duplicate that got removed. So, something like this will return true if there was a duplicate in the list:
listField.toSet().size() < listField.size()

Take an Element of a List which is in a List

I know this sounds confusing. I have a List which consists of Lists in these Lists i have always 2 Elements. I want to display the first Element of all Lists. How does it work?
When you trying to display the list of elements as a group using foreach() loop. By default the list will be displayed in Ascending order only, try that approach once. If you face any issue, please provide your source code, as you trying out to display group of sublists in a Listview. Happy coding

What is the correct way to save a list of items in a web form?

There is some form in a web form. It contains the list of items that use can edit, remove and change.
When the server receive the list of items, it should update existing items, create ones and remove the deleted ones.
I only know the naive and quite ugly approach:
When server receives the list of items from a client, it gets the actual list of items from the database
Pass round the received list of items:
2.1. If element has the ID and database has the element with this ID, this element updates
2.2. If this element doesn't have ID or database doesn't contain element with this ID, this element creates
Delete all items, that were not in the received list (marked as deleted)
The updated list of items are returnded to the client (with new IDs), and client displays them
I feel, that there is more elegant solution, and, propably, established for this task.
I had the same challenge and i solved it like this:
1-First when you load the page, create a list made up of id and data.
2-then the user fill the data.
3-those items that user doesnt fill should be deffault value.
4- then retrive the list from database and delete it and put the updated list
Hope this helps

Where are form elements rendered in Drupal 7? I'm looking for why the sixth item in a select option list doesn't get rendered

I have Drupal 7.58 site where there's a select list with 15 items that come from an entity reference. When I put a debugging statement into form_type_select_value in includes/form.inc, the whole array of items is there, so I know the query is working, and the form element should be built correctly.
But when the select list is display, the sixth element goes missing. I've found a short term way to circumvent this, by adding a dummy sixth item, but that's not going to fly in the long term.
What I need to know is where does it go after form_type_select_value?
edit: More info
This is happening in an Entityform where the field type is Entity Reference and the Widget is Select List. In Manage Fields under Entity Selection, I select an entity called Store, in Simple mode. There are 15 Stores, and these are sorted by the Title property, sorted in the Ascending direction.
When I sort in Descending direction, a different item is missing, but it's always the 6th from the top.
I've debugged it up to the point where the data comes in, before it's rendered, and it's all there in the outgoing array.