Adding USER CONTROL to VB6 form on load? - user-controls

I have a form where Client Info will be displayed. What I did is I created a user control with a bunch of textboxes lined up next to each other for Fname, Lname, Dob, SSN, etc. On the form itself, I created a copy of the user control but with labels to display the information that I'll in the USER CONTROL itself. So on FORM_LOAD, I'm pulling data from the server and I need it to add just as many USER controls as I have Clients in the database. The problem I'm seeing is, each time I add a control with this statement
Dim myCtl As Control
Set myCtl = Controls.Add("Project1.UCclient", "MyCtl", frmClientUC)
myCtl.Visible = True
....the user controls name gets incremented by one. So the first one I added on the form is ucclient1, then if i add another its ucclient2 and so on. Additionally, i loaded one of the USER CONTROLS with data (just to make sure it worked), I had to specify which ucclient I was referencing. So for the first one that I loaded I SELECTED data from SQL-SERVER then did this...
ucclient1.fldFirstName =RS!FirstName
ucclient1.fldLastName = RS!LastName
...and so forth for all the other fields. Because I have to specify what user control form I'm putting the data into, is there a way for it to increment it by itself? Possibly looping? I'm a newbie in VB6 and I'm just having a difficult time makign this work harmoniously without a 1000 lines of code.

You would do it the same way that you would any control. Put one control on the form in design mode. Set its index property to 0 to make it a control array. (If you have a context where you don't want any controls, then make it invisible and then make it visible when you need it.) Then add more controls as you need them, setting the Top and Left properties to position them on the page.
Here is the doc for adding a control to a control array at runtime.

Ok. I've found out a new way. It works well.
+ At form1, add a new user control (U1).
+ Copy code U2 (The User control of another project) into U1. Save it with the same name.
+ Close U1
+ At Form1, open ToolBox and click U1. There is an error message apear and you'll see the name of control missing (missing name).
+ Open the propertice of U2. Choose the missing name to see kind of control.
+ Open U1 and add the control and name it as the same name (missing name).
+ Return Form1 and click U1 in Toolbox to add control U1.
+ Make propertice U1 as same as U2.
sorry about my English.

Related

Blue Prism Write to Web Client

Has anyone had any problems writing data to a web client data field?
Having spied the field to be written in, the write action correctly writes the value from the data item into the web field. We then "Save" the value in the field by clicking the Save button. This is when the value reverts back to the value that was previously in the field and does not save the new value.
Copying the value from the data item and pasting it directly into the web field and hitting save works fine, but for some reason when Blue Prism does the write action and then save, the new value is not saved.
Any suggestions?
This is probably due to the way the web application is coded - specifically, the data in the box is not acknowledged until a keydown event (or similar) is fired. When you copy/paste the data into the field, it fires a similar event where it believes the user to have interacted with the field.
The solution for this type of field is to use the Send Keys or Global Send Keys functionalities of Blue Prism to send the desired text.
It happens when the target application uses java script events to sense the changes in the element. To handle this , you have to use the send keys in following format.
1. Focus the application / Control
2. Send Global mouse click centre to the element
3. Send "Sendkeys" to the application now.
4. Focus a dummy element in the page to let the page sense your input.
If the old value is already higlighted when the spied field is selected, try getting BP to delete it first, then paste in the new value, then click on the field again, then save. If this doesn't work, then uncheck the URL attribute of the application model you are using for the spied field and try this again.

How to hide URL Selector content tab?

I am creating a custom webpart using the Url Selector from kentico. I want the user to select content just from the Media Library. I went to form controls -> Url Selector -> Properties -> Dialogs_Content_Hide -> Default Value -> Yes and it still showing it in the Web Part. If I select the Dialogs_Web_Hide, Dialogs_Libraries_Hide and select the yes option in the default values, they hide, all except the Content_Dialogs.
Is this a bug? Or its something wrong?
Here is an example of the tabs
First set the form controls properties back to the way they were. If you don't, it will cause all kinds of problems later on.
Secondly, when you create the property in the webpart in the UI, select the URL selector form control for your text fields control. The scroll down just a bit and under the Editing Control Settings you'll see an "Configure" link. Click it. In there you will be able to tell the form control what tabs you want to enable and disable.
To add to Brenden's answer; if this is something you need to do a lot for your current build, then I'd also suggest making a copy of the Url selector form control and customize the properties as you originally mentioned. This way, you leave the default control in place for the system and have a control tailored to your needs. I've done this just now to check with a new form control that I called Media URL selector. Do make sure that you select the same source file as the original control in the Cloned form control file name property - Kentico by default will try to locate a new file called <original filename>_1.ascx. The reason for this is that admin section of your site also makes use of this control, so you may cause a nasty side effect somewhere else in the system.
As for why the settings had no effect; these are the default values you are setting. If you already have the form control in use, then the default setting would have been applied as they originally were. If you find one of the fields in question, you can change the control type to Text box, click Save, and then reassign it to Media URL selector.

Dynamically add / remove editable area to custom control embedded in XPage

Okay... this is a little difficult to explain but I will try my best.
In Custom Control while adding properties in Property Definition we can set "Allow multiple instances" which allows us to add multiple instances of that property when the control is embedded in XPage.
Similarly, I need to know whether it is possible to add (and remove) Editable Areas in a custom control when it is embedded in XPage? What I plan is that I would have a repeat control inside my custom control and I would be able to put the contents in each editable area in every loop of that repeat.
Is this the right way to go about or am I looking at this problem incorrectly? Any solution not involving editable areas is also welcome :)
Update 4 Apr 2013:
A use case context I am looking for is a simple carousel where contents of each screen in carousel can have different contents. These contents would be put into each (dynamically added) editable area. The contents can be very different from each other with one screen containing only text, other only image and another both image and text.
Look at the table walker example in the 26 original exercises. It does mostly what you are looking for (conceptually). You won't need multiple editable areas. Whatever is inside the repeat gets repeated.
What you want to do is to give the control a custom property "boolean editMode" so you can render that one line to be edited - if that's the UI pattern you want to follow.
You also could consider a dojo table with Ajax which allows for a familiar spreadsheet UI

