LINQ: Get Index Of XML Setting List(Of

Mar 21, 2012

I am trying to get an index of a List(Of Details) Details being a class i use instead of an annon method. Is it because i am using array.findindex when it's not an array but a list(Of???

Dim index As Integer = Array.FindIndex(Details, Details.FirstOrDefault(Function(nd) nd.Name = "name"))
Error1Data type(s) of the type parameter(s) in method 'Public Shared Function FindIndex(Of T)(array() As T, match As System.Predicate(Of T)) As Integer' cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error.

View 5 Replies


ADVERTISEMENT

VS 2008 Get Original List Index Of LINQ Query

Oct 24, 2010

If I use a LINQ query over some type of collection, is there any way to know the initial index of an element of the result?

Purpose: I make a query to set as source of a DataGridView, and on a (button)cellclick event I want to a call a method that needs to reference the collection at the correct index.

View 13 Replies

C# - Setting Call With An Index?

Oct 24, 2011

I can assign my user settings this way:

MySolution.Properties.Settings.Default.settingname1 = "mystring1";
MySolution.Properties.Settings.Default.settingname2 = "mystring2";
...
MySolution.Properties.Settings.Default.settingname300 = "mystring300";

[Code]....

View 1 Replies

Setting Index Value To Any Object?

Sep 5, 2009

I am new to .net and am wondering what Index is in .net. In vb6 I could set a index value to any object and then duplicate them and use the same code. Does .net have something like this?

View 3 Replies

Determining The Index Of A List Based On Another List And Vice Versa?

Jan 6, 2012

Suppose you have list 1 (ilist1) and list 2 (ilist2) both lists have 3 items.

At index 0 item1 which has text "-- Select --"
At index 1 item2 which has text "Yes"
At index 2 item3 which has text "No"

Both lists have identical items. I would like to know if it is possible to have the selection of list one be "Yes" and the selection of list two be "No" and vice versa using SelectedIndexChanged or something of the sort.

For example:
ilist1 = --Select--
ilist2 = --Select--

[Code]....

View 2 Replies

Setting Selected Index On DataGridView Combobox?

Oct 13, 2008

I can't seem to set the selected index or selected value of a DataGridView combobox when loading data from a database. My DGV has two combobox columns which are bound to datatables. The DGV itself is not bound initially. After adding a row, I select a value from each combobox which then populates the rest of the cells in the row. I'm using the EditingControlShowing event to add an eventhandler to catch the SelectedIndexChange of the combo boxes. This all works as needed. My issue comes when populating the DGV with saved data, I need to add the rows and set the selected index and/or selected value of each combo box. I've searched through various forums and articles for the last week with no luck.

I'm using VS2008 sp1, .NET 3.5 sp1 and SQL 2005 sp2 Express.

View 8 Replies

Setting Column Index For Databinded Combobox In Datagridview?

Dec 17, 2010

I have a datagridview with 3 columns. The second column is a combobox which I want to bind with a dataset. How do I go about setting the column index for it as I am doing something like this.

Dim ComboCol As New DataGridViewComboBoxColumn

ComboCol.DataSource = SDS.Tables(0)

ComboCol.ValueMember = "Specie"[code].....

View 3 Replies

VS 2008 Setting The Index Positions And Lenghth To A Specific Number?

Mar 23, 2010

I dont want to be setting the index positions and lenghth to a specific number becuase when i choose a different name from the listbox that is at a different position or longer it wont display it properly. explain to me another way around this so as it will allow any details to be selected and read???

[Code]...

View 16 Replies

LINQ - Index Was Outside Bounds Of Array

Feb 6, 2012

I currently have a program that uses Linq to read a CSV file. Everything was working great until a recent change was done where the CSV file had records being added to it where the last 2 columns where empty. So, the error I am getting now is Index was outside the bounds of the array. The question I have is how do I handle a column where an empty or null value is set in the CSV file?

Here's my abbreviated code below.
Function readLINQ(ByVal strCustomerFile As String) As DataTable
Dim readlines = File.ReadAllLines(strCustomerFile)
File.WriteAllLines(strCustomerFile, readlines.Skip(4).ToArray())
Dim gTable As New DataTable("CashFile")
With gTable
[Code] .....

View 2 Replies

Pass Index To JQuery From LINQ?

Nov 19, 2010

I'm having trouble with VB LINQ syntax. I have a web service that is returning JSON to jQuery and I need the index of the items but can't figure it out. [code]...

View 1 Replies

VS 2008 LINQ Get The Index Of Datagridview Row?

Apr 29, 2012

vb
Dim CheckedRows = From dgv As DataGridViewRow In Me.DataGridView4.Rows _
Where dgv.Cells(0).Value = True _
Select New With {.a = dgv.Cells(1).Value, .b = dgv.Cells(2).Value}

my code above works fine but how to get the index of the row on which the checkbox is checked

View 5 Replies

.net - Reset Index In LINQ Select Clause?

Mar 13, 2012

My LINQ query:

Dim groupedData = (From p In pData _
Group By p.TruncParam Into Group) _
.SelectMany(Function(g) g.Group) _
.Select(Function(d, idx) New With { _

[Code]...

When the TruncParam changes, I would like the index (idx) in the Select clause to reset to 1. So, in the list above, the Index should be SOLUB0001, SOLUB0002, INSOL0001, INSOL0002...CLRES0001, SUMCA0001, SUME0001.

How should I alter the LINQ query?

View 1 Replies

Sort Datatable In .net With Linq By Column Index?

Mar 23, 2012

I need to sort a datatable. I do it with linq this an example

Dim query = From c In dt.AsEnumerable _
Order By c.Field(Of DateTime?)("LastPurchaseDate"), _
c.Field(Of String)("LastName") Descending
Dim dv As DataView = query.AsDataView

But my problem is that i need to sort the fields not by passing the name of the column but the index of that.

View 2 Replies

Convert A List Linq Expression To Defined List Class?

May 26, 2012

y have this class

Private Class MyClass
Public Property propertyOne() as String
Public Property propertyTwo() as String

[code].....

View 2 Replies

How To Use The Vb Equivalent Of ++ For An Index Property In A Linq Query Projecting A New Type

May 3, 2011

I'd normally do this in C# but since I've got to get this code in this particular assembly which is a vb.net one, I'm stuck.

Here's my linq query:

Dim i As Integer = 0

Dim oldAndCurrentIntersectionOnNames = From currentApplicant In currentApplicants _
Group Join oldApplicant In oldApplicants _

[CODE]...

You'll see the .Index = i+=1

This was my attempt to do what I'd quite happily do in C# (i.e. Index = i++) in VB. Unfortunately the VB compiler doesn't like that. how I'd do this in VB.

View 2 Replies

.net - Create New Distinct List(of T) From Existing List(of T) Using LINQ?

Jun 1, 2011

How can I get a new distinct list from an existing list using LINQ? This is what I have so far and it is not distinct but does give me a new list.

Dim tmpQryColumn = (From a In _allAudits
Select New CheckBoxListItem
With {.Id = a.AuditColumn, .Name = a.AuditColumn}
).Distinct()
_columnList = New List(Of CheckBoxListItem)(tmpQryColumn)

View 2 Replies

.net - Searching A List Of Objects In An Object List Using Linq?

Dec 22, 2010

I have 2 classes

Public Class Shipper
Public Property ShipperID As Long
Public Property CreateDate As DateTime

[Code].....

View 1 Replies

Create New Distinct List(of T) From Existing List(of T) Using LINQ?

Mar 12, 2010

How can I get a new distinct list from an existing list using LINQ? This is what I have so far and it is not distinct but does give me a new list.

Dim tmpQryColumn = (From a In _allAudits
Select New CheckBoxListItem
With {.Id = a.AuditColumn, .Name = a.AuditColumn}

[code]......

View 2 Replies

Finding Items In One List That Aren't In A Second List Using Linq

Jan 25, 2011

I have two generic lists, named ListA and ListB. Both ListA and ListB could potentially have duplicate items. What I would like to do is use LINQ to grab the items in ListB that are not in ListA, but I'm unsure how to do so.

View 8 Replies

Linq - Create A List Of Integers From A List Of Objects?

Nov 23, 2011

I'm trying to create a list of days(integer) from a list of dates(date).

I tryed to do this....

[Code]...

View 4 Replies

Loop Against A List And Fill Another List From Its Data Using Linq

Jul 29, 2010

This is what I want to do as seen in C#(loop against a list and fill another list from its data using Linq)

[Code]...

View 1 Replies

Getting List Of Items Not In Parent List Using LINQ

Mar 28, 2011

I am writing app in vb.net

I have two variables one with list of RoomRate and other with list of RoomTypes.

We have RoomRates and RoomTypes linked with RoomTypeInfo variable insite the RoomRate.

So how do i find the RoomTypes which donot have the RoomRates Defined.

My Sample Code:

class RoomType
property UIN as integer
property Title as string
end class

[Code]......

View 2 Replies

XML To LINQ - Get List Of All Products From XML Doc And Put Them Into A Generics List

Jun 30, 2009

I'm basically brand new to LINQ. I've seen some examples that allow me to strong type objects using LINQ but I don't really understand them because they're in C#, which I guess lets you do different things with LINQ(I think?). [Code] I just want to get a list of all the products from the XML doc and put them into a Generics list.

View 3 Replies

A List Where An Index Has Three Values Associated With It?

Nov 16, 2011

I have been searching everywhere but I am unable to find a reference to what I need.I have a huge number of entries where each entry is composed of three long numbers:

a b c
1 2 40
2 1 40
1 8 12
3 9 13
8 1 12
ect.

in my algorithm I will find that I need to disregard values in column a which will then lead me to disregard values in column b. I initially thought that I may want to use three arrays and just change the disregarded value to a null value with each iteration. find function that would allow me to not have to loop through the entire array every time.This lead me to want to define the columns as lists where I could remove specific values from the list and reduce the size of the list with each iteration of the algorithm. The problem then is how do I say, listb.remove(8) and at the same time have the corresponding values for lista(1) and listc(12) removed?

View 4 Replies

Get The Selected Index Of The List Box?

Dec 9, 2010

'Get the selected index of the list box 'use that selectedindex for the row of the array and get both the quantity and price into local variables in VB

[Code]...

View 6 Replies

List Box Selected Index?

Dec 6, 2011

I think I'm having a brain fart on this but I can't seem to figure out why this is not working.

Public Class Radio_Main
Dim RadioDial As String = 1
Dim Go As String = "http://"
Private Sub pb_Tuner_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pb_Tuner.Click
'My.Computer.Audio.Stop()

[Code]...

View 2 Replies

Find Index In List(of String)

Jun 7, 2010

I have an List(of String), i need to find the index of a particular string in that list. I have searched msdn , but i am confused over the predicate methods. I have never used predicates. This i what i have tried

vb
'on button1 click
Dim Heads As List(Of String) = Me.GetSelectedNodes()
Dim tmp As Integer

[Code].....

View 1 Replies

Find List Index For A Given Property Value?

Aug 15, 2011

Ive got two lists (each representing a table in a DB, so they are related). lstTransaction has t_id, date, and cust_id. lstCustomer has Name, and cust_id.For each item in lstTransaction Id like to find the index in lstCustomer where lstCustomer.cust_id = lstTransaction.cust_id.

View 5 Replies

How To Search List By Index Or String

Aug 29, 2011

How on specific behaviour can be created in a custom class. I want to be able to create a custom class (a kind of list) where I can access the items by their index (this is the easy part), but also by a string that would describe them. Here is an example:
MyClass(1).SomeProperty = "NewValue"
MyClass("Item1").SomeProperty = "NewValue"

You can see this kind of behaviour in dataset for example where you can select a table by its name or by its index like this :
DataSet.Tables("MyTable").Rows...
DataSet.Tables(1).Rows...
How can I create a custom class that will behave like this?

View 2 Replies

List (Of T) Items Accessed By Index Or By Name?

Oct 17, 2011

I want to build my own class. In it, I need to recreate a behavior we can see in DataTable and in some other places : accessing items by their name or by their index. [code]...

View 5 Replies







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