w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Adding Dynamic Controls in ASP.NET
You need to have the logic in your click handler add to the panel's Controls collection as well as to the list of controls, like this: protected void btnAddAddress_Click(object sender, EventArgs e) { AddressUserControl aCntrl = LoadControl("~/UserControls/AddressUserControl.ascx") as AddressUserControl; addresses.Add(aCntrl); phAddresses.Controls.Add(aCntrl); } UPDATE: In your user control, you need to define an event that can be defined in the page that hosts the user control, like this: AddressUserControl.cs (code-behind): public event EventHandler RemoveAddress; protected void removeAddressUserControlButton_Click(object sender, EventArgs e) { // Find out if the event has been set, if so then call it if (this.RemoveAddress!= null) { RemoveAddress(se

Categories : C#

dynamically adding controls under loop in C#
You need to put the line private Label newLabel = new Label(); in the for loop. private int txtBoxStartPosition = 100; private int txtBoxStartPositionV = 25; for (int i = 0; i < 7; i++) { Label newLabel = new Label(); newLabel.Location = new System.Drawing.Point(txtBoxStartPosition, txtBoxStartPositionV); newLabel.Size = new System.Drawing.Size(70, 40); newLabel.Text = i.ToString(); panel1.Controls.Add(newLabel); txtBoxStartPositionV += 30; }

Categories : C#

Adding custom controls to IB xcode
The docs for CocoaTouch classes will usually indicate if a class is not designed for sub-classing. In the case of UISlider, there's also some instructions for customizing appearance. Custom Component in Interface Builder To use a custom component within Interface Builder, its necessary to use the "object" component, and specify the class type to your custom class. Unfortunately this does not render any visual queues, like core UIKit classes. Your own Plugin It may be possible to provide a plugin to tweak Xcode, however this is no small undertaking as there are no official docs, so its necessary to search for open-source plugins on GitHub, etc and study the code. Even then, the plugin may break with subsequent version of Xcode. Recommended Approach Interface Builder is an amazing t

Categories : Objective C

