473,378 Members | 1,152 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,378 software developers and data experts.

A problem with "Location" and "Size"

Hi,

A have a problem with Inhreit Control.

I try to Change its Size in Construct Function, And it works.

Code Here:
--------------------------------------------------
public class UserControl:TextBox
{
public UserControl()
{
this.Size = new Size (100, 100);
}
}
--------------------------------------------------
And then I try to Change it's Location, but it won't work.

Code Here:
--------------------------------------------------
public class UserControl:TextBox
{
public UserControl()
{
this.Location = new Point (100, 100);
}
}
--------------------------------------------------
What can I do if I want to change the Control's Location by the
Control itself?

Any help would be appreciate!

Thanks

chen


Nov 17 '05 #1
4 1555

"JMUApache" wrote...
A have a problem with Inhreit Control.

I try to Change its Size in Construct Function, And it works.
[snipped code]
And then I try to Change it's Location, but it won't work.
[snipped code]
What can I do if I want to change the Control's Location
by the Control itself?


You both can and can't...

Actually what you did with both the Size and Location was to change the
"default" values, but both of those are made void by the *user* of your
control.

If you use some graphical IDE for placing the control on a Form or likewise,
that will cause the IDE to generate code for at least the Location (the
place where you clicked in the control on the form) and the user can change
the Size in the same IDE, which replaces the "default" values of your
control.

// Bjorn A
Nov 17 '05 #2
Hi, Bjorn

First Thanks for your answer. Maybe I have not Describe my
question Well.

I didn't drag this control to the form but use code "new"

code here
-------------------------------------------
UserControl uc = new UserControl ();
--------------------------------------------

and I did not change its "Location" or "Size" property on my code.
It work well with "Size", but "Location" not.

And I then write a "SetLocation" Function in the UserControl
class, then call it from the form. The "SetLocation" do not work,
either.

Thanks for reply.

chen hui



On Sat, 20 Aug 2005 11:25:19 +0200, ""
<bj**********@DoNotSpam.hotmail.com> wrote:

"JMUApache" wrote...
A have a problem with Inhreit Control.

I try to Change its Size in Construct Function, And it works.


[snipped code]
And then I try to Change it's Location, but it won't work.


[snipped code]
What can I do if I want to change the Control's Location
by the Control itself?


You both can and can't...

Actually what you did with both the Size and Location was to change the
"default" values, but both of those are made void by the *user* of your
control.

If you use some graphical IDE for placing the control on a Form or likewise,
that will cause the IDE to generate code for at least the Location (the
place where you clicked in the control on the form) and the user can change
the Size in the same IDE, which replaces the "default" values of your
control.

// Bjorn A


Nov 17 '05 #3

"JMUApache" wrote...
First Thanks for your answer. Maybe I have not Describe my
question Well.

I didn't drag this control to the form but use code "new"

code here
-------------------------------------------
UserControl uc = new UserControl ();
--------------------------------------------

and I did not change its "Location" or "Size" property on my code.
It work well with "Size", but "Location" not.

And I then write a "SetLocation" Function in the UserControl
class, then call it from the form. The "SetLocation" do not work,
either.

In that case, could you provide a small but complete example, where your
problem occurs.

How I try, I can't replicate your problem.

In this small sample the Location is set at {100, 100}:
using System;
using System.Drawing;
using System.Windows.Forms;

class UserControl : System.Windows.Forms.TextBox
{
public UserControl()
{
Location = new Point (100, 100);
}
}

public class Form1 : System.Windows.Forms.Form
{
public Form1()
{
UserControl uc = new UserControl ();
this.Size = new System.Drawing.Size(300,300);
this.Controls.Add(uc);
}

static void Main()
{
Application.Run(new Form1());
}
}
// Bjorn A
Nov 17 '05 #4
Hi Bjorn:

Thank you.

The reson it does not work it is that I set it's Location
property another place.

Thanks for your reply.

chen hui

On Sat, 20 Aug 2005 20:12:53 +0200, "Bjorn Abelli"
<bj**********@DoNotSpam.hotmail.com> wrote:

"JMUApache" wrote...
First Thanks for your answer. Maybe I have not Describe my
question Well.

I didn't drag this control to the form but use code "new"

code here
-------------------------------------------
UserControl uc = new UserControl ();
--------------------------------------------

and I did not change its "Location" or "Size" property on my code.
It work well with "Size", but "Location" not.

And I then write a "SetLocation" Function in the UserControl
class, then call it from the form. The "SetLocation" do not work,
either.

In that case, could you provide a small but complete example, where your
problem occurs.

How I try, I can't replicate your problem.

In this small sample the Location is set at {100, 100}:
using System;
using System.Drawing;
using System.Windows.Forms;

class UserControl : System.Windows.Forms.TextBox
{
public UserControl()
{
Location = new Point (100, 100);
}
}

public class Form1 : System.Windows.Forms.Form
{
public Form1()
{
UserControl uc = new UserControl ();
this.Size = new System.Drawing.Size(300,300);
this.Controls.Add(uc);
}

static void Main()
{
Application.Run(new Form1());
}
}
// Bjorn A


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Joe | last post by:
I have an upload file operation in the web application. UploadForm.asp is the form, and UploadAction.asp is the form processing. //UploadForm.asp <FORM NAME="InputForm"...
10
by: Clint | last post by:
Hey all - I'm having a really confusing problem concerning a web service. Right now, I have an application that needs to call a web service that does nothing but return "true" (this will...
7
by: charliewest | last post by:
Using .Net CF, i have created a 2 dimension ArrayList, and "binded" this list to a ComboBox control using the "DataSource" property. I have set the DisplaySource and ValueMember properties as well....
5
by: Sue & Bill | last post by:
I have: Rectangle rects = new Rectangle; I want to initialize the values of rects as follows: Option A: ======== for (int i=0; i<rects.Length; i++)
7
by: Dica | last post by:
i've used the sample code from msdn to create an encyption/decryption assembly as found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp i'm...
42
by: Martin Jørgensen | last post by:
Hi, I'm trying to move a matlab program into c language. For those who knows matlab, this is the line I want to program in c: hx(1:nx,1:ny) = 0; % nx=10, ny=10 It works on a 2-dimensional...
0
by: mpietsch | last post by:
There has been quite some discussion on this particular error when resizing forms and moving controls on them. One solution that seems to work is enlarging the form's detail-area to maximum size...
2
by: swethak | last post by:
hi , i write the code in .htm file. It is in cgi-bin/searches/one.htm.In that i write a form submitting and validations.But validations are not worked in that .htm file. I used the same code in my...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.