OK so I've got a sidebar built using an NSOutlineView. I currently have two sections in the sidebar which can be expanded/contracted. I would like to be able to determine which section the selected row belongs to.
- Section 1
-- Item 1
-- Item 2
-- Item 3
- Section 2
-- Item 4
-- Item 5
The problem is that the selectedRow value changes depending on whether sections are expanded or not. Is there no easy way to determine which section the row belongs to without manually keeping track of expansion/contraction and the number of items in each section?
Try this:
//returns id of section, where currentRow is a selectedRow
id section = [yourNSOutlineView parentForItem:[yourNSOutlineView itemAtRow:selectedRow]];
You could call [NSOutlineView itemAtRow:] with the index of the selected row.
Related
I have a list with 5 items (count 5 is dynamic). I need to display first item in first row column 1 and second item in first row column 2 and second item in second row column and so on. eg. in the attached image, consider all the items as a single list of names but displayed in multiple rows but with two columns. Kindly don't suggest any plugin for this In the attached image, list count is 12. Have to arrange 12 items as in the image.
List view is not provide this functionality, You have to use collectionview instead of Listview
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/collectionview/layout
I'm adding data from catia to datagridview. A portion of code where I'm having trouble is shown below. When I bind the datatable to datagridview, the data gets pasted starting from the header and I'm not sure how to skip the header and start from row 1. Appreciate any help. Thank you. enter image description here
Dim txtLines1 As New List(Of String())
_StringList.ToList().ForEach(Sub(x) txtLines1.Add(x.Split(New Char() {";"})))
If txtLines1.Count > 0 Then
txtLines1.Item(5).ToList.ForEach(Sub(x) txtDataTable.Columns.Add(New DataColumn(x.ToString)))
txtLines1.RemoveAt(1)
End If
If txtLines1.Count > 0 Then
txtLines1.ToList.ForEach(Sub(x) txtDataTable.Rows.Add(x.ToArray))
End If
You are using the values in Item 5 (the 6th one) of your list as your column name. That is what is displaying there. For each column in the data grid, you could update it to give it a more meaningful name.
txtLines1.Item(5).ToList.ForEach(Sub(x) txtDataTable.Columns.Add(New DataColumn(x.ToString)))
This is a way to give it a meaningful name:
txtDataTable.Columns(4).ColumnName = "5th Column"
txtDataTable.Columns(4).Caption = "5th Column"
Based on this 2nd set of code below, it then removes the 2nd item from the list, before adding the items to a DataTable. Not sure why you would remove the 2nd item.
txtLines1.RemoveAt(1)
End If
If txtLines1.Count > 0 Then
txtLines1.ToList.ForEach(Sub(x) txtDataTable.Rows.Add(x.ToArray))
End If
So your grid results display:
The 6th item as the column names
Followed by as the data:
1st Item
3rd List item (You removed the 2nd one - Item(1))
4th List item
5th List Item
6th List Item
...
I've written a feature:
Feature: Open List item
Scenario: As a valid user I can open list item
When I press list item number 0
Then I do something...
Then I go back
What I would need is to open every item of ListView (not only 0th), so how could I specify a loop that would in the end iterate through whole ListView, or some specified maximum index - ie. for parameter value 5 it should execute this scenario for 0th, 1th, 2nd, 3rd, 4th and 5th item.
So, two questions:
1) How to create a loop?
2) How to parametrize execution
Regards,
Milos
1. If you know the exact loop count, you can use scenario outline in cucumber.
Feature: Open List item
Scenario: As a valid user I can open list item
When I press list item number <count>
Then I do something...
Then I go back
Examples:
| count |
| 1 |
| 2. |
| .. |
| n |
More details about scenario outline: https://github.com/cucumber/cucumber/wiki/Scenario-Outlines
Or
2. You can get count using query() & iterate using for each loop in ruby
For getting count query("view").count
Get the count.
Store it in variable
Loop it in step definition
I have one table with 3 rows and 3 columns. Now I want to add 2 row's 2nd columns cell's control. That means whether that is text or combox in the cell. How do I get the 2nd row's 2nd column and remove the compoenent dynamically in SWT JFace?
Do you use a TableViewer?
The SWT-way of getting to the item is indexed first by row, than by column.
Getting the text of the third column in the second row is done like this:
table.getItem(1).getText(2);
To display custom-controls, like a combobox you will have to either paint it manually or use SWT's TableEditor.
Also check out this tutorial: http://www.eclipse.org/articles/Article-Table-viewer/table_viewer.html
I am currently using DevExpress 10.2 within Visual Studio 2010. In a previous question I was trying to print the current user view of a DevExpress GridControl with the user's choice of expanded or collapsed master rows and/or group sections. I was told this was not possible at this time. I have now decided to use the following code:
gvPOinvoiceBanded.OptionsPrint.ExpandAllGroups = False
gvPOinvoiceBanded.OptionsPrint.ExpandAllDetails = False
when I want it to be completely collapsed while printing as by default these are set to true.
I was just wondering if there is someway to check either the total number of expanded master rows or the total number of collapsed master rows. I would also like to do the same thing for the groups as you can have the groups expanded while the master rows are not.
You can get the number of expanded group rows using a loop like this:
Dim ExpandedGroupCount As Integer = 0
Dim Handle As Integer = -1 'group rows have negative row handles
Do Until GridView1.GetRow(Handle) Is Nothing
If GridView1.GetRowExpanded(Handle) Then
ExpandedGroupCount += 1
End If
Handle -= 1
Loop
'Do whatever with expanded group count
MsgBox(String.Format("Number of Expanded Group Rows: {0}{2}Number of Group Rows: {1}",
ExpandedGroupCount, Math.Abs(Handle + 1), Environment.NewLine))
Similarly, you can do this to get the count of expanded master rows:
Handle = 0
Dim ExpandedMasterRowCount As Integer = 0
Do Until GridView1.GetRow(Handle) Is Nothing
If GridView1.IsMasterRow(Handle) Then
If GridView1.GetMasterRowExpanded(Handle) Then
ExpandedMasterRowCount += 1
End If
End If
Handle += 1
Loop
MsgBox(String.Format("Number of Expanded Master Rows: {0}", ExpandedMasterRowCount))
Of course, if you are only checking so that you can see if you need to set the collapse this probably isn't worth the effort. There is no direct property that provides the counts you are looking for.
You could also probably use the events that fire when rows are collapsed and expanded to track the count as it changes. You have to be careful with that though because the event only fires once when expand or collapse all happens. So if you go with that method be sure to check the rowHandle in the event arguments parameter for GridControl.InvalidRowHandle. That is the value used in the case of collapse or expand all.