I am using VS2015 to develop and need insert items into a CListCtrl object. I use InsertItem() to add the new item at the end of the list. Below is my code
int nIdx = m_SessionTimesListCtrl.InsertItem(
m_SessionTimesListCtrl.GetItemCount(), IFMT("%s/%s/%s", getTime(), getWeekDay(), getTimeZone()));
My intention is to get below list
03:00:00/MON/US
17:00:00/TUS/US
17:00:00/WED/US
17:00:00/THU/US
however, I got this list
03:00:00/MON/US
17:00:00/THU/US
17:00:00/TUS/US
17:00:00/WED/US
the only explain is CListCtrl sorts the inputs despites I give it the index to be inserted.
I checked my resource file and there is no sorting attribute been used.
CONTROL "",IDC_LIST_SESSION_TIMES,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,152,58
So, my question is how I can disable the auto sorting of CListCtrl?
The LVS_REPORT style is normally used when there is a need to display the items in a sortable fashion. Using this style may result in the list control having a CHeaderCtrl upon which one could click to sort the list items.
If sorting is not desired, and if there's no need to display a column header, you might want to not use the LVS_REPORT style. Choose something like LVS_LIST style instead.
If a column header is desired, but no sorting is required, you might want to disable the sorting properties of the control by doing something like:
m_SessionTimesListCtrl.ModifyStyle(LVS_SORTASCENDING|LVS_SORTDESCENDING, 0);
Related
I am not able to create a new menu in my mdi form.As already so many existing menus are there.
Its giving error "reached limit cannot create any more controls for this form".
Please help me to know that how to add new menu with this error.
You can use control arrays for your menus to overcome 256 controls per form limit. In Menu Editor you have to set Index property to an unique integer value to create control arrays of entries with same Names.
A common strategy is to designate mnuMain name for a control array with top menus i.e. first mnuMain(1) would be "File", then mnuMain(2) would be "Edit", etc.
Then in form's code declare an enum like this
Private Enum MenuIndexesEnum
idxFile = 1
idxEdit
idxTool
....
End Enum
and use it throughout code like mnuMain(idxFile) etc.
For "File" sub-menu designate mnuFile control array with unique indexes starting from 1 for "New", "Open", "Print", etc. "Exit" and extend the MenuIndexesEnum enum like this
Private Enum MenuIndexesEnum
idxFile = 1
idxEdit
idxTool
....
idxNew = 1
idxOpen
idxPrint
idxExit = 99
...
End Enum
Then continue with mnuEdit for "Edit" sub-menu, etc.
As #wqw said, the problem is that you've reached the 256 controls-per-form limit, and the solution is to start wrapping them up into control arrays. However, the control you're having an issue with (a menu) isn't necessarily the one you need to make into a control array.
I find that the most insidious, yet easiest to solve, control "consumers" are the label controls sprinkled everywhere on a typical form. To turn those into a control array, I just adopted the practice of copying and pasting an existing label anytime I need a new one; the first time, VB will ask if you want to create a control array (say "Yes"), and thereafter it will automatically increment the index for you every time you create a new copy of the label.
For me, label controls are the most convenient to make into an array, because there's usually no code associated with them, and hence no need to worry about the index at all.
How can I change the language for Sorting on PF DataTable component with reflow = "true" (so responsive Datatable)?
The problem is that on mobile screen, we can sort data from auto-generated dropdown where we have our sort options, see picture bellow. How can I change the language for this dropdown?
I'm using PF 6.0.
The intended way to do this is to define the following properties in your resource files (see Messages.properties)
primefaces.datatable.SORT_LABEL = Sort
primefaces.datatable.SORT_ASC = Ascending
primefaces.datatable.SORT_DESC = Descending
You can see this when you look at the DatatableRender of primefaces.
Notice i18n is done in different ways in primefaces. Some components like calendar or schedule must be translated via javascript. See here
I never ran into this or used it, but I know the source is open. So I went to the javascript file for the datatable. There I searched for 'Ascending' and via this.ascMessage, I ended up on line 170 where 'datatable.sort.ASC' is used as a key.
This in turn points to line 619 in core.js
getAriaLabel: function(key) {
var ariaLocaleSettings = this.getLocaleSettings()['aria'];
return (ariaLocaleSettings&&ariaLocaleSettings[key]) ? ariaLocaleSettings[key] : PrimeFaces.locales['en_US']['aria'][key];
},
Where you can see the normal PrimeFaces locale functionality is used.
So using your own locale and overriding this part in it, like in the default locale
aria: {
'paginator.PAGE': 'Page {0}',
'calendar.BUTTON': 'Show Calendar',
'datatable.sort.ASC': 'activate to sort column ascending',
'datatable.sort.DESC': 'activate to sort column descending',
'columntoggler.CLOSE': 'Close'
}
Will solve your issue I would expect
How can I change the language for Sorting on PF DataTable component with reflow = "true" (so responsive Datatable)?
The problem is that on mobile screen, we can sort data from auto-generated dropdown where we have our sort options, see picture bellow. How can I change the language for this dropdown?
I'm using PF 6.0.
The intended way to do this is to define the following properties in your resource files (see Messages.properties)
primefaces.datatable.SORT_LABEL = Sort
primefaces.datatable.SORT_ASC = Ascending
primefaces.datatable.SORT_DESC = Descending
You can see this when you look at the DatatableRender of primefaces.
Notice i18n is done in different ways in primefaces. Some components like calendar or schedule must be translated via javascript. See here
I never ran into this or used it, but I know the source is open. So I went to the javascript file for the datatable. There I searched for 'Ascending' and via this.ascMessage, I ended up on line 170 where 'datatable.sort.ASC' is used as a key.
This in turn points to line 619 in core.js
getAriaLabel: function(key) {
var ariaLocaleSettings = this.getLocaleSettings()['aria'];
return (ariaLocaleSettings&&ariaLocaleSettings[key]) ? ariaLocaleSettings[key] : PrimeFaces.locales['en_US']['aria'][key];
},
Where you can see the normal PrimeFaces locale functionality is used.
So using your own locale and overriding this part in it, like in the default locale
aria: {
'paginator.PAGE': 'Page {0}',
'calendar.BUTTON': 'Show Calendar',
'datatable.sort.ASC': 'activate to sort column ascending',
'datatable.sort.DESC': 'activate to sort column descending',
'columntoggler.CLOSE': 'Close'
}
Will solve your issue I would expect
I want to stack two treeviews on each other and have the columns be aligned. I figured the way to do this would be to use a gtk.SizeGroup somehow. However, gtk.TreeViewColumn is not a widget... how can I do this?
I have two suggestions:
Look at how gtk.SizeGroup is implemented and see if you can write your own TreeViewColumnSizeGroup.
Connect to notify::width of each column and in the callback set the width of the corresponding column in the other treeview.
UPDATE: This is the final code that worked. In a loop I'm building both view columns at the same time, so this line is sufficient:
col1.connect("notify::width", lambda col1,_,col2:col2.set_fixed_width(
col1.get_width()), col2)
I think the reason there is no "column widget" is that the main area is just a gtk.gdk.Drawable where each of the cell renderers draw their stuff. However, each column has headers that are widgets, so we can use those to do what we want.
Pick one view to be the 'main' one, and set the other to have gtk.TREE_VIEW_COLUMN_FIXED sizing. Use .forall() to go through the internal child widgets of the 'main' view. These will be gtk.Buttons representing the column headers. Connect to their size-allocate event. On that event handler, get the requested width, and .set_fixed_width of the corresponding column on the slave view.
self._svcols = []
def sizealloc(wid, alloc):
ci = self._svcols.index(wid)
cl = self.slaveView.get_column(ci)
cl.set_fixed_width(alloc.width)
def resizes(child):
child.connect('size-allocate', sizealloc)
self._svcols.append(child)
self.mainView.forall(resizes)
This works even if the column headers are not being shown.
I have a web page with a grid, and some columns have a link in the column header that will sort the values by that column [by round-tripping to the server].
I want to write a single Watir test that will identify those sorting links and click each one in succession. This is a smoke test that ensures there are no runtime exceptions resulting from the sort expression.
My question is, what is the best way to (1) identify these links, and (2) click each one in succession? This is what I have so far:
$ie.table(:id, "myGrid").body(:index, 1).each do | row |
row.each do | cell |
## todo: figure out if this contains a sort link
## todo: click the link now, or save a reference for later?
end
end
I think it won't be possible to click each link inside the loop since clicking a link will trigger a page load and I believe this invalidates the other Watir Link Elements.
So, what I suggest is that you take the IDs of the links and then loop over each other doing the clicks.
For instance, I would add an specific class to those sorting links and a meaningful id too.
Something along the lines of:
<a id='sortby-name' class='sorting' href='...'>Name</a>
Then you can pick them with this:
$ie.table(:id, "myGrid").body(:index, 1).each do | row |
# pick sorting links' ids
sorting_link_ids = row.links.select{|x| x.class_name == "sorting"}.map{|x| x.id}
end
And then, you do your clicking like this:
sorting_link_ids.each do |link_id|
$ie.table(:id, "myGrid").body(:index, 1).link(:id, link_id).click
end
Hope that helps!