473,394 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Form.Show() Error

13
Hi All,

If I type this code (VB.net 2003):

Expand|Select|Wrap|Line Numbers
  1. Dim myDialog As frmTestDialog
  2.  
  3. myDialog = New frmTestDialog
  4.  
  5. myDialog.Show()
you'd expect some dialog window to appear in a non-modal state. For some reason, this isn't the case with a program I am working on. Most of the dialogs use ShowDialog() to open them, and one uses Show(). The second I try to show another non-modal dialog, the dialog appears in a modal state. Another strange thing is, before I show the dialog, there is code to shift the dialog location to centre it on the main form - this isn't executed either: the dialog appears at 0,0.

My usual trend is to blame myself for errors (usually the case), then I blame the software; I have checked every single line of code (including the generated code), and it all checks out - the dialog should be non-modal. But ... it's not. I've come across other errors in VB.net 2003; is this another instance?

I'll try creating a new dialog and displaying this non-modal, and see what happens. If it works, I can just transplant the code ... but ... this shouldn't be happening, just like if I go to a shop, ask for a cola, I expect a cola not a Chinese panda; more annoying, I return the panda, ask for a cola, and they give me the panda back ... do loop until I give up ...

The system does using threading, but none of that code connects to the display dialog routines - all dialogs are opened with more-or-less the above code (a few have simple validation routines).

Any help would be appreciated here. I've been coding with VB.net solidly for years, and I've never encountered this before.
Apr 19 '09 #1
5 3580
Enij
13
Yep, for some reason when I add a new form to the solution, try to show it as non-modal, it appears in a non-modal state...

Okay, hold the phone ... as part of the validation routine that precedes the dialog.Show(), a ListView control is tested for an item count > 0 -- this listview is part of a threaded routine. The second I comment all the listview code, the dialog shows in a non-modal state (and the dialog is centred on the main form). It's like any connection whatsoever to the listview control is making the dialog become modal (the validation pseudo-code is: check listview for 0 items / if > 0, iterate listview items, creating a comma-delimited string based on listview item text / place the string in the dialog's tag / show dialog non-modal). By adding this string to the dialog tag property, the dialog becomes modal ...

This happens regardless to the String's scope.

I can work around this, but I would love to know what is going on here.
Apr 19 '09 #2
Enij
13
Wrote quite a few workarounds, even tried a 'cheat' by creating a dialog in thread, and they all failed.

I'm fairly positive this is a threading issue now. It is strange that my first non-modal dialog works perfectly.

I have a collection of routines that are run in a separate thread, which access the aforementioned listview control - directly access it, no invoking to the main UI thread, or anything like that (there are some visual glitches that happen when this is done, but by refreshing the control, the glitches vanish). I have a feeling this tardiness of mine is responsible for the error(s).

I did once invoke to the main UI thread, as there is some old code still commented on the system; not sure why I reverted the code. I'll run through my notes, and retry the invoking technique, see if this cures the problem...
Apr 19 '09 #3
Enij
13
Okay ... I'm at a dead-end here.

Tried using a delegate and invoking to the main UI thread, which failed, as in everything went smoothly, but the dialog is still modal and in the upper-left corner.

To see if this is a threading issue, I removed all the threading code and called the routine directly. The UI hung as I expected it to, the routine completed, showing results in the listview control, but ... still the dialog opens as modal, and it's in the upper-left corner. So, now I don't think it is a threading issue.

Before I start this routine, the dialog opens normally. It is after the routine has been called and ends, that is when the dialog goes nuts.

I've exhausted my VB.net knowledge, and I can't find anything with Google that mentions this type of error. I am loathed to blame VB.net; this is most likely something I've done, but I cannot find what it is.

Move on a few minutes into new tests ...

Now this is where things get a little strange. To see if the problem lay with something in the dialog code, I created a new, empty dialog, and hooked it up to display on a button click, commenting the old code out. In my understanding of the universe, when the button is clicked, the new dialog would appear, and for every click, a new dialog. This is what happened.

Then I ran my listview control routine. The routine completes, and ... this doesn't make any sense. Code that had been commented out is running -- I click the button to load the new, empty dialog, and the old dialog appears (modal, upper-left corner).