How to improve speed of adding controls to UI
If your computer have multiple cores, and I am assuming it have, try to perform the for loop in parallel (parallelfor (from .net 4 or above). You can set the points List size during creation to 256, this will prevent memory allocations during the items adding operation. Consider use a StringBuilder if Global.currentZonesToMap is large. Use StringBuilder to build the value for the DevicePoint.desc string property. Good luck, M. Moshe

Categories : C#

Adding NAudio controls to toolbox
Those are Windows Forms controls, not WPF controls. NAudio does include a WPF demo application which contains some bits you could reuse, and also the .NET Voice Recorder application shows how to display waveforms and volume meters in WPF while using NAudio.

Categories : Wpf

Is there a quick way of adding an event to many controls at once in WPF?
Look into event routing. You should not create and access individual text-boxes but let the framework create them via datatemplating a collection, your above code is ze horror.

Categories : C#

Adding custom server controls into MVC
You cannot use your ascx or dll custom controls in MVC. Mostly, because the lifetime of ASP.net controls is different. In MVC - controls just render HTML, They don't receive any postback, they don't save controlstate or viewstate. Even "Page" object does not exist in MVC. MVC controls can accept parameters and render HTML.

Categories : Asp Net Mvc

Adding Controls to a panel in Parallel or Concurrent
Your code is way too complicated for what it's trying to do, especially since I don't see any advantage in using parallelism here. (Though there might be some reason in your real code, it's hard to tell from your samples.) I think you shouldn't use parallelism until you learn how it works. And programming using a trial-and-error approach should be avoided, because it means you don't actually understand your own code, so it leads to bugs. But the actual problem in your code doesn't have anything to do with parallelism. It's that you're using Random incorrectly. If you use the default constructor, Random is seeded with the current time. This means that if you create multiple Random instances in short succession, like you do, they are all going to return the same sequence of numbers. This me

Categories : C#

Adding asp controls to programmatically added content
Its kinda hard to tell what your going for, but I will do my best to get as close as I can. The first thing is you need some control to work as a "container". This can be just about any control you like. In my test for this scenario I did something like this: <div runat="server" id="ContainerDiv"></div> The next thing is you need a way to manage your Id. I did this by creating a simple variable and method like so: private int IdCount = 0; private string GetNewID() { return string.Format("try{0}", IdCount++); } Now you say you want an achor tag that also has a CommandName and CommandArgument a LinkButton will do this. You can add a LinkButton to your div above like this: ContainerDiv.Controls.Add( new LinkButton() { ID = GetNewID(), CommandName

Categories : C#

Adding controls at runtime in from derived class in MFC
Declare a member variable CButton m_ctrl_chk, override DialodDervied::OnCreate() and add code like int DialodDervied::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialogEx::OnCreate(lpCreateStruct) == -1) return -1; m_ctrl_chk.Create(_T("Checkmate"), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, CRect(5, 5, 100, 20), this, 1234); // the 1234 value is the ID of the control return 0; } Use similar classes (CEdit, CStatic, CButton, ...) to create other type of controls in the same way.

Categories : C++

Adding controls dynamically according to data type WPF
Get the list of PropertyInfos of your model and wrap them in ViewModels. Then use DataTemplates with implicit keys to generate your controls. Step1: Get PropertyInfoViewModels var vms = model.GetType().GetAllProperties.Select(p=> ViewModelFactory.Create(p)); Your factory should return a StringPropertyViewModel for string properties, etc. abstract class PropertyViewModel<T> : INotifyPropertyChanged { public string Caption {get; set;} public T Value {get; set;} } Step2: DataTemplates <DataTemplate TargetType="{x:Type sys:StringPropertyViewModel}"> <StackPanel Orientation="Horizontal"> <Label Text="{Binding Caption}" /> <TextBox Text="{Binding Value}" /> </StackPanel> </DataTemplate> Step3: Ensure the DataTemplates ar

Categories : Wpf

Adding controls to custom panels in the designer
For anyone that wants to know how to do this I was searching for the wrong thing as to why I couldn't find anything on the topic How to drop controls onto a panel in a user control?

Categories : Dotnet

Adding Controls to a StackPanel from a BackroundWorker thread
Try using BeginInvoke instead. for (int i = 1; i <= 10; i++) { string content = DataSupplier.GenerateRandomInt(); this.Dispatcher.BeginInvoke((Action)(() => { lbl.Content = content; //create a new label, and set it's content to a randomly generated number Label lbl = new Label(); //add this label to stackPanel1 stackPanel1.Children.Add(lbl); })); Thread.Sleep(100); } Invoke will execute synchronously, so when the call has been executed, your thread will return, BeginInvoke will instead execute asynchronously. I have added a thread.sleep to suspend background thread for a while. In this case all the work done by background thread is to update the UI, so UI is always busy.

Categories : C#

How optimal the code can be with dynamically adding the controls
Optimal code: Doesn't contain more than 50 lines of difficult to read code (agreed, it's not unreadable, but still, minor refactoring would help), Doesn't mix CSS with HTML, together with presentation-related HTML attributes such as width, Doesn't use the JavaScript alert. Let's get back to your question. Which one is better: StringBuilder or HtmlGenericControl? Better being an extremely vague term, let's answer a bunch of slightly different questions: Which one is faster ? Probably StringBuilder, given that it doesn't matter. At all. Compared to the time spent downloading an image (say two seconds, i.e. 2 000 ms.), the comparison in performance between StringBuilder and HtmlGenericControl will be very probably less than a millisecond. Is it important that you waste 1 ms. on a proc

Categories : C#

Adding styles to Parameters controls in SSRS 2008
You could try hacking the css in the report manager - not sure if that will 'pass through' to sharepoint. Maybe you could modify some css in sharepoint to this. Use a dom inspector such as Firebug, Chrome developer tools or IE developer tools to see where the styles are coming from. If you need to validate dates, you can do this in a stored procedure. Check the values of the parameters and kick out an error message. It's not pretty, but it works. IF DATEDIFF(m,@STARTDATE, @ENDDATE) > 0 RAISERROR(N'Date range must be less than one month',16,1)

Categories : Reporting Services

adding attribute to dynamic controls generated in javascript
For dynamically generated content you could use on $("form").on("change", function(event) { alert('Checkbox click!'); });

Categories : Javascript

C# WinForms, Adding a usercontrol Dynamically during runtime and controls are invisible?
It seems that you have called SuspendLayout() without telling the panel to ResumeLayout() pnl_ContactDetails.SuspendLayout(); for(int i = 3; i < details.Count; i++) { TextPrompt txtbox = new TextPrompt(details[i]); //Textbox to be added MessageBox.Show(details[i].value); txtbox.Name = details[i].name; //Sets properties txtbox.Location = new Point(25, y); txtbox.Size = new System.Drawing.Size(345, 45); txtbox.TextValueChanged += new EventHandler(txtbox_TextChanged); /* txtbox.Show(); */ // Leave this call out in favor of: txtbox.Visible = true; this.pnl_ContactDetails.Controls.Add(txtbox); txtbox = (TextPrompt)this.pnl_ContactDetails.Controls[i - 3]; //Checks to make sure controls are on form. MessageBox.Show(txtbox.ContactDetails.name);

Categories : C#

C# adding controls in site master wont reference in asp:loginView
Label ClubName= HeadLoginView.FindControl("ClubName") as Label; if(ClubName != null) ClubName.Text = "hello"; your aspx label ID is ClubName but in your code you access it as NameClub. Anyway you can't access controls inside LoginView directly. Use FindControl method and get the control as above. You better Read How to: Access Server Controls by ID

Categories : C#

Render speed: adding one DOM item at a time or adding set of items at once
What I would do is use document.createDocumentFragment() and do all possible operations there, and touch the real DOM once. (Beside in a loop might be a good idea to cache the selector once): var frag = document.createDocumentFragment(); $.each(results, function(key, val){ var a = document.createElement("div"); a.innerHTML = val; frag.appendChild(a); }); $(".results").append(frag);

Categories : Javascript

Three.js First Person Controls moves the camera all the time
You might want to use the PointerLockControls instead See an example here: https://github.com/mrdoob/three.js/blob/master/examples/misc_controls_pointerlock.html

Categories : Misc

Dynamically adding input controls to form, similar to Apple Mail Rules
Use JQuery.append( html_fragment) to dynamically build & append your desired HTML elements, into the TD or DIV container where you need them. See: http://api.jquery.com/append/ and also jQuery document.createElement equivalent? For example: var prefix = "cond0"; var content = "<select name='"+prefix+"_field'>"; // generate select options here.. content += "</select>"; // var container = $( "#"+prefix); container.append( content); Hope this helps.

Categories : Jquery

Are adding weeks, months or years to a date/time independent from time zone?
Would the results in #1 and #2 always be the same? My money is for YES. I don't see any reason why they wouldn't be the same. From DateTime.ToLocalTime The local time is equal to the Coordinated Universal Time (UTC) time plus the UTC offset. The value returned by the conversion is a DateTime whose Kind property always returns Local. Consequently, a valid result is returned even if ToLocalTime is applied repeatedly to the same DateTime. From DateTime.ToUniversalTime The Coordinated Universal Time (UTC) is equal to the local time minus the UTC offset. Since AddDays, AddYears and AddMonths doesn't change based on TimeZone, there will be no problem.

Categories : C#

Run time controls needing data back on button click
Got it! Private genTmpLbl As New List(Of Label) Public Sub makeRunTimeControls() Dim tmpLbl As New Label Dim intX As Integer = 0 Do Until intX = 4 With tmpLbl .Size() = New System.Drawing.Size(58, 15) .Text = "Run-time Controls " & intX .Location = New System.Drawing.Point(2, 20) .Name = "test" & intX End With With Me.Controls .Add(tmpLbl) End With genTmpLbl.Add(tmpLbl) intX += 1 Loop End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click For Each label In genTmpLbl For Each control In Me.Controls If TypeOf (control) Is Label Then Debug.Print(control.Name

Categories : Vb.Net

What happens when more than one thread tries to update form controls using Invoke at the same time in Winforms?
Try it out! :) You'll find that neither of them can update the UI from a background thread, instead they need to use Control.BeginInvoke to invoke work on the UI thread, in which case they will execute in the order that they call BeginInvoke.

Categories : C#

Force context menu to recreate child controls each time it opens
I was able to quickly do this by creating a Style for the ContextMenu that sets its DataContext to null when it is hidden. This will cause the Bindings to re-run when it is opened, as they will have a new source. If you set the DataContext explicitly for the ContextMenu, you'll have to move that to a setter: <ContextMenu> <ContextMenu.Style> <Style TargetType="{x:Type ContextMenu}"> <Style.Triggers> <Trigger Property="IsOpen" Value="False"> <Setter Property="DataContext" Value="{x:Null}" /> </Trigger> </Style.Triggers> </Style> </ContextMenu.Style> <MenuItem Header="{Binding Color, Mode=OneTime}" /> </ContextMenu>

Categories : Wpf

Adding time to time saved in mysql through PHP
In PHP: $time30 = strtotime($row['date']) + (30 * 60); $now = time(); In MySQL SELECT *,timestampadd(minute,30,date)<now() as expired FROM list ORDER BY id DESC Then in the PHP you have $row['expired'] as a 1 or 0.

Categories : PHP

Adding Kinect cursor events to WPF Controls (Kinect SDK 1.7)
You may want to look at KinectInteraction in the Kinect for Windows Toolkit 1.7, which supports tracking hands in a physical interaction zone, etc. However, from your post it seems like it would be a better idea to read up on and experiment with the basics of events and event handling in C# and WPF first. These articles on MSDN may serve as a starting point: Events (C# Programming Guide) Events tutorial Events (WPF)

Categories : C#

DNN: Using multiple web user controls in one module and showing different controls in different pages
Astro, Option 1: You need to go to Host > Extensions > Edit your extesion > Expand Module definition and click on add control. Here you have to select your ascx control and provide key as any string. Let's say you provided key test, you selected user control and selected control type as view and saved it. Now from view you can use following code to navigate to the newly added control: DotNetNuke.Common.Globals.NavigateUrl(TabId,"test","mid="+ModuleID); This will redirect the page and load your page with test.ascx. You can use this kind of option when you want to show view.ascx by default and want to switch view when on some action and show test.ascx. Disadvantage here is, when you switch to test.ascx, all other modules added to page will not be visible. Option 2: You have to creat

Categories : C#

using custom controls instead of user controls to create complex views
Unless you need the functionality provided by custom controls, I would suggest using UserControls or DataTemplates. They are simpler. Here's a related questionanswer. WPF User Controls vs Custom Controls

Categories : Wpf

RaiseEvent between User Controls where there are multiple instances of the same controls on one page ASP.net
The solution I found to this problem is from an old article from 2002 on Code Project. Here's the link to that article ASP.NET User Controls - Notify One Control Of Changes In Other Control. After reading that article and looking through sample code, here are the following changes I made to the code above. There are no changes to the ASPX files except the following line in the Output ASPX file should be removed. <%@ Reference Control="~/Input.ascx" %> First you add a new class called LabelChangeEventArgs. Public Class LabelChangeEventArgs Inherits EventArgs Private _LabelStr As String Public Property LabelText() As String Get Return _LabelStr End Get Set(value As String) _LabelStr = value End Set End Pro

Categories : Asp Net

Opaque panel, over the top of other controls on form, some controls are drawing over it thought?
Try the .BringToFront() method on the panel, or the .SendToBack() on the controls that are over your panel. See MSDN Documentation. Usually, when you add a new control, its added in front of every other control of that parent.

Categories : C#

Difference between using XML for static controls and making controls programmatically?
There is no performance loss / the performance loss is negligible compared to the HUGE productivity / code cleanliness gained by doing things the RIGHT way. And XAML is not static. There is DataBinding, and if you need to add / remove items dynamically there is the ItemsControl. There is also the concept of DataTemplates that dynamically render specific UI depending on what Model / ViewModel objects are passed to it. Do not manipulate nor create UI elements in procedural code. WPF is not winforms.

Categories : C#

FireMonkey controls based on iOS controls do not behave correctly
For solution we should know: Each Firemonkey form bases on Native UIView, which is subview by root view in Main UIViewController. So when you insert control on a FireMonkey form, that control stay on Form's UIView. All standart Firemonkey Controls doesn't have Native UIView. FMX form have all FMX controls and manages them. Firemonkey WebBrowser bases on UIWebView and is displayed like a subview in a Firemonkey form's UIView. All Popup form are based on UIView with transparent background. Position of popup and size set throught properties TForm.Position, TForm.Size. So you can create a form with transparent background above on Form with TWebBrowser, set size and set position. For the solution of your problem you can: Create new form or popup form Set size and position for it. Show i

Categories : IOS

Adding A Title Every Time A number Changes
I'm not 100% sure how to do it with this template engine, but with regular PHP you could do something like $currentSeason = 0; foreach( $episodes as $key => $val ) { if( $val['season'] != $currentSeason ) { .. Show Title .... $currentSeason = $val['season']; } ... Show rest of information .... }

Categories : PHP

Adding data to two tables at the same time
For mysql (with auto_increment id in members table) it can be: START TRANSACTION; insert into members ... insert into admin ... (id, ...) values (last_insert_id(), ...); COMMIT; UPDATE After you provided structure an example is: START TRANSACTION; insert into members (Name, Username, Password, Level, Address, Phone) values ('name','username','password','level','address','12345') insert into techs (techID, price, company, comments, rate, qualification) values (last_insert_id(), 10, 'company', 'comment', 1, 'qualification'); COMMIT; Members.id will be created automatically because it's auto_increment field.

Categories : Mysql

adding and incrementing date and time (Postgresql)
SQL Fiddle update clip c set starts = s.starts, ends = s.ends from ( select starts, starts + clip_length as ends, file_id, position from ( select '2013-08-30 22:00:00'::timestamp + sum(clip_length) over(order by position) - clip_length as starts, clip_length, file_id, position from clip ) s ) s where c.file_id = s.file_id

Categories : SQL

rCharts - Adding second y axis to time series
This can be done in highcharts and most likely others. I have taken the nice work done here. A simplified version of that is: library(rCharts) h <- Highcharts$new() h$xAxis(categories = c('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) h$yAxis(list(list(title = list(text = 'Rainfall')) , list(title = list(text = 'Temperature'), opposite = TRUE) , list(title = list(text = 'Sea Pressure'), opposite = TRUE)) ) h$series(name = 'Rainfall', type = 'column', color = '#4572A7', data = c(49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4)) h$series(name = 'Temperature', type = 'spline', color = '#89A54E', data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21

Categories : R

Javascript Adding Time for a Future Date
If you want to add a number of weeks, just add 7 times as many days, e.g. var now = new Date(); // Add two weeks now.setDate(now.getDate() + 14); So if you have 24 fortnightly payments: var now = new Date(); // Add 24 fortnights (48 weeks) now.setDate(now.getDate() + 24 * 14); or now.setDate(now.getDate() + 24 * 2 * 7); whatever you think is clearest. If you want to have a start and end date: var start = new Date(); var end = new Date(+start); end.setDate(end.getDate() + 24 * 14); alert('Start on: ' + start + '. End in 24 fortnights: ' + end); Edit Here's a working example: <script> function calcLastPayment(start, numPayments) { if (typeof start == 'string') { start = stringToDate(start); } var end = new Date(+start); end.setDate(end.getDate() + --numPa

Categories : Javascript

Calculate the subtotal while every time adding a new row in JTable
There are probably a number of ways to do this and it will come down to your requirements about how you would finally achieve it, but to my mind, you want to minimize the number of iterations you need to perform over the table each time a new row is added... There's no point iterating over the entire table if only one row was added, for example. It's inefficient. Instead, you could use TableModelListener and listen for updates to the table model and update a running total (adding the new row values to already running total). import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java

Categories : Java

Add Date/Time when adding product to database
This can just be part of your database architecture: ALTER TABLE `products` ADD `created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP This will automatically add a timestamp to the column created whenever a row is created. For more information, try this: Automatic Initialization and Updating for TIMESTAMP Obviously, in this case the table is called products and you would need to change it to whatever your table name is. UPDATE To update all existing records at the same time, just run: UPDATE `products` SET `created` = NOW() If you want to be more specific use: UPDATE `products` SET `created` = NOW() WHERE `created` = '0000-00-00 00:00:00'

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.