Forms :: Show Form Random Location?
May 26, 2009im working on a little project and i need my form1 to basically spam itself in random locations...
View 5 Repliesim working on a little project and i need my form1 to basically spam itself in random locations...
View 5 RepliesI'm trying to make a Form pop up at an random place (given in a textbox). Here is my code so far:
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Form2.Location = Textbox1.text
Form2.Visible = True End Sub
Yes i know it doesn't work. What I really need to know is how to make the txt understandable for the system.drawing.point.
I am practicing using the drawing commands, and have gotten a grass background and black happy face that moves around the background.It's a 10x10 grid of 50 pixels.I want (at the moment, when i press enter) it to generate a random number of trees (15 ~ 25) at random locations on the background. The program doesn't freak out about anything, and the variables seem to be right (using stop commands) but it's not drawing anything. Here is the code for the "GenerateTrees" command I have for when I press enter.
Private Sub GenerateTrees()
NumberOfTrees = Int(Rnd() * 10) + 15
For i = 0 To NumberOfTrees - 1
bmap.MakeTransparent(Color.Fuchsia)
[code].....
I have a button on my form. When I click it, I want a form to be opened exactly on the location where the button is.
View 1 RepliesI have been searching for a solution to this but I can't find one. I have played with the anchor and dock properties but they are not doing what I want, so here goes... I would like to place and size all of my controls on my form and then when the form is re-sized during run time (different resolutions, full screen/windowed, etc), have everything just scale up or down accordingly. Anchoring the controls to all four sides of my form re-sizes the control properly but it doesn't move it's location in sync with the other control's size next to it, they begin to overlap each other. Am I going to have to code my own scaling code for each control in my program?
View 5 RepliesI have a program that uses two forms. The program opens to the Main form, and the user can navigate to the other form from the Main form through use of a button. Here's the way I've currently written it: When the Main form loads, it declares and instantiates the other form during the load procedure. When the user presses a button, the second form is displayed by means of the ShowDialog method. On the second form, there is a Return to Main Screen button which closes the second form, bringing the user back to the Main form.
So, here's the structure of the code:
Code:
Public Class frmMainForm
Dim frmSecondForm As New SecondForm
Private Sub btnSecondForm_Click(blah, blah, blah) Handles blah, blah, blah
[CODE]...
Here's my reasoning: Originally, I wrote the code so that a new instance of the second form was created every time the button was pressed. The problem was that whatever data was displayed on the second form, previously, was lost when the user returned to it a second time. Since the user would be switching back and forth between these forms, frequently, I needed that data to persist.
What is the best practice for accomplishing this:
1) Declare and instantiate the second form on program start, as I have done, and use the button simply to show the form?
2) Declare and instantiate the second form each time the button is pressed but maintain the variables on the Main form and pass them ByRef to a custom constructor for the second form? Is this even possible?
3) Something else?
i am using an unbound datagridview so i can dynamiclly add rows. all that is working fine. but the grid is not is the location i have coded.. i am using the defualt form as a base then coding the unbound stuff in.. should i just create a blank class file and do everything? the only problem i am having is the grid must bees in the correct location according to the pixel point that i have given it. Right now it is placing the grid at point (0,0) no matter what point is entered on the line for location. so what am i missing??????
View 3 RepliesI have a class that inherits the UserControl class, the class creates its own graphics such as a title bar and what not. Is it possible to show this class as a form/it's own window?
Public Class CustomForm
Inherits System.Windows.Forms.UserControl
'create new instance, assign/declare vars here, blah blah
[Code]....
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
[Code]....
The end result is baffling me here are 2 examples when I debug
Mine: 640.1 * 49 = 31364.9
Debugger: 640.1 * 49 = 31360 ( not right needs to show the correct decimal )
Mine: .775 * 3 = 2.325
Debugger: .775 * 3 = 2.325 ( shows it perfectly???)
i have uploaded 3 pics shows 3 diff forms.
1. BaseForm.( Includes 2 button, Buttons Text "Form1" and "Form2")
2. Form1. (Just inherited BaseForm)
3. Form2. (Just inherited BaseForm)
If the Button Form1 clicked then it shows Form1 disable Form1 button. and Hide BaseForm. same action for Button Form1.
When I click the Right Top Cross button then the Background BaseForm Still running. I want to close all form If I click cross.
I have a simple login field, which works fine with the exception of one quirk. The form is set up with the tab order to go to the UserID first and the Password text box second. This works fine when the form is used the first time, but when the form is used the second time the focus in placed in the Password field. If the form is used a third time, focus is moved the OK button, that is each time moves to the next tab order. I even tried to set the focus in the Load event as in Me.txtUserID.Focus(), but this doesn't change the behavior. Again, I should note that I close the form and not hide the form.
View 3 RepliesI want to load a picturebox and it gets a random location on the screen.How do I do that?
View 3 RepliesI have been working on a quite complex multiform solution.All of a sudden the start up form (in fact any form I designate to start up) loads, displays and operates fine.
But when I try and show a form using showdialog the form displays behind the original form and I can�t set focus to the ide to close it down. I have to use task manager or alt f4 while the form has the focus.
Calling different forms from this one gives the same result but other forms work fine. I don�t want to redo this form as Ive done a lot of work onit.The only thing I can think of that whist I was changing the startup form in the project propertied page (file>project>properties) I unchecked the �Enable applications framework checkbox.
I'm trying to make this game, where the button moves to a random location everytime your mouse gets near it.How would i do it?
View 3 RepliesI am a grade 11 student in high school and am struggling with a project in my computer programing class. in the project we are to create a mario game, where you have 2 pictureboxes (the player and the enemy) one picturebox, the player, is moved using the keypad, the goomba isn't moved at all. the object of the game is to 'kill' as many goombas as quick as possible. I need to make the game so that if the boundries of the player intersect witht he boundries of the goomba, the goomba will move to a random location.
I can't get the goomba to move to a random location, here is my code. I highlited and bolded the part of the code that I am having the prolem with.
Public Class FrmQ4
Dim intLocation As Integer
Dim intCounter As Integer
[Code].....
I have a picture box and I tell it to appear on a random location on another specified larger picture box.
here's my code:
Code:
Sub P2_AppleMove()
Dim P2ax As Integer = CInt(Int((P2Foodarea.Width * Rnd()))) ' sets the random area of the food
[Code]....
P2foodarea is a large picture box I created. I only want the apple to spawn on P2Foodarea, atm, it spawns on P1Foodarea which is very weird. P1foodarea is a whole other picture box. I even made new variables as you can see P2ax and P2ay, but it still doesn't spawn on P2Foodarea. I have even tried recreating a new picture box for P2foodarea
how to hide and show listbox in specified location? on a form in visual basic 2010
View 6 RepliesI'm working on my graduation project and within it i need a function gives me random dates since 2008,01,01 untill now. I want the dates to show up random not sequential.. how can I do this ????
View 1 RepliesI am writing a program that shows random images in three picture boxes. When I open the program the initial images are in the picture boxes. When I click stop, the program is supposed to select a random image out of five. in each picture box. However, when I click start the images go away and when I click stop, no images appear. There is also a message that is supposed to come up on the screen, which it does. I just can't get the images to show. I am using Visual Basic 2005.
My code is below:
Public
Class videoBonanzaForm
Private images() = {image1, image2, image3, image4, image5}
Private image1 As Image = Image.FromFile("sevenpounds.gif")
Private image2 As Image = Image.FromFile("push.gif")
[Code] ......
I have a simple GUI form to hide / show / minimize / terminate / force terminate Processes. i can do all well but for show and hide i need the MainWindowHandle to show or hide it
So here is hide process code:
Dim Proc As New Process = Process.GetProcessesById(List.SelectedRows(0).Cells(1))
Dim hwnd = Proc.MainWindowHandle
ShowWindow(hwnd,0)
If i try the same with show code:
Dim Proc As New Process = Process.GetProcessesById(List.SelectedRows(0).Cells(1))
Dim hwnd = Proc.MainWindowHandle
ShowWindow(hwnd,9)
The MainWindowHandle become 0 cuz its hidden is there is any other way to get the MainWindowHandle of Process ?
I'm working on a simple base form in which all the other forms in the project will inherit. This base form only adds 5 properties (at the moment) dealing with painting a gradient background. The problem I'm facing right now is when I change a property on Form1 (the test form) and click run it doesn't show that change. I also checked the .designer.vb file and when I make a change it's not added to the code behind file, I'm at a loss right now to why.
[Code]...
How to control the location where the OpenFileDialog.Show places the interface on the screen?
View 1 RepliesI am not so good at VB.NET, well, I am working with a school to run a Spelling Bee aimed at children in year 7. And to make it fair and unbiased i need an application that can choose randomise a word from the list box then transfer the string to the text box. So basically something that can pick a random string from the listbox and show it in the textbox1.text property.
View 4 RepliesBasically what I am making is a form with just one button and 2 text boxes. The purpose of it is that when I click the button 2 random PRIME numbers between 100-999 will show up in the boxes. With my code I have now, the numbers that show up in the boxes aren't always Prime.
My current Code is.......
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Randomize()
Dim p, q, i, j As Integer
[Code] .....
i follow this script Quote:
[Code]...
When a press a button. a random text will show in a label. -
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Randomize(Label1.Text)
[code].....
I have a project in vb.net (2008) .net 3.5 in which I have a mainform (Not a MdiParent) and I created another form I want to use as a tip form. I'm trying to set the tip forms location to the lower right of the mainform no matter what the size of the mainform's height and width.
I tried this :
TipForm.Location = New Point(Me.Width - TipForm.Width, Me.Height - Me.RibbonControl.Height - Me.statusbar.Height * 1.5 - TipForm.Height)
I have an app with 4 buttons that each generate a random number into textbox, before this number is entered i would like to have a progress bar at the bottom, well show that its processing basically.
View 4 RepliesI am developing a windows app in VS2008 to be used along side ESRI�s ArcMap. Most ArcMap users will have dual monitors and I would like the user to be able to choose which monitor my app is loaded on to.
When I deploy the app using the standard install package, the app will load onto which ever monitor the user places the desktop shortcut. However, when using the ClickOnce method of deployment, the placement of the shortcut does not matter and the app always loads on the primary display monitor.
Is there a way to control where an app is loaded by code or any other method?
i want the panel to center itself evertime i change the size of the window. how do i do it? panel1.location.x=form1.location.x doesent work.
View 1 Replies