-
August 19th, 2013, 12:40 PM
#1
How To AutoResize Customized Components (In This Case Customized DataAdapter)
Hello,
In order to be able to draw a border around a DataAdapter, I've created a class that inherits from DataAdapter and draws a border around a DataAdapter, making the class a customozied component.
Next, I'd like to be able set it up so that when it gets resized along with the other components on the Form, that it will resize in proportion to the size of the Form.
I've read about how, in general, to resize (or re-scale) a component, one way is to set the Anchor property AnchorStyles.Top, AnchorStyles.Bottom, etc. However, in this case, it doesn't seem to work.
Below is the code for the customized DataAdapter. You can see some different things that I've tried. I'm fairly new to C#. Any ideas or hints would be helpful. Thanks.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace DataAdapterWithBorder
{
public class DataAdapterWithBorder : DataGridView
{
int BORDER_SIZE = 6;
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
ControlPaint.DrawBorder(e.Graphics, ClientRectangle,
Color.Blue, BORDER_SIZE, ButtonBorderStyle.Solid,
Color.Blue, BORDER_SIZE, ButtonBorderStyle.Solid,
Color.Blue, BORDER_SIZE, ButtonBorderStyle.Solid,
Color.Blue, BORDER_SIZE, ButtonBorderStyle.Solid);
// Anchor =
// AnchorStyles.Bottom |
// AnchorStyles.Right |
// AnchorStyles.Top |
// AnchorStyles.Left;
// Dock = DockStyle.Fill;
//ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle,
// Color.Orange, ButtonBorderStyle.Solid);
}
}
}
-
August 19th, 2013, 02:21 PM
#2
Re: How To AutoResize Customized Components (In This Case Customized DataAdapter)
Since you are using a DataGridView, can't you just set its BorderStyle property?
-
August 19th, 2013, 03:31 PM
#3
Re: How To AutoResize Customized Components (In This Case Customized DataAdapter)
Originally Posted by Arjay
Since you are using a DataGridView, can't you just set its BorderStyle property?
No, that doesn't allow the color and width of the border to be set.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|