Best practice in dealing with xpages extensions dialog box?

I have an extension pages dialog box that I placed in a custom control. The dialog box is used to search for cost centers and return information such as market, cost center number, cost center name etc.
A "Select" button is pressed and the dialog box appears. The user searches for and selects their cost center. The OK button is pressed and it closes the dialog box and updates the various fields on the xPage.
A couple of questions.
Currently the "Select" button on the CC needs to know and refer to the name of the dialog box control within the CC. Seems to me that this is not the best practice. My end user programmer needs to know the ID of that dialog box control within the CC. Is there any way for my "Select" button could "show" the CC and the CC would actually show the dialog box control?
My CC makes use of custom properties to store the various document fields from the selected cost center. The OK button then uses these properties to set the various fields on the xPage. This again does not seem to be a best practice. If I wanted to use that CC in another application then I might need to edit the code in the OK button. Is there a better way to deal with this? Like I can set properties for a CC when I drop it on my xPage, is there a way I can tell it the code that I want to execute when the OK button is pressed?
One thing I thought was to have properties for the fields that need to be updated by the OK button but that does not seem to be so flexible.
For the issue of needing to know the id not sure if theres a typo but I don't understand why its bad that a select button inside a cc needs to no the id of the dialog to open it? did you mean the select is outside the cc? either way have you tried anything like creating a property on the custom control so that from outside it you can set something maybe
<xc:mycustomControl showDialog="false">
and then when something outside it happens change showDialog and refresh the cc, then inside the cc you can have a before / after page load to determine what happens when showDialog is true / false.
For your second issue it sounds to me like this should be using a domino document structure. Rather than the dialog pulling out each piece and the ok button updating, what I would do is have a domino doc data source on the page. when something is selected through the dialog I would update the document this source is pointing to and have all the fields bound to what ever fields they need to be. This way after something is selected the fields will just update to what ever the document contains, and it will be much more re useable so long as the domino docs have the same field names

Automatically open document when only one document is listed in repeat control

I have a repeat control for a domino view which displays the results from a search field.
As you type more characters into the search field the number of items in the list is reduced. If/When the the list only contains a single item I would like to open item automatically, without having to click the link.
Any ideas are appreciated.
Edit: after some very interesting responses, here are some screenshots
I have 3 elements on the page, a searchbar, a repeat control and a form:
When I start typing in the search bar, the repeat is refreshed with every keystroke:
the list is reduced, typing the next character ...
again the list is reduced, only 2 left, typing again....
Only one left, now it would be time to open the document in the form ..... without clicking the link.
I've tried several events on the page, but it seems that I could not find the one that will allow me to "select" the document and display the data in the form.
It seems that it's not as simple as I thought
Since you want to open the link automatically I don't know if I would try to base it on the getRowCount() of the repeat itself. You don't want to even get that far right? you just want to go to the single document.
I would put a function in beforePageLoad event maybe. Not totally sure which event but I'd try that first. Use SSJS and do a lookup that would basically return a collection of what the repeat would show. If the collection count = 1 then get your destination from that entry and do your redirection from there.
That what I would try at least. Interesting scenario!
Now that I see the screenshots this might be easier then you think and I have already implemented something similar on an internal application that I have built. It does rely on the fact that each entry in the list is 100% unique.
First of all you will need to bind the search field to a scoped variable and the onchange/onkeypress event will need to perform a partial refresh of a panel that contains both the list and the document portion of the page.
For the list the link on each item should set the value of the same scoped variable used in the search box and clicking the link should be set to run a partial refresh of the document area.
For the document area you will need two panels, the first panel will only display if there is no matching document and the second panel will only display if there is a matching document, you can do this in the rendered section by writing some ssjs that grabs a handle to the db/view and does a dblookup and returns either true or false if the document exists depending on panel your dealing with.
With this setup, when somebody clicks a link or fills out the searchbox the scoped variable will contain a value, the document panels will then check to see if this is a unique value in the view in the db and update themselves to either display the 'no document' panel or the 'document' panel accordingly.
You could add a evaluation script to the entry of your repeat control which checks the size of your repeat control using the method getRowCount() from the component. If this is 1 you could execute a context.redirectToPage("yourpage.xsp?id=yourid",true) this forces the current page to send a redirect request back to the browser and therefore redirects you to the correct page.
All you need to know is which xpage you need to open and which parameters you should use. But these could be retrieved from the content you are iterating over.

Resources