473,320 Members | 2,162 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,320 software developers and data experts.

Rezise usercontrol by width only

Hi to all,

I have created a user control for which I want only the width property
be available for resizing.

I have tried:
namespace TestControl
{
public class Class1
{
public override double Height
{ get
{
base;
}
}
}
}
But on compile I get:
Not suitable method found for override.

How do I do this?

Sep 22 '07 #1
3 3499
"Executor" <wo**********@sogeti.nlwrote in message
news:11**********************@19g2000hsx.googlegro ups.com...
public class Class1
{
public override double Height
[...]
Not suitable method found for override.
Well, your "Class1" is not inheriting from anything, so it's no wonder
that you can't override Height.
You can inherit from Control or any of its derived classes, but you are
still not going to be able to override Height because it is not marked as
virtual in the Control class. Instead of overriding, you can shadow the
property by using the "new" keyword (public new double Height), but this
will not prevent the control from being resized by code that casts into the
parent class.
Sep 22 '07 #2
As Alberto said, the supplied code isn't for a control.

Assuming you have a control coded/designed, and you want to limit the size
when used on a form, then you can set the minimum and maximum sizes to what
you want. In your case, set the minimum and maximum heights to be the same
value.

If you are trying to control the size inside the control, you will need to
override the events raised by resizing the control.

"Executor" wrote:
Hi to all,

I have created a user control for which I want only the width property
be available for resizing.

I have tried:
namespace TestControl
{
public class Class1
{
public override double Height
{ get
{
base;
}
}
}
}
But on compile I get:
Not suitable method found for override.

How do I do this?

Sep 22 '07 #3
On 22 sep, 15:06, Family Tree Mike
<FamilyTreeM...@discussions.microsoft.comwrote:
As Alberto said, the supplied code isn't for a control.

Assuming you have a control coded/designed, and you want to limit the size
when used on a form, then you can set the minimum and maximum sizes to what
you want. In your case, set the minimum and maximum heights to be the same
value.

If you are trying to control the size inside the control, you will need to
override the events raised by resizing the control.
CUT

Hi there,

Thanks for your info, I now have this:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace TestProps
{
public partial class UserControl1 : UserControl
{
public enum eOrientation
{
Horizontal,
Vertical
}
private eOrientation m_Orientation = eOrientation.Vertical;

public UserControl1()
{
InitializeComponent();
}

public eOrientation Orientation
{
get { return m_Orientation; }
set { m_Orientation = value; }
}

public new int Height
{
get { return base.Height; }
set
{
if (m_Orientation == eOrientation.Vertical)
base.Height = value; ;
}
}
public new int Width
{
get { return base.Width; }
set
{
if (m_Orientation == eOrientation.Horizontal)
base.Width = value;
}
}

private void UserControl1_Resize(object sender, EventArgs e)
{
if (m_Orientation == eOrientation.Horizontal)
{
// ToDo: Calculate Height
}
else
{
// ToDo: Calculate Width
}
}
}
}

It seems to work.

Sep 27 '07 #4

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

Similar topics

2
by: Jose Michael Meo R. Barrido | last post by:
I made a custom runded rectangle usercontrol. I used a function i found on the internet. the function works fine(see "GetRoundRect" below). I use the fullowing code to make my usercontrol...
2
by: Jaikumar | last post by:
Hi, 1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image. 2) In the UserControl1 i am...
4
by: steve bull | last post by:
I have created a UserControl and added it to my toolbox. It appears in the toolbox with the icon I created for it. The problem is that when I drag the control onto a form no code is generated. If I...
0
by: Sebastian Hiller | last post by:
Hello, i'm new to .Net (i'm using VB as language and i'm working in the code-behind mode) and i can't solve the following problem: I have a WebForm and want to Add a UserControl...
1
by: al | last post by:
Greetings, I included a UserControl (UC)on webpage. It works fine except when I change document direction to 'rtl', UC doesn't resize with the rest of document. It just disappears behinde rest...
1
by: Patrick | last post by:
Problem I have an ASPX file, with a table of 3 columns, 2 rows with a usercontrol in the middle column (in the code snippet stated below, although in reality, the left hand column would also...
3
by: Patrick.O.Ige | last post by:
I created a USERCONTROL and i want to call a LABEL from an ASPX page. The USERCONTROL is in the ASPX page I have the label :- Label lblstr = new Label(); And displaying using:-...
1
by: Philipp Lenz | last post by:
I'm very confused about how this works, all the tutorials out there show me how to apply a skin to a webcontrol, but I want to know how I can access the components of a control....for example: I...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.