When I worked as a computer engineer, I saw errors (crazy errors) like this when the computer's memory modules were corrupted (one minute a DVD-ROM would read 50 files, then next, it'd read 23 files, etc).

Anyway, I'm out of ideas. Any help here would be great.
Apr 19 '09 #4
Plater
7,872 Expert 4TB
As for your latest problem:
If you set breakpoints and run in debug, do your breakpoint circles become empty red circle (instead of filled in ones)?
It sort of sounds like something is happening at compile time, like maybe something is not being cleaned/built correctly?
I've had it happen where I didn't pay close enough attention to the build output to see things like "project not selected for build" (vs went crazy and took all of my projects out of the build list) and couldn't figure out why my code wasn't running.
Apr 20 '09 #5
Enij
13
Hi Plater,

Thanks for your quick reply. Things are a tad strange at this end.

My build list is good -- everything is where it should be. I deleted all the .exes, .pdbs, Release and Debug folders, letting VB recreate them - the error still happens.

Then, I tried your breakpoints idea, and regardless of what I did or where the breakpoints were set, they were never triggered. Then, I thought maybe another routine had accidentally been told to handle the control's click event (I'm using a label control to act as a button), but the routine handling the click was the only one.

Then, I commented out the entire click event code, ran the application, and the dialog still appeared in its modal state (X-Files eat your heart out!!) ... there's no code to do anything, yet something happens... Dumbfounded, I placed a button control on the form and rigged it to show the dialog, and it works -- the dialog is being shown as non-modal, doing everything the code tells it to.

My computer's hard-disk started making some strange, whining noises a few days back (it is 6 years old after all), so I ran the usual checks on all system elements, and they all came back clean. But, just on the off-chance, I put the VB solution on to my new laptop, ran the application, and the same fault happens, letting my old machine and the VB installation off the hook.

Label controls have a click event, so I'm assuming it's fine to use them as buttons (I use label controls as simple, flat menu icons). Though, saying that, I have bundle of 24x24 labels acting as buttons, and they're all doing their job nicely.

My breakpoints are displayed as solid red circles.

I'll try creating another label control, configure it as the other, and transplant the code across, see what happens ...

EDIT: (after the above test)

Deleted the old label control, created a new one, and hooked it up to show a dialog in a non-modal state ...

It works ... it ... WORKS!!!!!! ha hahahahahhahahaaaaa!!!

... ahem ...

Guess the solution was obvious -- if a control stops working correctly, delete it and replace it, before going over-board, tearing your application apart, searching for a problem that isn't there.

I've been meaning to have a look at the express edition of VB2008, perhaps it's time I did. Does anybody know if VB2008 can be purchased alone, or if it is only available as part of Visual Studio 2008?
Apr 22 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Norman Bird | last post by:
I have a form i will use to register new people and when I click the submit button, the form just shows itself. It is supposed to show a message showing field errors if you leave fields blank etc....
13
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide...
4
by: Ahmet | last post by:
Hi all; I have one application in which I read form names from database to be opened. I open form with the code below, and call its show method for form to be shown but before this, I must set...
6
by: Shane Saunders | last post by:
I have a menu option that loads a form and displays infomation. if you go to main form and try to load something else from that same menu, it does a check to see if the form in exist and then...
5
by: ortaias | last post by:
I have a form which calls up a second form for purposes of data entry. When closing the data entry form and returning to the main form, things don't work as expected. When I return to the main...
20
by: vitorjol | last post by:
Hello. I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from form2, i get the error "object reference not set to an instance of an object" ! What can i do to solve the...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
9
by: timnels | last post by:
I have an issue where I have a user control that is launched into a floating form. At some point later, I allow the user to "unfloat" the user control by reparenting it on a split container in...
10
by: sara | last post by:
Hi - I have been struggling with solution ideas for this now for almost 2 weeks, and have not been able to figure this out. I have a user who creates a Purchase Order (tblPOData). In some...
4
by: zufie | last post by:
I have a main form containing a command SEND button that prompts an email form to pop up. The email address(es) that are supposed to appear on the email form are those corresponding to the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.