DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 14 of 14

Thread: Creating My Own Access Style Data Control

  1. #1
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263

    Creating My Own Access Style Data Control

    I am creating a basic data control patterned after the MS Access Forms Data control. In this case the control won't be binding to any other controls it is just for handling the basic recordset functions like Move: Next, Prev, First, Last, New, etc..
    I created a property, like on an access form, where you can include a record selector or not. The record selector is the Long button that shows up on the left side of the form. It is used to select the record when you want to delete, or to update the record if it has been modified. It also indicates when a record has been modified by changing its Icon from an arrow to a pencil.
    My problem is that I want to add or remove this button based on the property setting, so how do I programatically add a control to a form when the form is in design mode?
    Also how would I make the RecordSelector Property a design mode only property? You would never set this property at runtime.

  2. #2
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    You are talking about a user control, don't you ?
    Well if you don't use a user-defined control (or another OCX project) then I would say to make this you need to use it. otherwise this is done automatically if :
    -the user control code is not opened within the opened windows.
    -the property "Edit At Design Time" is set to TRUE.
    -just add on change() ... on clcik() .. on whateverYouWant() .... and you will see it acting kool-ly
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  3. #3
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    The control I am writing is a UserControl that has a recordselector property. When I add the UserControl to a form, it is automatically set to align to the bottom of the form. When I set it's recordselector property to true it should add a button control that is set to align to the left side of the form. This button control will be the recordselector. If I set the recordselector property back to false then the UserControl needs to remove the recordselector button from the form. The form is of course the UserControls parent form.

  4. #4
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819

    Arrow

    Try the attachment ... is that what you need ? [hint: open the form in design view and change the "btn" property]
    Attached Files Attached Files
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  5. #5
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    No that is not correct. You are just hiding the button on the UserControl. I need a seperate Button on the actual form itself, not on the UserControl. Here is a sample project. Here I used a PictureBox instead of a button because it turns out that only the picturebox has the Align property and I needed it to be Aligned Left. Later after I get the code to work I will add the extra code to draw the borders so that it acts like a button.
    Last edited by Ron Weller; 02-11-2009 at 07:59 PM.

  6. #6
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    if you wanna do that with a control that exists in the "design form" and want to later distribute your control separately then your options are to tell the user when using the control he has to make the side picturebox with the same name and everything ... and in the usercontrol put this code in the desired event :

    Form1.cmdRecordSelector.Visible = False

    as you kan see you should have the same "form name" the "control name" and maybe the "control properties" ...

    another better solution is to implement this picturebox inside another user control and interact between them separetly independent on what the form is ...

    hope this can help
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  7. #7
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    another idea that may helps .. in the user control make a function that get the handl of the desired control ... when the OCX initialize .. call this function to get the dependent control and interact with it upon the property change ...
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  8. #8
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    I'm working on an Idea where you have two UserControls, One is the Data Control, and the Other is the Selector Control.
    Then I will add two properties to the Data Control, one to hold the name of the selector control, the other to allow you activate or deactivate the selector support.
    This way if you try to activate the selector support it will give an error message if the selector name property does not contain a valid selector control name.
    Also when they enter or remove the selector name I can automatically set the support flag to True or False, depending on valid contents in the selector name property.
    This way I can setup a generic data form template that already has the controls on it and then activate or deactivate the selector support as needed.
    I'll keep this thread updated as to how this idea works out.
    (It would be so much eaiser if you could just add and remove the selector control automatically!!!)
    Last edited by Ron Weller; 03-28-2008 at 05:09 PM.

  9. #9
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    first I remember you had an old thread about making such thing all in one only control .. wasn't u able to figure it out like that so that this will be much easier ?

    second your supposed solution could be better if you use something like what the MAPI control does where you need a session and the control ... in you case you will have something like :

    RonAccessCtl1.RonCtl = RonCtl1.getProp

    this line code the user has to write it so that they can interact with each others ...

    third , if you don't know that ... we still can change the alignment of your control ... you want the first to stick in the bottom and the second to the left but in their prop. we still can change alignment ... so again I think the best solution is to make them all one only control ...
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  10. #10
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    Yes I did ask a similar question in an old thread but those suggestions did not work either.

    If you change the Align property, my contols detect it and reset it right back.
    It forces the selector to the left and the data control to the bottom. It's designed to look like it's part of the form, not a free floating control.

    It could be free floating if I made it one control; but the problem with making it one control is that the control takes up the entire form. It gets in the way when you start adding your regular controls.

    I could make it a container control, but how do you keep the inserted controls from overlaping the builtin ones? Not sure how that would work.

  11. #11
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    I just got a new idea that may help ... add a third usercontrol .. invisible at runtime ... and this is the only public control in the OCX ... when the user select it it will generate the other two controls and past them in the form using :
    Controls.Add ...
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  12. #12
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    Yes but then you can't see it at design time, which is realy the point. Otherwise you have to deal with things like possibly needing to move controls up, or over, or resize the form, to make room for the data controls. Then there are all of the design time properties that will have to be passed on to the actual data controls.
    Is there a way to create a new kind of form, where these controls are part of the form itself? Kind of like what some programres do when they take an existing control and give it new capabilities. Only thing is I don't know how they do that either!

  13. #13
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    Kool I got another better idea .. make a template for your OCX .. after the user install your ActivX .. he will open new Ron-Project .. which is already designed to include the UserControls as desired ... once later he still kan add new RonForm to the project which contains the usercontrols well alignmed and designed ...

    to kreate a template projekt or form just design them as you wish then same the .frm and the .prj files and put them in projects folder which exists here :

    HKEY_CURRENT_USER\Software\Microsoft\VisualBasic\6.0\TemplatesDirectory

    the ActivX installer should do that automatically for the user ...
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  14. #14
    Join Date
    Apr 2008
    Posts
    1
    thanx bro

Similar Threads

  1. ADO data controls + 2 ACCESS tables
    By Ron in forum VB Classic
    Replies: 1
    Last Post: 08-11-2001, 01:59 PM
  2. Data Access Strategy
    By Karl Robinson in forum VB Classic
    Replies: 0
    Last Post: 07-16-2001, 01:55 AM
  3. Replies: 0
    Last Post: 01-17-2001, 11:38 PM
  4. Simple Data Environment Question
    By Alex Nitulescu in forum VB Classic
    Replies: 1
    Last Post: 10-21-2000, 05:13 AM
  5. Data Access with ASP+
    By Greg Huber in forum ASP.NET
    Replies: 3
    Last Post: 08-22-2000, 11:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center