Results 1 to 14 of 14

Thread: Creating a custom control, but I'm no good at them. could someone help out please?

  1. #1

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609

    Exclamation Creating a custom control, but I'm no good at them. could someone help out please?

    I have a database with filenames and their locations, and to maintain this database I loop through the "locations" and for every location that does exist I loop through thw files in that folder to see if they exist in the database. from this I create a report, but I need this report to have clickable buttons that can trigger actions (like showing a form so enter data for a newly found file), but I dont know how to do that!

    What I effectively need to be able to do is to just add rows of "mesage - button" combinations.

    The little illustration I have attached should help in explaining what I mean.

    I'm not asking someone to write it for me, cos I am trying to learn but if someone could steer me in the correct direction it would be greatly appreciated

    - Michael D
    Attached Images Attached Images  

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    If I understand what you're asking then you are wanting to create a UserControl.

    Right click on your project in the Solution Explorer and choose Add from the context menu. Add a UserControl.

    The UserControl looks like a blank form. Drop a textbox a label and a button on it. You may need to save and rebuild your project now (shouldn't have to, but you may as well...)

    Now UserControl1 should be in your toolbox and you can drop as many instances of it as you want anywhere you wish. It is a control like any of the built in ones (buttons, textboxes, etc.) abd behaves the same - you can assign to its properties and handle its events.

    Does this help, or have I missed the point?
    This world is not my home. I'm just passing through.

  3. #3

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    You have got the point, but the problem that I cannot figure out is how to effectively have a list of these controle like a generated set of rows of these things.

    Like a listbox, but a list of these things, or a single control that does it all. Like, if a file needs to be added to the database, I want a row that shows that a file was found and there is a button on that row that allows you to add it (run a function or any given piece of code in the project).

  4. #4
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    So, put (say) 12 of these controls on your form and have a pair of up/down scroll buttons next to them. Populate the controls from a list of files. Shuffle the data up and down the 12 controls when the scroll buttons are clicked.

    You don't have to go with the up/down scroll buttons - you could use a vertical scroll bar, but its a bit tricky getting the handle sizing right with that.
    This world is not my home. I'm just passing through.

  5. #5

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    Youre getting the idea
    To clarify the idea even furthere, I have found that the Microsoft Baseline Security Analyser has used what I am looking for.

    Find attached a screenshot of what I mean. see how it has some rows which have text and buttons that are customised for each request.
    Attached Images Attached Images  

  6. #6
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732
    Dynamically load the instances of controls ass needed...
    Leather Face is comin...


    MCSD

  7. #7
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    ...and set the properties of each UserControl appropriately (e.g. height, button visibility, label text, etc).
    This world is not my home. I'm just passing through.

  8. #8

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    how? example?

  9. #9

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    Anyone ?

  10. #10
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Does this help to get you started?
    Attached Files Attached Files
    This world is not my home. I'm just passing through.

  11. #11

    Thread Starter
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    Sweet :-) thanks a lot dude.

    now fo someone is kind enough, how would I be able to access functions that are located inside the parent form, from the control ? (I'm a little new to this, so please be tolerant)

  12. #12
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    If your parent form has a Public function called Funky() then you should be able to access it as follows:

    VB Code:
    1. Me.ParentForm.Funky()
    This world is not my home. I'm just passing through.

  13. #13
    Addicted Member PeteD's Avatar
    Join Date
    Jun 2003
    Location
    Sydney
    Posts
    158
    don't you mean:

    VB Code:
    1. Ctype(Me.ParentForm, ParentFormClassName).Funky()

    ?

  14. #14
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Yes, I expect I do. Apologies for my sloppiness. !
    This world is not my home. I'm just passing through.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width