How To AutoResize Customized Components (In This Case Customized DataAdapter)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: How To AutoResize Customized Components (In This Case Customized DataAdapter)

  1. #1
    Join Date
    Jul 2013
    Posts
    7

    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);

    }

    }
    }

  2. #2
    Arjay's Avatar
    Arjay is online now Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,359

    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?

  3. #3
    Join Date
    Jul 2013
    Posts
    7

    Post Re: How To AutoResize Customized Components (In This Case Customized DataAdapter)

    Quote Originally Posted by Arjay View Post
    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center