|
I have created a MDI application with many forms and created a few custom controls that are needed for the data. They are extended off of UserControls, most are composite controls, but not all.
When a user is on Form1, and a "Standard" text box has focus, the users switches to Form2 to check something, then back to Form1, The "Standard" text box still has focus when they return.
When using my "Custom" text box,(a UserControl with a text box droped on to it in the Designer) when the Custom text box has focus, when the user switches to the other form, and then back, some other field (usually lowest tabindex) ends up with the focus.
How do I setup my UserControl so that focus ends up back in it when our form looses and regains focus.
I have a skeleton program with the same error with none of my custom code in it that I can upload or email to you if it helps.
Its most likely something stupid, but I cant find it.
|
|
|
|
|
The problem is that when the user switches away from the initial form, the first event to fire will be that the form has gotten focus, after which the form will automatically move focus to the control with the lowest tab number, or to the control that you explicitly tell it to. So if the last control to have focus should always get the focus back, you need to monitor which control (for example your textbox) has focus at any time (for example by its index or tab number).
Then you can just set focus to that control when focus is brought back to the form.
In other words, the problem hasn't anything to do with your usercontrol.
My advice is free, and you may get what you paid for.
|
|
|
|
|
I agree that that is what is happening with my usercontrols, But when the focus starts out in a standard text box, that is not what is occurring. In the standard text boxes (or any other windows "standard" controls). when returning to the first form, the focus returns to where it was when we left the form automatically.
For example, a form with three controls, two textboxes, TabIndex 1 and 3, and my UserControl tab index 2
Tab Index 1 -> Jump off and return -> Tab Index 1 (as expected)
Tab Index 2 -> Jump off and return -> Tab Index 1 (the questionable one)
Tab Index 3 -> Jump off and return -> Tab Index 3 (doing what I want my control to do)
Also I have tried code to monitor what the last selected control was, and to reset it using OnEnter and OnLeave functions, but Even though it was doing LastControl.Focus() on the correct LastControl the focus was still ending up back at TabIndex 0 as if something else in the application was forcing it to go there for some reason. But even with every other reference to "Focus" in my code commented out, it still kept going back to 0. (Also in my basic test case that I created with out any other code in it, just standard controls and the absolutely fewest lines of code to make the forms show up.
Does anyone have an example of tracking the last control used? I could easily be doing something wrong, but with the time I have spent on this, I don't think so.
|
|
|
|
|
For those people looking through the archives and finding this. I ended up changing my UserControls into Panels. It comes with its own issues. But seems to have "fixed" the listed problem.
|
|
|
|
|
can anyone point me in a good direction. I am upgrading an old VB6 app. There are two primary forms. If I hide a form, then unhide it, it seems to change size. Any idea why this is or how I can stop it? (I generally show only one of the two forms at a time)
I do have a way to determine what size it needs to be but am not sure where to put my re-sizing routine (the form needs to be different sizes for different configurations) It is generally resized on the load event.
Thanks in advance
sorry, upgrading a VB6 app to .net, did not have issue in VB6
|
|
|
|
|
No-e wrote: If I hide a form, then unhide it, it seems to change size. Any idea why this is or how I can stop it? (I generally show only one of the two forms at a time)
Your best way to do this is to write both forms as controls, and then show/hide those on the same form. Having said that, there's no reason for yuor form to resize, you should post some code.
No-e wrote: I do have a way to determine what size it needs to be but am not sure where to put my re-sizing routine (the form needs to be different sizes for different configurations) It is generally resized on the load event.
I assume this means your load event is firing every time, have you tried breakpoints ? Does it need to be resized regularly, or only on startup ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Thanks for your response, if I might take a step back it may help as I also see this screen resizing when the form loads.
Private Sub frmChamber_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
frmChamber.DefInstance.Height = frachamber(0).Height + 214
If frmChamber.DefInstance.Height < fraControl.Height + 200 Then frmChamber.DefInstance.Height = fraControl.Height + 214
end sub
when this code runs, my height will be 645 in this case. It is very clear.
the code then returns to the
public sub new() routine and does a me.show(). Note this code was inserted by the update tool,I have not changed it, copied exactly as is)
Public Sub New()
MyBase.New()
If m_vb6FormDefInstance Is Nothing Then
If m_InitializingDefInstance Then
m_vb6FormDefInstance = Me
Else
Try
'For the start-up form, the first instance created is the default instance.
If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
m_vb6FormDefInstance = Me
End If
Catch
End Try
End If
End If
'This call is required by the Windows Form Designer.
InitializeComponent()
'This form is an MDI child.
'This code simulates the VB6
' functionality of automatically
' loading and showing an MDI
' child's parent.
Me.MdiParent = MBIG.mdiMain.DefInstance.DefInstance
MBIG.mdiMain.DefInstance.DefInstance.Show()
'The MDI form in the VB6 project had its
'AutoShowChildren property set to True
'To simulate the VB6 behavior, we need to
'automatically Show the form whenever it
'is loaded. If you do not want this behavior
'then delete the following line of code
'UPGRADE_NOTE: Remove the next line of code to stop form from automatically showing. Click for more: 'ms-help:
Me.Show()
End Sub
The form will then show on screen but will be much shorter than it was when I set it. I can re-size it again from the calling routine, but I am not sure why it would change.
Thanks for your help, I am hoping I am just not understanding how this works.
Mike
|
|
|
|
|
I had a similar issue with minimizing. When minimized and then unminimized it changed it's width to a very small number. You can stop this from happening by putting code in the activate event and setting the minimiumsize property.
Example:
If _SizeAtLoad = -1 Then 'don't want to do this everytime it activates, just first time
_SizeAtLoad = Me.Width
'* Changed to avoid "repaint" flicker and bounce
Dim MinWidth As Integer = _SizeAtLoad '* default to width when form opens (backward compat. behavior)
Dim MinHeight As Integer = 300 '* default to 300
If Me.MinimumSize.Width > 0 Then
MinWidth = Me.MinimumSize.Width
End If
If Me.MinimumSize.Height > 0 Then
MinHeight = Me.MinimumSize.Height
End If
Me.MinimumSize = New System.Drawing.Size(MinWidth, MinHeight)
End If
Hope this helps...
Nathan
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
modified on Thursday, June 11, 2009 9:36 AM
|
|
|
|
|
Thanks, glad to see I am not the only one I also found the visible changed event and put my resizing there. Kind of strange, would like to understand it better but will need to move on now....
|
|
|
|
|
Hi,
I am trying to print a pdf using the printdocument and printdialog by passing a file name using the opendialog. This is my code
im c1 As OpenFileDialog = New OpenFileDialog
c1.InitialDirectory = "c:\"
c1.Filter = "PDF Files (*.pdf)|*.pdf"
If (c1.ShowDialog() = DialogResult.OK) Then
lblFileName.Text = c1.FileName
file = lblFileName.Text
End If
PrintDocument1.DocumentName = file
PrintDialog1.ShowDialog()
PrintDocument1.Print()
Anytime I try this it does not print anything.
Can anyone help please
|
|
|
|
|
There is no PDF support in .NET. You need to buy a third party library for that. The print dialog DocumentName in general, does not magically print a document for you in any case. You need to impliment printing in all cases. Perhaps you should try reading some documentation ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
I recently upgraded a project that did a lot of screen manipulation. Controls (hundreds in different configurations were loaded, aligned and displayed using the ".left" and ".top" commands on the control.
In many places there were alignments done based on other things and an offset, for example,
frachamber(0).Width = ((ID_WIDTH * 2) + (SLOT_WIDTH * 2) + 400)
after the upgrade I get
frachamber(0).Width = VB6.TwipsToPixelsX((ID_WIDTH * 2) + (SLOT_WIDTH * 2) + 400)
I would like to simplify and get rid of the twipstopixels and just go with pixels but am not sure how to convert my offset values (400 in this case) It looks like someone spent a lot of time figuring out all these offsets in the past, something I would like to avoid if possible.
any idea how to convert, say 100 twips is about this many pixels? (I guess they would be needed in both X and Y). In debug mode it will not tell you what the converted value is in pixels.
Thanks
sorry, upgrade from vb6 to .net
|
|
|
|
|
Hi,
a simple google action turned up this article[^].
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
hello everyone ..
well i have a form contains DataGridView and one of its components is a ComboBox , the problem is i wana save the ValueMember instead of the DisplayMember in the database .
BS: i am using sql 2005 and vb.net 2005
here the sample .
http://www.4shared.com/file/110589646/9b033db6/WindowsApplication2.html
|
|
|
|
|
atk8877 wrote: the problem is i wana save the ValueMember instead of the DisplayMember in the database .
That is how it is supposed to work. Is it not doing that?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
You write the code to store in the DB, so what is the problem ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
|
I have a task that i have to synchronize/update both my web(asp.net & SQL 2005) and windows application databases(VB.net & SQL 2005).
My scenario is my web app. and windows app. both accept reservations. I want any reservation happen to my web or windows app will reflect to both databases(online & local) at the same time.
Please help me.
Thanks.
al hajjaj
|
|
|
|
|
I would look at using SQL Server replication or if that is not possible, writing INSERT, UPDATE and DELETE triggers for each of the tables that need syncronising. Better still why not use the same database for both apps?
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
Like Steven said, best is to use a single database for both. In fact, it is useless to build a separate windows form. Just make a separate section in your web app with login for administrators / employees, and build the form there.
Using xml could be an alternative approach. Handle web reservations as orders, and have your web app send the necessary information for the reservation in an xml file.
Vice versa, you can send data about existing reservations / open capacity in xml files to your web server.
Obviously this approach would not nearly be as real-time, so you would have to figure out a rule about how to handle double reservations. For example an approval queue.
My advice is free, and you may get what you paid for.
modified on Wednesday, June 10, 2009 6:32 AM
|
|
|
|
|
|
Single database will do and write a webservice which handles database layer and business logic layer. Webservice can be called from web and windows applcation. So even if you change the presentation layer (web or windows) you can do that.
|
|
|
|
|
How to populate the column header to all records. I am using Vb.net 2005.
Any body help me? It is urgent. Please!!
Example: (In Microsoft Access Database)
Header-- Name Designation Salary
Gopi Jr. Programmer 10,000
Mani Sr. Analysist 10,000
Kamal Database Admin 25,000
Need the Output: ( I Need the output to Notepad )
Name: Gopi
Designation: Jr.Programmer
Salary: 10,0000
---------------------------------
Name: Mani
Designation: Sr. Analysist
Salary: 10,000
---------------------------------
Name: Kamal
Designation: Database Admin
Salary: 25,000
----------------------------------
Please sent the code to my mail id. it is very help full for me.
E-Mail: agopi_2005_ind@yahoo.co.in, agopi.net@gmail.com
Regards,
Gopi A.
|
|
|
|
|
Member 4027617 wrote: Please sent the code to my mail id. it is very help full for me.
E-Mail: agopi_2005_ind@yahoo.co.in, agopi.net@gmail.com
Wow - you're really a bit stupid, aren't you ? That's two email addresses that will get spammed by spam bots now.
Member 4027617 wrote: Need the Output: ( I Need the output to Notepad )
Member 4027617 wrote: It is urgent.
Seeing as you can't do your own job, perhaps you need to pay someone to do it for you ? I mean, we're here to help, not to do your job. What have you tried ? Anything ? Did you google it ? Do you have any idea what you're doing ?
You have asked two questions.
1 - output to notepad. I assume you mean output to a text file ? File.WriteAllText will do that. Process.Start will open the file in notepad.
2 - formatting your data. Your best bet here may well be to read your data, then iterate over it and build the format you want, given that you have to build it into a string to save it in the first place.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi,
I need help. if you know this please post the code. No need the comments. Do you know what i am doing? why i am asking this for urgent? Don't insult any other like this. Really I am working in BPO Concern. Just i develop the tool for our work. I will help us and reduce the time. We have take more hours for this output (Manual work). If you know this please help me.
Don't Mistake me. Please help me.. Please..
|
|
|
|