Linq Get Elements For The First N Groups?

Mar 16, 2012

I would like to get the first N groups elements with Linq of a ObservableCollection, an example trying to get the first 2 groups:

Data example:

GROUP1 item1
GROUP1 item2
GROUP1 item3
GROUP2 item1

[code]....

View 5 Replies


ADVERTISEMENT

VS 2008 - LINQ Query - Groups And Counts On A Single Dgv Cell ?

Aug 11, 2010

I have a LINQ query that groups and counts on a single dgv cell. What I want to do is group and count on 2 dgv cells. So I modified my existing query by adding a SELECT statement highlighted :

CODE:

But I am getting an error on the second select variable stating: Range variable 'Value' is already declared

What I have read shows that I can select more than one variable.

What I am trying to achieve is this:

Original

CODE:

Result:

CODE:

View 2 Replies

C# - Getting A Set Of Elements Using Linq?

Mar 26, 2010

I have the following piece of XML:

<xml>
<ObsCont xCampo="field1">
<xTexto>example1</xTexto>

[Code]....

How do I (using linq) get for example what is inside the xTexto tag that has as parent the ObsCont with the xCampo attribute "field2" ?

View 3 Replies

Accessing XML Elements With LINQ Using .net (not C#)?

Nov 29, 2011

how to search XML trees with LINQ using VB.net. I've found some very helpful posts for C#, but none for VB.net?How would I use LINQ to XML to get the value from example XML Getting a set of elements using linq How to get elements value with Linq To XML I want to get the inputlocation for the process where name = "MyProcess1" Based on the example links above, I have been trying code like this:

Dim inputLocation As String = xdocument.Descendants("Configurations").Descendants("process").First(Function(c) c.Element("name").Value = "MyProcess1").Element("inputLocation").Value

But the code is not returning any values. here is the xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Configurations>
<process>

[code]....

View 1 Replies

LINQ To XML - Sequence Contains No Elements

May 25, 2011

I have this XML
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="[URL]" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="[URL]" />
<xsd:element name="root" msdata:IsDataSet="true">
[Code] .....

And I also have this method, where I take two files and take some values from them, and then I merge all the values into an object in the second query:
Public Shared Function RetrieveTranslation(ByVal filefrom As String, ByVal fileto As String) As List(Of clsTranslation)
Dim valuefrom = (From l In XElement.Load(fileto).Elements("data") Select l.Element("value").Value).FirstOrDefault
[Code] .....

So, the problem is that when I run the code, there is an "Sequence contains no elements" error in the first query(valuefrom). I debugged and it says that there is nothing in the query, but I don't understand why? I'm curious to know if it is well done to do something like I did, create an object from two queries, putting the first value in the second query.

View 1 Replies

Add Child Elements To Existing Xml - Linq?

Aug 17, 2009

I'm having trouble adding child elements to the below
<securities>
<security id="040104JC6">

[code]....

View 2 Replies

VS 2008 LINQ When Some Elements 'could' Be Missing?

Jan 27, 2010

some of the xelements within the query were calling for tags that didn't exist in the original xml, heres a simple example of what i mean.

element = _
<xml>
<object>
<string>someString</string>

[code]....

So how do i change the querry so that it wont produce a null error if the tags asked for are not present.

View 7 Replies

VS 2010 LINQ Sub-elements And Joining

Mar 30, 2012

I'm really struggling with this. I have two XML files. The first one has items, and then sub elements for properties:

[Code]...

View 3 Replies

[2008] LINQ - Xml Elements Into A Datagridview?

Oct 20, 2009

I've become undone when trying to convert xml linq query result to a datagridview (see code below), needing some pointers,.

Dim doc As XDocument
doc = XDocument.Load("C: empxmltest.xml")
Dim query = From c In doc.<quotefile>.<quote> _

[code].....

View 3 Replies

Creating Objects From Child Elements Using LINQ To XML

Feb 1, 2011

Is there any way to use a LINQ to XML to query an XML document like the one below to create new (anonymous or strongly typed) objects from the child elements of a descendant? Here is my XML document:

[Code]...

View 2 Replies

XML Feed - How To Get Collection Of Elements (Assets) Via LINQ

Mar 9, 2011

I have the following XML which I load via XDocument.Load(uri) or XElement.Load(uri). I am having trouble getting a collection of <asset> elements via LINQ.

Here is a snippet of the XML I'm trying to query:
<assetCollection xmlns="tag:aisle7.net,2009:/api/1.0">
<title>All Assets</title>
<description>Collection containing all assets in the system</description>
<resourcePath>/us/assets/~all</resourcePath>
[Code] .....

View 2 Replies

Linq To Xml Query Returning A List Of All Child Elements?

Mar 8, 2010

I have got an xml document which looks something like this.

<Root>
<Info>
</Info>
<Info>

[Code]...

How can i write a linqToXML query so that it returns me an IEnumerable containing each child element, in this case all five child elements of , so that i could iterate over them. The order of child elements is not definite, neither is number of times the may appear.

View 1 Replies

Replace Xml Content In Conditionally Selected Elements Using Linq (VB 2008)?

Mar 22, 2009

I'm working on a .NET application (VB 2008) that gets all of its data from a web-based Django application.I'm using Linq-to-XML and Linq-to-objects in the app.One API call is giving me XML data in the following format that I am loading into an XDocument.

[Code]...

View 1 Replies

Html - Dynamically Created Elements From Codebehind Need To Be Inserted Between Specific Elements

Sep 17, 2010

I created a method and pass the element type, id, and any inner text that instantiates a new html element. The last statement: Me.Controls.Add(element) adds it to the end of the page, but I would like it to be inserted in a specific position (between 2 divs within a form). What I am describing is very similar to this post on SO here, although it was for javascript.

View 1 Replies

Document.Elements("GradeProfile") Doest Not Return Elements With The Name Specified?

Jan 2, 2010

Dim Document = XDocument.Load(FileName)
Dim findElement = Document.Elements("GradeProfile")

[code]....

View 4 Replies

Validating Many Groups?

Apr 25, 2009

I'm throwing errors when I call this function before running my calculations:

Function CalcValidation() As Boolean
' Didn't want to leave something out, so I needed a validation to ensure that a selection
' had been made for each component.

[code]....

View 1 Replies

Collapse Groups Of Procedures?

Dec 29, 2011

I have a block of related sub routines I would like to "group" together within class to make navigating a littel easier. When I say group, I mean achieve the same functionality of being able collapse and expand a block of code as would with single procedure or class. Two alternative ways I can think to accomplish this is either use a partial class for those procedures or use namespace. I just wanted to see if VS for VB.Net had another way to be able group and collapse blocks of procedures.

View 3 Replies

Create Many Groups In Contextmenu

Jan 9, 2010

I have a contextmenustrip. I want to create many groups items in that contextmenu. I mean Line which separate each groups. I can do that in Dotnetbar. but with contextmenu in win form I cant.

View 2 Replies

How To Put String Always In Groups Of Twos

Apr 15, 2012

I have a string of hexadecimal numbers that is generated by the program which I created.
B 53 D0 A1 58 3 DA AF E2 15 9E E 68 F0 65
Given by:
HexText = HexText & " " 'the space makes the characters separated into groups

I want the single characters "B" and "E" would both have 0's before them so that the text is all in groups of twos. How can this be done?
0B 53 D0 A1 58 3 DA AF E2 15 9E 0E 68 F0 65
instead of:
B 53 D0 A1 58 3 DA AF E2 15 9E E 68 F0 65

I was thinking I might be able to do a for Loop and go through the text and if it's a single character add a 0 before but don't understand the exact syntax behind it:
For i = 1 to Len(HexText.Text)
'If a character in a group of two of the string is not equal to a hexadecimal number, make that character equal to 0.
Next

View 4 Replies

ListView With Groups Display?

Oct 4, 2011

I state that I am Italian and I am using a translator.

I have a problem that I can not fix.

I have a listview with a group. The property view is SmallIcon

On my windows xp everything works perfectly, but I tried the same thing on Windows 7, and I have this problem: When I add a bit of items in the listview I have some strange display problems, no errors.I made ​​some screenshots to let you know

View 4 Replies

Nest Groups Within A Listview ?

Aug 7, 2009

I want to know if it is possible to nest groups within a listview. I started with a listview in my application that contains list types and this worked fine. I have now been asked to group by Product, then Week Commencing and finally by List Type; This would envolve a 3 group nest and i just cant figure out how to do it (if at all possible).

like so...

Rods
1st Jan 2009
Shakespeare
listview items 1

[CODE]...

If what I am trying to accomplish is beyond the listview control, can anyone suggest a possible avenue to explore?

View 4 Replies

Possible To Make ComboBox With Groups

May 16, 2011

How, if it's possible, you can make a combobox have groups like the html example below:

<select>
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
[Code] .....

View 5 Replies

Separate Text In Groups Of 5?

Jul 20, 2010

I am currently trying to separate my text into groups of 5.For example.

Original text is ABCDEFGHIJK.I am trying to make the output to something like this ABCDE FGHIJ K.Using textbox for it

View 2 Replies

Way To Delete Local Groups ?

Aug 7, 2009

Is there a way to delete local groups through vb.net? i.e. an equivelant to the c# function NetLocalGroupDel?

View 1 Replies

Active Directory Groups In Form

Sep 18, 2008

I am writing an application where active directory validation is required before accessing the main form. There are 2 forms. Form 2 is the login form and form 1 is the main form. The main form would have a simple look, with about 10 checkboxes.I have managed to get the authentication working great but what now need to do is validate groups. Say if "user A" is in "groups A,B and C" and "user B" is in "groups B and C" i would like for them to use my login form, once they log in, the groups that they are members of would appear in a listbox on either form, (whichever is easiest) and is hidden from the user ... if they are in group A, then the main form would show only the first 3 checkboxes, if they are in group B, then it would show the 4th and 5th checkboxes, if in both groups then show the first 5 checkboxes etc.It is a simple idea, but is complicated to explain.As i said, the login form is working with the active directory... here is the code for the login form:[code]Form1 in the code is my main form, and wish for it to change according to which groups the user is in.

View 9 Replies

Adding Groups At Runtime To ListView?

Jun 2, 2011

Any snippet of code for adding groups at run-time to a listview. I am currently listing books (and stats) without groups via the following code which is executed in a loop (one pass per book title).

item = New ListViewItem
item.Text = seq.ToString
item.SubItems.Add(Mid(titlenode.Nodes(N_CSTAT).Text, 3))
item.SubItems.Add(Mid(titlenode.Nodes(N_JSTAT).Text, 3))
item.SubItems.Add(titlenode.Nodes(N_PUBLISHED).Text)
[Code] .....

The listview is set to details view. What I want to do is group the book titles by series. For example, books by Michael Connelly may be grouped by "Harry Bosch", "Jack McEvoy", "Mickey Haller", etc. I can create a new group for each new series by
groupnum += 1
group = New ListViewGroup("group" & groupnum, _
System.Windows.Forms.HorizontalAlignment.Left)
group.Name = "group" & groupnum
group.Header = series
But I cannot find how to add the group to the listview and add the new item to the associated group.

View 2 Replies

Avoid Duplicate Listview Groups?

Nov 25, 2010

on button.click event,Dim category As New ListViewGroup(cbType.Text) If Listview.Groups.Contains(category) Then Arggh! this should work. Listview.Items.Add(lvi).Group = category

Else
Listview.Groups.Add(category)
Listview.Items.Add(lvi).Group = category
End If

If cbType.Text was "Dog", it will add another "dog" group header every time I add an item having selected dog, when I want to add the item to the existing dog group.

View 3 Replies

Big Business In Shirts, Especially For Groups And Teams?

May 20, 2011

does a big business in shirts, especially for groups and teams. They need a project that will calculate the price for individual orders, as well as a summary for all orders.The store employee will enter the orders in an order form that has text boxes for customer name and order number. To specify the shirts, use a text box for the quantity, radio buttons to select the size (small, medium, large, extra large, and XXL), and check boxes to specify a monogram and/or a pocket. Display the shirt price for the current order and the order total in labels.

Include buttons to add a shirt to an order, clear the current item, complete the order, and display the summary of all orders. Do not allow the summary to display if the current order is not complete. Also, disable the text boxes for customer name and order number after an order is started; enable them again when the user clicks on the button to begin a new order. Confirm the operation before clearing the current order.

When the user adds shirts to an order, validate the quantity, which must be greater than zero. If the entry does not pass the validation, do not perform any calculation but display a message box and allow the user to correct the value. Determine the price of the shirts from the radio buttons and check boxes for the monogram and pockets. Multiply the quantity by the price to determine the extended price, and add to the order total and summary total

The assignment also requires a pop up message "Daily Summary" with total shirts sold, total sales, and average sale per customer.So far I have this as my code but I am not sure what needs to change in order to display the correct total shirts- mine only displays the last accepted shirt order.

[Code]...

View 1 Replies

DataGridView - Splitting Rows Into Two Groups

Feb 13, 2009

I am using datagridview I want to split the some rows into two groups?

View 1 Replies

Even Dispersal - Number Of Race Groups

Aug 1, 2011

For a race, I am trying to evenly disperse the heats for smaller race groups within those of larger race groups. I do not want the smaller groups to finish too early and I am also trying to minimize groups running back to back heats.

As an example:
Group A has 4 heats
Group B has 2 heats
Group C has 1 heat

The resulting schedule would look something like this:
A1 B1 A2 C1 A3 B2 A4

To complicate things, there could be any number of race groups and each race group can have any number of heats.

View 14 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved