How to save form size?

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

43 Replies - 2761 Views - Last Post: 24 August 2012 - 06:48 AM Rate Topic: *---- 1 Votes

#16 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 23 August 2012 - 11:49 AM

View Postmodi123_1, on 23 August 2012 - 11:46 AM, said:

The property is pretty immaterial. It's a number.

If you just want to know about the form as it runs then sure.. a shared object or class that holds the size for each form will do.


Yes, but as noticed in the first post, I'm having problems with Public Shared...
Was This Post Helpful? 0
  • +
  • -

#17 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8379
  • View blog
  • Posts: 31,147
  • Joined: 12-June 08

Re: How to save form size?

Posted 23 August 2012 - 11:52 AM

First off, avoid using commonly used words. Height and Width? Yeah those are properties on a form.

Next, make a shared class file and put their declaration in there.

After that - I don't know. You didn't specify a problem.. just that you were looking for the code for your problem.
Was This Post Helpful? 0
  • +
  • -

#18 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 23 August 2012 - 12:14 PM

View Postmodi123_1, on 23 August 2012 - 11:52 AM, said:

First off, avoid using commonly used words. Height and Width? Yeah those are properties on a form.

Next, make a shared class file and put their declaration in there.

After that - I don't know. You didn't specify a problem.. just that you were looking for the code for your problem.


About height and width: I'm just using normal names for the forum to understand it easier (which I do not use in the project)...

Tried it but doesn't solve the problem...

Anyway; Thanks.
Was This Post Helpful? 0
  • +
  • -

#19 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8379
  • View blog
  • Posts: 31,147
  • Joined: 12-June 08

Re: How to save form size?

Posted 23 August 2012 - 12:17 PM

Tried.. *WHAT*?

I actually created a quick project.. threw in three forms.. one shared class holding a variable for the size of each form... on each form load it checked the correct shared class variable.. and it worked.. for each one.. and on close saved the size.
Was This Post Helpful? 0
  • +
  • -

#20 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 23 August 2012 - 12:20 PM

View Postmodi123_1, on 23 August 2012 - 11:52 AM, said:

Next, make a shared class file and put their declaration in there.


Damm, look at your post...

Could you post it?

This post has been edited by Whazabazaa: 23 August 2012 - 12:22 PM

Was This Post Helpful? 0
  • +
  • -

#21 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8379
  • View blog
  • Posts: 31,147
  • Joined: 12-June 08

Re: How to save form size?

Posted 23 August 2012 - 12:24 PM

Quote

Damm, look at your post...

What about my post?


Quote

Could you post it?

No.. I won't post it. It's as complex as adding a new class to your project.. making it shared.. adding shared variables.. and call those variables.
Was This Post Helpful? 0
  • +
  • -

#22 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 23 August 2012 - 12:59 PM

View Postmodi123_1, on 23 August 2012 - 12:24 PM, said:

Quote

Could you post it?

No.. I won't post it. It's as complex as adding a new class to your project.. making it shared.. adding shared variables.. and call those variables.


I've got this but it doesn't work, btw I'm new with calling things public:

Public Class Form2
    Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Dim A As New SizesForms

        A.HeightFORM = Me.Size.Height
        A.WidthFORM = Me.Size.Width
    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim A As New SizesForms
        Me.Size = New System.Drawing.Point(A.HeightFORM, A.WidthFORM)
    End Sub
End Class


The class created:
Public Class SizesForms
    Public HeightFORM As Double
    Public WidthFORM As Double
End Class

Was This Post Helpful? 0
  • +
  • -

#23 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 260
  • View blog
  • Posts: 1,419
  • Joined: 07-April 08

Re: How to save form size?

Posted 23 August 2012 - 01:17 PM

Ok so do this:

1. Create a class called FormDimention
2. Add properties for Form Name, Height, and Width
3. Create a List(or better would be an IEnumerable) of type FormDimention which is accessable by all forms
4. On the form closing event check that Collection to see if there is already an object for that form. If there is update the height/width. If not add a new FormDimention object to it for that form.
5. On the form load if there is an object in the Collection for that form load it, if not load defaults.
Was This Post Helpful? 0
  • +
  • -

#24 ToshNeox  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 100
  • Joined: 10-December 11

Re: How to save form size?

Posted 23 August 2012 - 01:19 PM

So, because there seems to be a real evil (in my opinion) rule about posting full code and doing 'your homework', I shall help you out a little here.

I'm also going to suggest you use My.Settings no matter what, as it will be the easiest for you.

In VB Express / VS / editor go to Project > <project> Properties

