I'm basically interested in checking if the user is showing any baselines in his active view, and if yes, which one.
If for instance "Baseline1 Start" is used in Bar Styles for the active view, I'd find the matching item number.
If I were able to loop through each bar style item, such as the built-in list MS Project shows lists under "Bar styles", that would solve my problem.
I've tried using the GanttBarEditEx method, but as the documentation explains, it only returns boolean.
If I for instance want to delete an item, this code will do:
GanttBarStyleDelete Item:="41"
My problem is that I don't know what Item I'm looking for. I don't know how to read data about Item:= "41"
This code is not working, but illustrates what I want:
For i = 1 to 200
if GanttBarEditEx(item:=i, from:"Baseline1 start") = True Then MsgBox i
Next
I'm able to figure out the item count using the same logic, when item = i returns an error, that means there's no such item and I have found max. That's how far I've gotten.
There's also a code for GanttBarStyleBaseline which could be of help!
If it's impossible to list the items, I might be able to write a code that's sets each baseline to false, then check if a change was made to the active view, and hence find the active shown baseline...Help?
Update: I noticed that BarBoxStyles opens the "Bar styles" window. But I'm guessing that can't be turned into a collection for looping.
Related
I have an extensive code that populates tags using commands similar to the following :
ActiveDocument.SelectContentControlsByTitle("Tag1").Item(1).Range.Text = "New Item"
ActiveDocument.SelectContentControlsByTitle("Tag1").Item(2).Range.Text = "New Item"
However, if the user of the document deletes any of those tags 1 or 2 from the word document then the code will detect the tag does not exist, show an error and stop running the code. Hence my question...
Is it possible to count the number of Tags with a specific name, then IF that count returns 0 the code skips looking? I think I will be able to solve this issue if I can count per tag name, but yet to figure this out!
Just looking up the documentation for SelectContentControlsByTitle should have pushed you towards an answer.
Returns a ContentControls collection that represents all the content
controls in a document with the title specified in the Title
parameter. Read-only.
As a collection has a Count property you can use that to determine how many items are in the collection, or you can loop through the members of the collection rather than writing to them individually.
The following will work without raising an error if there are no controls with that title:
Dim cc As ContentControl
For Each cc In ActiveDocument.SelectContentControlsByTitle("Tag1")
cc.Range.Text = "New Item"
Next cc
I'm working on a DB where the users have to select items from multiple list boxes, at the end of the all of this, the form closes and opens a new form. All of that works great.
My issue is that when the user goes back to the original form, I want it to load in with their list box items already highlighted. Sort of a "here is where you left off" kind of thing.
I have code that works, but it's somewhat limited:
If InStr(me.Backup_Chain, "Apple") > 0 then
Me.List_Type.Selected(0) = true
End if
If InStr(me.Backup_Chain, "Grapes") > 0 then
Me.List_Type.Selected(1) = true
End if
"List_Type" is just a textbox that I populate with the users previous selection. So if they selected Apples and Grapes it reads: 'Apples','Grapes'
This works pretty well, but it's not dynamic. So if I add "Bananas" to the list, Bananas because item number 1 in the list, and thus screws up all of my other references.
So, my question is 2 parts:
Is there an easier way or reselecting the list box items?
If not, is there a way to make the Selected(#) dynamic? i.e. to tell that "Grapes" is in location 1 vs 2.
Thanks everyone!
Edit: In addition to this, I have a run a query to filter one of the list boxes down to a subgroup of clients (based on the other list box selections). Which means I need to refresh the page. So I can't get by with just hiding the form.
I ' ve a combobox with too long multiple Items . There is any method to set a horizontal scroll in combobox or set a multiline properties for each item ?
Hi Mattia,
There are a couple of methods that are usable as well as effective for this problem you are having, here is the concept that I've created that you may implement in your project;
Original text: C:\path1\path2\path3\path4\file.exe
Combo Box text: C:\path1\p...file.txt
To do this you will 1st have to specify how many characters you want to shown in the start of the text (1st 5 or so) then you must specify how much you would like to leave off at the end (last 6 or so).
I realize this causes a problem, "I wont be able to see the full path!", however adding a 2nd form or a msgbox to display the full text which should initiate the 1st 2-4 secs of display time, this should not be a challenge nor a problem and will make you look like a Pro!
I hope this helped you with your problem or motivated you to go over and beyond!
I've encountered this in a couple spots in my app:
Let's assume I have 3 items in a carousel. I'm viewing item #2. I need to reload that carousel, so I do the following operations:
Ext.getCmp('carousel_name').removeAll();
var new_objects = (bunch of code that recreates the carousel's objects again, with the same IDs; this is the same code that was used to create the objects the first time, so it is likely not the issue)
Ext.getCmp('carousel_name').add(new_objects);
In the carousel object items list (Ext.getCmp('carousel_name').getItems()), all three items exist. However, only #1 and #3 (the ones which weren't the active item prior to the carousel reload) actually appear. #2 presents a blank white screen, and in the HTML nothing exists except for the item shell markup (no code that I've written shows up). If I do Ext.getCmp('carousel_item_2').show();, the item does appear, but is full-screen, and I get the error:
[DEPRECATE][Ext.Panel#show] Call show() on a component that doesn't currently belong to any container. Please add it to the the Viewport first, i.e: Ext.Viewport.add(component);
When I try to manually add that item to either the Viewport or the carousel, nothing is fixed.
I've tried inserting a dummy item in-between removal and reinsertion of new items, that doesn't work. Nor does hiding the entire Viewport before doing any of this and showing it afterwards. Nor does using setItems() rather than add(). Nor does doing Ext.getCmp('exercises_carousel').each(function(item){ item.destroy(); }) rather than removeAll(true)
I don't believe the issue is the code snippet that re-creates the new items, since it's the same code that's used to create the items the first time, and there are no issues on the first creation.
Pretty stumped here.
EDIT: I've found that if, when I get to the end of the carousel, if I add a empty item after the last item in the carousel, I don't get the blank item at N-2. No clue why this is the case. Still not a real solution, it's a hack.
Assuming there are no problems in your code snippet to re-populate new items in your carousel, then the only problem is because of this issue (I'm not sure whether it's a bug in Sencha Touch 2.1 or not but it does exist): when you call yourCarousel.removeAll() and add some new items again, your carousel will NOT set proper active item.
I've seen a similar problem and I added this after adding new items, which works:
carousel.setActiveItem(0);
Alright, this is a hack, so if anyone has a legitimate solution, that would be awesome. But the hack does work, so here it is:
Add an empty item in the carousel
Set active item to the new empty carousel item
Destroy all carousel items
Recreate (and re-add) all of the items
In code:
Ext.getCmp('carousel_name').add({});
Ext.getCmp('carousel_name').setActiveItem(Ext.getCmp('carousel_name').getMaxItemIndex());
Ext.getCmp('carousel_name').removeAll(true);
var new_objects = (bunch of code that recreates the carousel's objects again, with the same IDs)
Ext.getCmp('carousel_name').add(new_objects);
EDIT: As it turns out, this for some reason works 90% of the time; for some unknown reason 10% of the time it still doesn't get inserted. The only way to guarantee that all items get inserted correctly is to clear the entire viewport (Ext.Viewport.removeAll(true)), recreate all of the original items in the viewport, and reinsert them. I'd rather not have to do this every time an item doesn't get inserted.
So I have a form that has a listbox that shows like a ledger. My question is how can I make it display the last records (or have the scroll bar default to the bottom instead of the top), instead of the first few as the default.
Now I don't mean reversing the order from bottom to top instead of top to bottom (though that would be a cool thing to learn how to do), just simply having the bottom of the list (in terms of the scroll bar) shown and the default, so that it is always showing the last 10 or so records (based on the size that I made the list box).
So i think this is simple, but then again, I obviously do not know?!?!
Thanks!
In a suitable event, such as the current event:
Me.ListX.Selected(Me.ListX.ListCount - 1) = True
You could add some code to the form load event so that it will do this:
YourListBox.SetFocus
YourListBox.ListIndex = YourListBox.ListCount - 1
YourListBox.Selected(YourListBox.ListCount - 1) = False
It basically selects the last item in the list box so it will scroll down to it, and then unselects it.
I know this is later but maybe this will help someone in the future who comes upon this thread. This is the code I used to go to the last record then unselect the last record.
YourListBox.SetFocus
YourListBox.Selected(YourListBox.ListCount - 1) = True
YourListBox.Selected(YourListBox.ListCount - 1) = False
How did you set the listbox items? Are they from a database? If yes, then you need to update the SQL statement with an "order by columnName".