|
Let's suppose that I can prevent this.
My problem is the .bak file . I just want that if someone get this file , I want to prevent that he restore on another server without my program.
|
|
|
|
|
Hi,
I want to drag and drop a cell in datagridview.I can drag and drop a row but I can't a cell. How can I do this?
Thanks
|
|
|
|
|
|
Hi Abhinav S,
Thanks your answer.
I tried the second link you sent and it works but it is emptying the value of moved cell.
I want to change the cells values.
I want to value of column(0) move to column(1) and value of column(1) move to column(0).
I want to transfer value between cells.
Thanks
Emrah
|
|
|
|
|
I created a List, and populated it with an Invoice number and date.
Now I want to delete all the records before the report start date, and after the report stop date.
So I tried this, and now realize theres no way it can work.
I made a copy of the list, and went through the copy, deleting the record in the original.
Trouble is, the original list gets shorter, and the index I used from the copied list no longer matches.
I not sure what to really do here, or how to handle it. Perhaps the RemoveRange would be better to use.
Looking for ideas, or how to acquire the ranges.
'Stage Six, Remove the records not within the date ranges
Dim tSA As New List(Of invoices_by_SA)()
tSA.AddRange(lSA)
Dim lC As Integer = 0
For Each inv As invoices_by_SA In tSA
If (DateTime.Compare(inv.InvoiceDate, p_startDate.ToString("MM/dd/yyyy")) < 0) _
Or (DateTime.Compare(inv.InvoiceDate, p_stopDate.ToString("MM/dd/yyyy")) > 0) Then
lSA.RemoveAt(lC)
End If
lC += 1
Next
|
|
|
|
|
There's a small trick to it: Use a for-loop instead of a foreach-loop and iterate it backwards. Then you can remove as you wish and like:
for idx as Int32 = list.Count-1 to 0 step -1
if ..... then
list.RemoveAt(idx)
end if
next
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Oh I didn't think of that. Duhh
I tried this and somehow it worked. But I'm not sure if it's 100% solid
I should just switch to your method, since you have proven it reliable.
'Stage Six, Remove the records not within the date ranges
Dim tSA As New List(Of invoices_by_SA)()
tSA.AddRange(lSA)
Dim lC As Integer = 0
For Each inv As invoices_by_SA In tSA
If (DateTime.Compare(inv.InvoiceDate, p_startDate.ToString("MM/dd/yyyy")) < 0) _
Or (DateTime.Compare(inv.InvoiceDate, p_stopDate.ToString("MM/dd/yyyy")) > 0) Then
lSA.Remove(inv)
End If
Next
|
|
|
|
|
Your method is solid. I would prefer the for-loop because it has some performance benefits:
- no list copy required
- no enumerator required
- removing the item by index doesn't require an index-search in the list
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
I can't figure this out. This is my first expression of this type.
I just want to write a shipping address into a single textbox on the RDLC report canvas without creating a set of textboxes
So I have tried this.
I don't understand the line numbers, should it be all on one line, or like code where I can use multiple lines.
Perhaps the ampersand is the wrong concat char to use, or the way I tried to create spaces is wrong.
=Parameters!address_Streetline1.Value & System.Environment.NewLine & Parameters!address_Streetline2.Value & System.Environment.NewLine & Parameters!address_City & " " & Parameters!address_StateCode & " " & Parameters!address_PostalCode & " " & Parameters!address_CountryCode
=Parameters!address_Streetline1.Value & System.Environment.NewLine &
Parameters!address_Streetline2.Value & System.Environment.NewLine &
Parameters!address_City & " " &
Parameters!address_StateCode & " " &
Parameters!address_PostalCode & " " &
Parameters!address_CountryCode
<pre>
|
|
|
|
|
I got schooled in expressions. I forgot the values part
=Parameters!address_Streetline1.Value & VbCrLF &
Iif(Parameters!address_Streetline2.Value = "", nothing, Parameters!address_Streetline2.Value & VbCrLF) &
Parameters!address_City.Value & " " &
Parameters!address_StateCode.Value & " " &
Parameters!address_PostalCode.Value & " " &
Parameters!address_CountryCode.Value
|
|
|
|
|
I'm struggling with a simple task of finding the Index of a line in a Listbox based on the first two characters of the string, Listbox line item.
My best code finds the index of the last item, not the item containing the specified search string.
Private Sub Command1_Click()
Dim find As String, i As Long, found As Boolean
find = "0,3"
For i = 0 To List1.ListCount - 1
If StrComp(find, List1.List(i), vbTextCompare) = 0 Then
found = True
List1.SetFocus
List1.ListIndex = i
Exit For
End If
Next
MsgBox " Index # is: " & i
End Sub
Sample Listbox lines: ("-" indicates a space, forum wouln't display spaces)
0,0 - Item one - Item two - 4/27/2015 9:15:00 AM
0,3 - Item one - Item two - 4/27/2015 9:25:00 AM
0,1 - Item one - Item two - 4/27/2015 10:15:00 AM
0,2 - Item one - Item two - 4/27/2015 10:25:00 AM
So the result of the above is: 4, not 2. My attempts at using 'Left' haven't worked.
Any advice appreciated.
|
|
|
|
|
You are trying to compare different length strings. You need to extract the first characters from the list item before doing the compare.
|
|
|
|
|
[Solved]
I created a function to select and read 0 to List1.ListCount items, split lines at each comma, and compare the first two values of each line. When the correct pair of values are found, that index is deleted, and the listbox is refreshed.
modified 28-Apr-15 0:21am.
|
|
|
|
|
Have you tried something like this?
If StrComp(find, Left(List1.List(i), 3), vbTextCompare) = 0 Then
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
I run my application and i have this error:
Échec de la demande d'autorisation de type 'System.Data.OleDb.OleDbPermission, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
|
|
|
|
|
Something needs permission.
|
|
|
|
|
Something needs permission to run but since we know nothing about what your code was doing at the time, what this application is supposed to do, how you're running it, ..., nothing, there's nothing anyone can tell you that would be helpful.
The quality of the answer you get is directly dictated by the quality of the question you ask.
|
|
|
|
|
Hi,
I have two VB.Net Projects. For Example Project1 and Project2. I make exe to Prject2. Project1 has one MDI Form. I want to run Project2.exe in MDI_Form in Project1 when click a button in Project1.
I can run to Project2.exe from Project1 but it doesn't run in MDI Form in Project1. It's open in another window.
Thanks.
|
|
|
|
|
Every process will open in it's own window. You cannot prevent that. There is also no standard way of getting the window into another application as this is something that is not supported.
It can be done, though you may not like the results. You have to create a MdiChild form in your MDI project. Don't put anything on the form. When you launch your other project, create an instance of your child form and set it up as a MdiChild as normal.
After you launch your other process, you have to wait until the Process.WaitForInputIdle is true to be sure the process window has been created. When that finally happens, you can get the Process.MainWindowHandle property value. You then call the Win32 API function SetParent to reparent the process window to your child form. Your essentially making your MdiChild form the new Desktop window for your other app.
BUT YOU HAVE NO CONTROL OVER THE BEHAVIOR OF THE CHILD PROCESS WINDOW! Users can maximize, minimize, move, whatever, ... the process window inside your MdiChild form. There's really nothing you can do to prevent this.
|
|
|
|
|
Hello !
Maybe it's a stupid question , but I want to know if exist on vb.net any way to have a Partial Public Sub ?
Thank you !
|
|
|
|
|
|
Hi,
I have the following method in my (Windows) application to format a report in a DataGridView. The report has a variable amount of columns.
Private Sub FormatColumns(ByVal dgv As DataGridView)
Try
For Each clm As DataGridViewColumn In dgv.Columns
Select Case True
Case clm.Name Like "Konserni"
clm.Width = 150
Case clm.Name Like "Ketju"
clm.Width = 150
Case clm.Name Like "Myyjä"
clm.Width = 150
Case clm.Name Like "Myynti"
clm.Width = 100
clm.DefaultCellStyle.Format = "c"
Case clm.Name Like "Budjetti"
clm.Width = 100
clm.DefaultCellStyle.Format = "c"
Case clm.Name.ToLower Like "kate"
clm.Width = 120
clm.DefaultCellStyle.Format = "P"
Case Else
clm.Visible = False
End Select
Next
Catch ex As Exception
EC(ex)
End Try
End Sub
When I run the report, and apply this method all columns are formatted as percentages (except the string values of course). It is supposed to format each column differently, depending on the type of value.
What am I doing wrong, or what did I misunderstand about (the use of) DefaultCellStyle ?
Any help appreciated.
Regards,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
I doubt there is a problem with DefaultCellStyle. The DefaultCellStyle only applies to the column you set it in, not to all columns.
Set a breakpoint on the For Each line and step through the code in the debugger, line by line, so you can see what the code is seeing and doing. I really wouldn't use the Like operator here since it's intended for pattern matching, not outright equality.
|
|
|
|
|
Hi Dave,
Thanks, I will try step through.
Regards,
Johan
P.S. In the real code I am matching a pattern, it appears that the stars were dropped by the codeproject editor.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Ok, so I tried step through, and the only thing unexpected that I see, is that once the Format property has been set for a column in the loop, that setting is maintained through subsequent loops, until changed (again).
So unless this is a bug or some cache issue in the debugging process, showing the value of a property incorrectly, I suppose it is possible that properties of the DefaultCellStyle, accessed through the column, get set for all columns in the DataGridView, not just for that specific column.
I have worked around this by using:
DataGridViewCell.Style.Format , but it takes noticeably longer now that I need to apply formatting one cell at a time.
My advice is free, and you may get what you paid for.
|
|
|
|