|
I am using LINQ to group by however after group By I need to create a new table with data...
I am using Dataview to get all data
Dim vDependent As DataView = myDataTable.DefaultView
vDependent.RowFilter = "EEGRP ='" & item.EEGRP & "' AND EESSN ='" & item.EESSN & "'"
Is there is a better way to do this?
Dim data = myDataTable.AsEnumerable().GroupBy(Function(r) New With {Key .EEGRP = r.Field(Of String)("EEGRP"), Key .EESSN = r.Field(Of String)("EESSN"), _ Key .DEDENF = r.Field(Of String)("DEDENF"), Key .DEDENM = r.Field(Of String)("DEDENM"), _
Key .DEDREL = r.Field(Of String)("DEDREL")},
Function(key, rows) New With
{
Key .EEGRP = key.EEGRP,
Key .EESSN = key.EESSN,
Key .DEDENF = key.DEDENF,
Key .DEDENM = key.DEDENM,
Key .DEDREL = key.DEDREL,
.Dates = rows.Select(Function(r) DateFromStringParts( _
r.Field(Of String)("DEIBCY"), _
r.Field(Of String)("DEIBYR"), _
r.Field(Of String)("DEIBMT"), _
r.Field(Of String)("DEIBDY"))).OrderByDescending(Function(d) d).Take(3).ToList()}
)
Dim result As New DataTable
result = myDataTable.Clone()
For Each item In data
Dim vDependent As DataView = myDataTable.DefaultView
vDependent.RowFilter = "EEGRP ='" & item.EEGRP & "' AND EESSN ='" & item.EESSN & "'"
Dim newRow As DataRow = result.NewRow()
newRow("EEGRP") = vDependent(0)("EEGRP")...
|
|
|
|
|
I downloaded this source from code Project because I needed an HTML Editor.
I was just wondering if you gius think I should build this as a seperate project, and add it to my project?
So I would build it, and then add it to my toolbox, and drop the control onto my form.
A Windows Forms based text editor with HTML output[^]
|
|
|
|
|
It says, in the article:
To embed it into your own app, simply reference the EXE as if it were a DLL from your app in Visual Studio.
It should show up in the Toolbox Window in Visual Studio.
Check the source code for examples of how to access it from your code.
|
|
|
|
|
I should of read the whole article, how stupid of me.
|
|
|
|
|
It often helps, yes.... on the same principle, I remember my math teacher at school used to drum it into our heads over and over: "Read the question at least three times before even attempting to answer it. And if you get stuck, read it again." Nowadays, this is encapsulated in the acronym "RTFM". The answer is, as they say, (usually) out there.
|
|
|
|
|
I need to implement that rule again.
Well, at least I translated the project to VB and got it to work, plus upgraded it to 4.51. Just need to fix the little errors and fine tune it for my needs. Pretty neat how it works.
|
|
|
|
|
I am reposting my problem hopefully a bit more specific for you guys!
The program I am writing uses various labels which retrieves data from Microsoft Access.
I use the following code to print a specific label:
e.Graphics.DrawString(lblMethod.Text, New Font("Arial", 10, FontStyle.Regular), Brushes.Black, 10, 420)
Although this works fine and prints but this particular label text has a lots of text and therefore does not wordwrap as such.
How can I get this label to wordwrap automatically?
|
|
|
|
|
You're not printing a label. You're printing text. Also, your code leaks resources since you're not disposing the Font object you created.
There's plenty of examples on then web. All you have to do is Google for "vb.net print string to printer with word wrap[^]".
|
|
|
|
|
HI,
i need to write a procedure to send a file by ftp or tcp from a Datalogic mobile device to a PC in the same LAN.
The mobile device has a SO win CE 5.0 and is connected to the switch by wireless connection.
I tryed using VB 2005 to create a connection but nothing seems working.
Does anybody have an idea about how to send files from win ce to a pc using VB?
Thanks.
|
|
|
|
|
|
I am trying to use linq...however running into the issue...
how to I combine 3 fileds to Date?
.Dates = rows.Select(Function(r) r.Field(Of DateTime?)("DEIBMT") & "/" & ("DEIBDY") & "/" & ("DEIBCY") & ("DEIBYR"))
Dim data = myDataTable.AsEnumerable().GroupBy(Function(r) New With {Key .EEGRP = r.Field(Of String)("EEGRP"), Key .EESSN = r.Field(Of String)("EESSN")},
Function(key, rows) New With
{
Key .EEGRP = key.EEGRP,
Key .EESSN = key.EESSN,
.Dates = rows.Select(Function(r) _
r.Field(Of String)("DEIBMT")) _
.OrderByDescending(Function(d) d).Take(3).ToList()}
)
|
|
|
|
|
It depends what type your columns are. Assuming integers, something like this should work:
.Dates = rows.Select(Function(r) New DateTime( _
(100 * r.Field(Of Integer)("DEIBCY")) + r.Field(Of Integer)("DEIBYR"), _
r.Field(Of Integer)("DEIBMT"), _
r.Field(Of Integer)("DEIBDY")))
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
All columns string... could you show me how I should do this with strings?
|
|
|
|
|
String representations of integers, or something else?
If it's integers, then Integer.TryParse will work:
Private Shared Function DateFromStringParts(ByVal century As String, ByVal year As String, ByVal month As String, ByVal day As String) As DateTime?
Dim cy, yr, mt, dy As Integer
If Not Integer.TryParse(century, cy) Then Return Nothing
If Not Integer.TryParse(year, yr) Then Return Nothing
If Not Integer.TryParse(month, mt) Then Return Nothing
If Not Integer.TryParse(day, dy) Then Return Nothing
Return New DateTime((100 * cy) + yr, mt, dy)
End Function
...
.Dates = rows.Select(Function(r) DateFromStringParts( _
r.Field(Of String)("DEIBCY"), _
r.Field(Of String)("DEIBYR"), _
r.Field(Of String)("DEIBMT"), _
r.Field(Of String)("DEIBDY")))
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
nice !!
|
|
|
|
|
I have a ListView control inside my system where its content display different information based on different Button control. And information will only be displayed if the user have the right to view the information. This is filtered when they login into the system. So for example, the user is a student and he can only view information from Button1.Text, Button2.Text, Button5.Text and the rest button will result blank in ListView1.Text (because as I mentioned, they have no right to view certain information). So I want those button that isn't showing any information to become invisible.
The code that I currently use
If ListView1.Items.Count > 0 Then
For Each controls As Control In Panel1.Controls
If TypeOf controls Is Button Then
DirectCast(controls, Button).Visible = False
End If
Next
End If
But if I use this code, the whole Button will become invisible because all Buttons refer to the same ListView control. So how would I code it to make the ListView1.Text be able to recognize which Button it belonged to and make them invisible?
|
|
|
|
|
You should make this decision when the user logs on. Based on the status you just show the buttons that are relevant to that user. They can then click any that are visible to get the ListView populated.
|
|
|
|
|
Hello guys, I have created a simple VB.net program (windows form application) and everything is working fine. But I want my program be able to copy itself to the desktop when user launch it for the first time. And this copying process should be done silently without showing to user. How to do that? Thank you.
|
|
|
|
|
Where do you intend to copy the .exe FROM?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Elly08 wrote: And this copying process should be done silently without showing to user. Why? You should not be modifying the user's setup without their permission.
|
|
|
|
|
First, copying the .EXE and .DLL files you the users Desktop is a REALLY STUPID IDEA!
You INSTALL your application into a proper folder, like some folder under Program Files. You then create a shortcut to the application on the All Users Desktop or the users Desktop. This is also usually done from your installation .MSI.
Copying the application files to the Desktop gives every opportunity to the user to screw up the application since they will have full permissions to modify anything and everything on the Desktop, deleting your application files, any supporting .DLL's and configuration files, ..., what have you.
Besides, copying the files to the desktop cannot be done "silently". SUre, you can do it without showing a progress bar, BUT THE FILES WILL STILL SHOW UP ON THE DESKTOP!
|
|
|
|
|
I suspect he want to do this from a web browser
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
So do I. That's an even dumber idea and an even greater security risk.
|
|
|
|
|
Sorry, my question might not clear. What I mean here is, how do I copy the package file (not the source code) to user PC when they launch the program. I want the program will be able to copy its file from the release folder (inside the bin folder) to the temporary folder.
|
|
|
|
|
Still not clear at all.
What kind of app is this? ASP.NET, Windows Forms, WPF, ...??
How is the user launching this if it's not already on their machine?
|
|
|
|