|
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.
|
|
|
|
|
Nope. ``DefaultCellStyle`` applies ONLY to the column that it is set on.
Also, there is no debugging "cache".
I coudln't tell you what's going on because we simply don't have enough information on your code and how the rest of the grid is setup.
|
|
|
|
|
Hi Dave,
Would it suffice if I tell you the steps (in pseudo code) ?
1. Open Visual Studio 2012 Express
2. Start new Windows Forms project (.NET 4)
3. Drag DataGridView and button controls onto Window
4. Press button =
- Use SqlCommand to run MS SQL stored procedure that returns a table
- Use SqlDataAdapter to enter data into DataSet
5. BindingSource.DataSource = DataSet
6. DataGridView.DataSource = BindingSource
7. Run Method as in my original post
Regards,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Johan Hakkesteegt wrote: Would it suffice if I tell you the steps (in pseudo code) ?
No, because that is what you THINK the code is doing. The real code is required to show what the code is ACTUALLY doing.
|
|
|
|
|
Hi Dave,
You were right (as usual).
I found that I was calling another method (see below) before using the one I posted originally. When I commented this one out, the first method worked as expected. Looking at it though, I don't see how this method caused the unexpected behavior. As far as I can tell, it is pretty much doing the same thing.
Public Sub FormatTable(ByVal dgv As DataGridView)
Dim cs_Default As New DataGridViewCellStyle(dgv.DefaultCellStyle)
Dim cs_Money As New DataGridViewCellStyle(cs_Default)
Dim cs_Date As New DataGridViewCellStyle(cs_Default)
Dim cs_String As New DataGridViewCellStyle(cs_Default)
Dim cs_Integer As New DataGridViewCellStyle(cs_Default)
Try
With cs_Date
.Alignment = DataGridViewContentAlignment.MiddleLeft
End With
With cs_Money
.Alignment = DataGridViewContentAlignment.MiddleRight
.Format = "F"
End With
With cs_Integer
.Alignment = DataGridViewContentAlignment.MiddleRight
.Format = "N0"
End With
With cs_String
.Alignment = DataGridViewContentAlignment.MiddleLeft
End With
For Each clm As DataGridViewColumn In dgv.Columns
Select Case clm.ValueType
Case Type_Double, Type_Long, Type_Decimal
clm.DefaultCellStyle = cs_Money
Case Type_Integer
clm.DefaultCellStyle = cs_Integer
Case Type_String
clm.DefaultCellStyle = cs_String
End Select
Next
Catch ex As Exception
EC(ex)
End Try
End Sub
Regards,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
There is probably something in between this method and the other one. Having multiple methods to format a grid is a bad idea because of the problem you're running into, though it's, sadly, kind of common.
If I have multiple grids I need formatted differently, but overall styled the same, I normally create my own DGV class, inheriting from the .NET DGV, setup the base styles common to all grids, then use that I my forms.
When I need to setup formatting, I have a method on the form that hosts the grid explicitly setting up the one grid instance with the things that are over and above the items setup in the base grid. This sometimes results in a duplication of code but I consider that a small price to pay for flexibility when I need to change a grid here and there.
Now, you might want to step through this code and the other code. It would appear that you're replacing the entire style of a column instead of making changes to it. If this code is called to setup your grid and then you call the other method to further change it you could be replacing the styles from one method with the styles from another instead of making changes to the style that is in place.
|
|
|
|
|
Thanks Dave, I will look into that.
Thanks for the help !
My advice is free, and you may get what you paid for.
|
|
|
|
|
I think "SELECT CASE TRUE" would always select the same case. Did you want to switch on the name?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
In VB the switch works like this. In other words, "Select the first case which' outcome conforms to the main statement".
It appears that the codeproject editor dropped the stars from the pattern matching.
Regards,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Johan Hakkesteegt wrote: In VB the switch works like this. Never seen it before; nice to learn something new
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Im starting a new personal project and it is years since I have done any coding. I do understand C++ to a basic level, however Im looking for convenience here and not attempting to program the next OS of the future.
Anyway Im basically wanting to write a program that stores basic rehearsal scripts for a language class I am part of.
I want to be able to quickly create a script to practice various language techniques from.
The basic scripts will fall into categories.
The basic structure goes something like this (I want to be able to alter this if needs be, in fact I probably will want to alter this).
Script Type 1
Script Type 2 part a
Script Type 2 part b
Script Type 2 part c
Script Type 3
Script Type 4 part a
Script Type 4 part b
Script Type 4 part c
For example script Type 1 will be an introductionary statement
Type 2 will be information about me. And so forth. The idea being I can print off a sheet of conversation for someone to speak from. SO they dont need to think what they are saying just how to say it.
For each of these script types I will have a collection of different scripts of varying length.
Each type will have multiple lines in the structure of
ME:
YOU:
ME:
YOU:
....
Im sure you get the idea.
I want to be able to select which scripts I use for each of the Types and Parts from a growing collection.
Now here is where my issues arise.
Should I create a database or use some sort of text file parsing?
I am unsure how many Script types that I want (basic at the minute but this could grow).
If I use text file parsing, will it make sense to have a different (small) text file for each script and some sort of header at the top so it can be recognised?
Or should I do one big text file with Headers?
Or a text file for each script type?
As for printing this off, I am planning on having it outputted in HTML to a web browser so that the print out looks attractive.
My other thought is to maybe use a database, but I think this is possibly overkill for this.
I also want to create a script input screen so I can input new scripts to be stored, using whatever storage medium is the best.
Please advise. I have used text parsing in the past and I have used databases in the past. But for this project I am just wondering what would bee most effective.
By the way when I say language I mean foreign language.
Please advise.
|
|
|
|
|
I would suggest you to go with a database. While certainly possible, I would find a collection of text files where I have to parse headers a bit messy. And updates to the data and structure would be more convenient with SQL (with the exception of single-file updates where you otherwise could just use a text editor). If you would ever decide to introduce more relational data you would start running into trouble with single files.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Thank you for your response.
Final question should I store all the scripts in the database or just use the database to point to a file name.
This might sound a dumb question, but I have only used databases for storing specific information such as personal info and billing info?
|
|
|
|
|
I would store the scripts in the database. The only advantage I could see not doing this (and just storing the file name instead) would be the ease of editing a script by opening it with a text editor - so you wouldn't have to implement a functionality for that. But the drawback would be that you give up one of the database's benefits: data integrity.
If you probably want to offer your application to your class mates you might want to choose a single-file database system for ease of setup (SQLite would be my recommendation).
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Thanks, I am looking into SQLite now.
What I am planning on doing is having two tables.
One table as follows
Script_ID (PK, FK)
Script Name
Type
And the other
Line_ID (PK)
Script_ID (FK)
Line
Speaker (Me/You)
Then I can leave the formatting for when an HTML file is created.
Cheers for your help. Makes sense now on how I can make this work.
modified 21-Apr-15 14:03pm.
|
|
|
|