.net - Shared Form.ShowDialog Method?
Apr 18, 2011
I have a new developer that is calling Showdialog (in VB.NET) on a Windows Forms form without first creating an instance of the form.How is this possible? I don't see a shared method for ShowDialog...
I'm not crazy about this approach either as it seems to me that the dialog will not be disposed until the application exits.What am I missing? Is this a new best practice?OK, Form2 is just a blank form.Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Form2.ShowDialog()
End Sub
End Class
View 1 Replies
ADVERTISEMENT
Aug 25, 2011
I have a class like this:
[Code]...
It works, when I make getBar methods public, but I don't want to expose these unneccessarily. Why I can't call private shared methods from a public one in the same class is over my head. I'm using .net framework 4.0 in a web application.
View 1 Replies
Aug 12, 2009
Given in the following language specification, for me at least, calling Db.Foobar() [In the following code] does not indeed call off to the Shared Constructors of the base classes. I am curious as to a) is this my own fault for doing something wrong or b) is this an error in the language specification[code]...
View 2 Replies
Mar 28, 2011
I have a form being called form several forms using ShowDialog().
1. Is there a way for called form to know which form called it by receiving a code or key from the calling form?
2. The calling form has a gridview. How can the called form pick up a column's value from the currently highlighted row in gridview in the calling form?
View 4 Replies
Aug 7, 2009
I'm having an interesting issue that I can't reproduce on a different project, but can consistently on this one. I have no clue what might be causing it, but am hoping that someone may have seen it before.
I have a main form, from which I run a series of checks. On this form, I have a listview control. Because of some issues with the refreshing of this listview control, I had to create my own messagebox. It's just a form that displays some text ( it also happens to look nicer than MsgBox; in my opinion, anyways ). It's been working great for months, until recently.
My problem is that on my main form's load event, I run this check, which returns an error within a try/catch block. I then call my custom messagebox with a message. It in turns calls it's ShowDialog() function.
In any other situation ( after the main form has been loaded ), I have no problems. The messagebox goes on the screen and behaves appropriately ( ie: waits for my input and acts as a modal dialog ( stops execution of my main form's thread ) ). However, on this onload event, my messagebox comes up and goes away almost immediately afterwards.
I've traced it all the way to the showdialog() call. For no explicable reason, it appears to skip right over this call, without me doing anything on the form.
Here's what the inner trace looks like ( when I put a breakpoint on the onclosing event for this messagebox form ):
CODE:
View 10 Replies
Feb 28, 2012
As the question states, can a shared method of an object be multithreaded? I don't quite having threading down in my skillset, otherwise I would test myself. On the other hand, I am involved in designing class that could be part of a multithreaded application in VB.Net.
View 3 Replies
Jul 7, 2009
I have a class that inherits from a base class (this contains a lot of common db related stuff amongst other things and is marked as MustInherit). I want to write a shared method in which I call a base class method, however the compiler gives me the message 'MyBase is only valid within an instance method'. This shared method is a logging method and will be used a lot within the app, I'm trying to avoid having to instantiate an object each time I want to call it.
Is it possible to access the base class methods from a shared method?
View 5 Replies
Aug 26, 2009
I have a utility class that creates & returns a db connection:
Public Shared Function GetConnection() as OracleConnection
dim c as New OracleConnection()
... set connection string...
c.Open()
Return c
End Function
Is there any risk of concurrent calls returning the same connection? The connection string enables pooling.
View 4 Replies
Jan 5, 2012
Quote:
Originally Posted by kaliman79912
Quick note: Close does not dispose of the form if it was displayed using .ShowDialog, but I guess this is not the case.
I did not want to hijack the other thread [URL] but would like to have this clarified for me.
View 5 Replies
Sep 27, 2009
I'm creating a Shared (static) method in ASP.NET MVC so it can be used by any controller in my project. This static method needs to generate a URL. I think I need to use System.Web.Mvc.UrlHelper, but I can't figure out how to call it from within a static method.The constructor seems to want a RequestContext.
View 1 Replies
Jul 24, 2011
I like to create an extension method to Image.FromStream Public Shared Function FromStream(ByVal stream As System.IO.Stream) As System.Drawing.Image
With possibility to cancel processing like Public Shared Function FromStream(ByVal stream As System.IO.Stream, ByVal CloseTask As ManualResetEvent) As System.Drawing.Image
View 1 Replies
Dec 1, 2009
How can i use Server.MapPath in shared methos i tried something lile this [code]...
View 1 Replies
Feb 24, 2009
I have a form that I am using to search for records in a dataset, it has a text box for entry of the search criteria and a 'Search' button to initiate the editing of the entry and .Filter on the BindingSource. This is one form in a project with many, when I show it using .ShowDialog it always disappears, (not visible and not loaded) after the 'Search' button is clicked, I have stepped through and there is no .Hide or .Close that it encounters, it performs all of the logic correctly but control is returned to the main form it was shown from. When I use the .Show method, I do not have this problem.
View 5 Replies
Nov 4, 2010
I converted this app from VB6. I have 2 forms. Form1 instantiates Form2 via a Menu Item.I am having trouble getting Form2 to end when clicking close (X). If Form2 is 'idle' it closes fine; but if I am in a loop processing anything all the events fire, but it continues processing in Form2. I've tried messing with Dispose, Close, Application.Exit, Application.ExitThread. My last attempt was creating my own event to fire back to Form1 and dispose Form2 -- and it hits it but Form2 is still running. What is the deal? BTW if I use just Show vs ShowDialog -- Form2 just blinks and disappears.[code]
View 2 Replies
Jan 21, 2009
I converted this app from VB6. I have 2 forms. Form1 instantiates Form2 via a Menu Item.I am having trouble getting Form2 to end when clicking close (X). If Form2 is 'idle' it closes fine; but if I am in a loop processing anything all the events fire, but it continues processing in Form2. I've tried messing with Dispose, Close, Application.Exit,pplication.ExitThread. My last attempt was creating my own event to fire back to Form1 and dispose Form2 -- and it hits it but Form2 is still running. What is the deal? BTW if I use just Show vs ShowDialog -- Form2 just blinks and disappears.
Form1 does this
Dim f2 as Import
:
[code].....
View 6 Replies
Sep 8, 2010
I have three form First Form is MDi form and Second Form Is Child Form and third Form Is small form.The small form conatin DataGridView searcher for name and I want whe I press the Event Mous Click he copy value from cell"column" of DataGridView to Child Form..[code]
View 7 Replies
Nov 4, 2010
I have been thrown in at the deep end with an existing VB.NET project at work. I have never used VB.NET before so I am struggling a little. Does anyone know how to solve the following.I need to pass an instance to client side and then pass it to a shared method in order to access instance methods from when the shared method.The starting point is a fileupload control within the HTML of my Contacts.aspx file:
<asp:FileUpload ID="DocUpload1" runat="server" onchange="CallMe();" />
The onchange event calls a javascript method, see below, this uses AJAX PageMethods to called a Shared method in my code behind This is the script code which is in my Contact.aspx file
[Code]...
If anyone knows the solution please could they update the code as I probably won't be able to understand if you just give a description. I just hope I am along the right tracks.
View 1 Replies
Mar 4, 2010
I have a base class with several derived classes. I want all of my derived classes to have the same Public Shared (static) method with their own implementation. How do I do this? Is it even possible?
View 3 Replies
May 8, 2012
[code]...
Dim ass as Assembly = Assembly.LoadFile("sample.dll")
Now, I want to call the shared method using the class name.
View 1 Replies
Jul 31, 2010
use of the shared function, which returns a reference to a datatable to the calling code. While there a probably many debates as to the preferred use of ADO.NET objects, my question is about the Shared Method aspect. Note that the dataTable is declared within the Shared Function, so it seems to me you get a new one every time, yes?
Public Shared Function MyData() As DataTable
Dim ReturnData As New DataTable
'A silly example of retreiving some data into a datatable:
Using cn As New SqlClient.SqlConnection("SomeCOnnectionString")
[code]....
View 4 Replies
May 9, 2012
In my program I use WebBrowser control for OAuth. It's located on vk_auth_window form. So in the code I call vk_auth_window.WebBrowser1.Navigate(vkauthurl). If authentication is successful, I silently get token, but if user is not authenticated a form vk_auth_window is showed to them to enter username and password. To check this I catch _DocumentComplete event and check for the right URL. I need no other code being executed until the user finished authentication or closed authentication form. ShowDialog() does the trick, but it somehow hides cursor from username and password fields in WebBrowser control. So I introduced a variable Dim showform as Boolean=True in and set it to False from the _DocumenComplete event and in the main code I use infinite loop.
While showform
System.Threading.Thread.Sleep(100)
Application.DoEvents()
End While
However it makes userinput slow due to thread sleeps. And If i remove them, it loads CPU quite a lot. Is there a better way to wait for form to close? What is it?
View 1 Replies
Sep 10, 2010
So you know how when you call "Form.ShowDialog" from where ever you call it, it blocks until the form being displayed closes. And then the function returns whatever result it was.I want to know how to block like, but without a form, yet still have the "main ui thread".Basically I have this long process that needs to thread out and do several things... and it's heavily event based. It jumps between two threads, the main ui thread, and it's own background thread. The main ui thread needs to have access so that I can randomly open different dialog boxes for things... sometimes they're just windows asking to hit OK or Cancel to continue, others it's to perform some action, etc etc.
But there is NO central form related to it. It's a complete background thread running that randomly hops over to the main ui thread for things.Right now I have this class I designed called lets say "DoJobProcessor". On it is a function called "BeginDoJob" that threads off from the thread pool... when ever I need to jump back I use a ManualResetEvent to block on the background thread, jump over to to the main thread with "invoke" and passing a reference to the MRE, then release the block when done there and continue on on this background thread.
All while this is going on I just set the form I'm trying to block the main ui thread from managing by just setting its Enabled property false.It all feels just messy and annoying... and I was just writing something using ShowDialog and I was like... HEY, what if I could block this BeginDoJob method, hi-jack the main ui thread, then let that function return the result when done instead of having this "Complete" event with the return value in it. It's obviously possible because ShowDialog does it, but I don't know how.
This way the job I'm performing isn't always waiting for the main ui thread, instead its the other way around... the ui thread waiting for it, the way it aught to be. Show something, branch off do some stuff and just idle the display while it does it, come back show something else, branch off and just idle while it does that.
View 6 Replies
Jun 21, 2010
I have a form that is called w/ ShowDialog. Inside that form, I want to pop a message box to ask the user a question, but it doesn't show.[code]
View 2 Replies
May 17, 2009
I have problems with a form and load event.My form manage items that can be added, deleted or modified. In load code, I initialize all vars to cero. This is OK to be ready to add items.
My problem is with modify and delete. To carry this, I must load vars from a source. So, in my foreing code I have this:
[Code]...
My problem is that when showdialog is called, all data which were loaded from duplicar funct is put again to cero. How can I avoid this and load correct data into the form.
View 2 Replies
Feb 24, 2009
I am writing an application in VB2008 with several forms. From Form1 I open a new form with me.hide() and then form2.showdialog(). The system works but in form2 the application runs without screendisplay until the program waits for a user input. So first all databases are processed. Meanwhile no screen is visible for the user. Sometimes this takes about 5 seconds. I would like the user to see the build up screen directly.
View 9 Replies
Feb 11, 2011
I want to open a form as modal without using showdialog()Problem with showdialog() is we can not open the form as mdi child with it. i want to open few forms as modal but as mdi child forms. but i want to make sure user cannot go anywhere else without closing thst form.if we set parent form enabled = false then i can not set it as mdi child otherwise that form also becomes enabled=false.
if we write showdialog() then so many form icons will appear on taskbar. it we open as mdi child then only one icon appear i don't want to appear so many icons on taskbar so i want to open as mdi child but as modal
for eg. Mainform = mdi form
from mainform open formA = as mdi child of main form (but modal)
from formA open formB as child (modal)
from formB open formC as child (modal). if i use showdialog() then so many form icons on taskbar.
h2007
View 4 Replies
Mar 7, 2009
im running this code to load a form and call a public method inside it:
vb
[b] newForm.Show()[/b]
Call newForm.editToolStripButton_Click(sender, e)
but when i use form SHOWDIALOG method it doesnt execute
Call newForm.editToolStripButton_Click(sender, e)
View 11 Replies
Aug 27, 2010
Is it possible to prohibit an instance of a class from calling a shared/static method?
For example:
I want to allow this:
ClassName.MethodOne()
But I want to disallow this:
Dim A As New ClassName
A.MethodOne()
The reason this is desirable is that in this case it is semantically confusing if an instance can call the method.
View 2 Replies
Nov 21, 2010
There is a popup window which is rendered using xslt (no aspx page) on click of button, during this window load and close events I need to manipulate the text exist in the textarea of popup window. Having said I need to store the list words (key,value) for validation and spell check so I just declared a dictionary/hashtable object in common class (globals.vb) where i could store (add and retain values until I click close window, there could be couple of in turn calls to other methods of popup window) and manipulate as expected but whenever I reset the dictionary/hashtable (objDic.clear()) on popup load and close, it resets the concurrent users dictionary also.
Note :
1.Dictionary is declared as Public in Public Module (Globals.vb).
2.Dictionary manipulation happens inside the shared method (that is in turn calls to shared method of popup events).
View 3 Replies
Oct 8, 2010
Can we override a Public Shared method in derived class? If not why?
View 2 Replies