Then, go to settings, and create a setting for each form, with an easily recognizable name. I.e:

sizeForm1, sizeForm2, etc...


And make sure to set it's type to System.Drawing.Size.

Now, in your form's load event, use the following:
(Change Form1 to whatever your form is called)

Form1.Size = My.Settings.sizeForm1



Which when the form is opened, will automatically change the size to whatever is stored (remember to make sure you gave the settings a default value to assure that it won't cause an error).

Then, in your form's resize event, use the following:
(again, changing variables needed)

My.Settings.sizeForm1 = Form1.Size
My.Settings.Save() 'Saves them



Although you might not want to use them now, you'll see how easy My.Settings actually are to work with. It'll simplify everything, unless you still want to make your own function to intuitively load the sizes from an XML file and set each form's size.
Was This Post Helpful? 1
  • +
  • -

#25 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8379
  • View blog
  • Posts: 31,147
  • Joined: 12-June 08

Re: How to save form size?

Posted 23 August 2012 - 01:41 PM

Quote

So, because there seems to be a real evil (in my opinion) rule about posting full code and doing 'your homework', I shall help you out a little here.

It exists on the "give a man a fish/teach a man how to fish" principle. We want everyone to be as good of a developer they can be and just doing a free-for-all doing everyone's homework won't achieve that goal.

Quote

I've got this but it doesn't work

Here's another great learning opportunity - doesn't work.. *HOW*? Elaborate on errors you may be getting, error text, the line the errors are occurring, what the application is doing versus what it should be doing.
Was This Post Helpful? 0
  • +
  • -

#26 ToshNeox  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 100
  • Joined: 10-December 11

Re: How to save form size?

Posted 23 August 2012 - 02:07 PM

View Postmodi123_1, on 23 August 2012 - 01:41 PM, said:

Quote

So, because there seems to be a real evil (in my opinion) rule about posting full code and doing 'your homework', I shall help you out a little here.

It exists on the "give a man a fish/teach a man how to fish" principle. We want everyone to be as good of a developer they can be and just doing a free-for-all doing everyone's homework won't achieve that goal.

Quote

I've got this but it doesn't work

Here's another great learning opportunity - doesn't work.. *HOW*? Elaborate on errors you may be getting, error text, the line the errors are occurring, what the application is doing versus what it should be doing.


Hey hey, calm down :bigsmile:. We'll get to the problem soon I wager.

I know about the 'Gimme teh codez' thing, I was just making a point that I think it's enforced a little too harsh. It's kinda like "Don't give them ANY code", but you need to start everyone off with something. I know you'll say "that's for homework", but if you do, you don't get what I mean, so we'll leave it at that eh? :clown:
Was This Post Helpful? 0
  • +
  • -

#27 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 23 August 2012 - 02:11 PM

Thank you, I'll try it tomorrow...

View PostToshNeox, on 23 August 2012 - 01:19 PM, said:

So, because there seems to be a real evil (in my opinion) rule about posting full code and doing 'your homework', I shall help you out a little here.


I'm not a native English speaker: do you say you are making my 'homework'?
Was This Post Helpful? 0
  • +
  • -

#28 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8379
  • View blog
  • Posts: 31,147
  • Joined: 12-June 08

Re: How to save form size?

Posted 23 August 2012 - 02:26 PM

Quote

I was just making a point that I think it's enforced a little too harsh.

.. and I find instances where it is not enforced enough. Cest la vie. Can't win them all.

Quote

It's kinda like "Don't give them ANY code", but you need to start everyone off with something

(ir)Regardless of my personal pet peeve for the "o n0ez, where doo i startz?!", there is some level of getting the point across. A balancing act of pushing for the learning and just handing out answers. If the written answer is not understood then it's a guessing game of what part of the words the op would have failed on and it becomes time to refactor and explain those words.. and so on and so on...
Was This Post Helpful? 0
  • +
  • -

#29 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: How to save form size?

Posted 23 August 2012 - 02:32 PM

For the people who think I pasted the code so they can do my homework:
I posted my codes to show a bit effort... I could also say what my problem is and say nothing about codes, so you could write the code. I think that's more doing someone's homework! It's posting a fault code (doing something) versus only the problem (doing nothing), I'm just saying...

I admit that not saying the errors was my fault...
Was This Post Helpful? 0
  • +
  • -

#30 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8379
  • View blog
  • Posts: 31,147
  • Joined: 12-June 08

Re: How to save form size?

Posted 23 August 2012 - 02:36 PM

... then what *ARE* the error messages and what not? Again it's all about helping us to better help you!
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3