w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
how to add picture box control and label control dynamically in list view control
Did you google around? There are lot of links that can help you http://geekswithblogs.net/dotNETvinz/archive/2009/04/24/faq-displaying-image-from-database-to-gridview-control.aspx http://weblogs.asp.net/aghausman/archive/2009/05/26/show-images-on-grid-view-from-file-stream.aspx http://www.codeproject.com/Articles/20782/Displaying-Images-from-a-Database-in-a-GridView http://www.codeproject.com/Articles/20971/Thumbnail-Images-in-GridView-using-C

Categories : Asp Net

How to add an html control inside a div or crate a new control beside another control
var myA=document.createElement("a"); would create an element, you can set it's text by myA.innerHTML and src with myA.src="http://www.google.com" To add it to the page you can do: document.getElmentById("mydiv").appendChild(myA); to remove: var As=document.getElmentById("mydiv").getElementsByTagName("a"); var a = As[As.length-1]; a.parentElement.removeChild(a);

Categories : Javascript

Setting values in a numpy arrays indexed by a slice and two boolean arrays
Slicing a numpy array returns a view, but boolean indexing returns a copy of an array. So when you indexed it first time with boolean index in a[slice_][indices][high_indices], you got back a copy, and the value 42 is assigned to a copy and not to the array a. You can solve the problem by chaining the boolean index: a[slice_][(a[slice_] > 700) & (b[slice_] > 0.5)] = 42

Categories : Python

Concatenate arrays from foreach loop into single variable of nested arrays
Use this: $allimagesizes[] = $imagesizes; Putting [] after the array name means to add a new element to the end of the array. Also, in the assignment to $imagesizes, you should use =, not .=. The latter is for appending to a string.

Categories : PHP

Ruby/Rails: Convert array of arrays to hash of arrays
a = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]] [:white, :black, :red, :blue, :yellow].zip(a.transpose) # => [[:white, [1, 6, 11]], [:black, [2, 7, 12]], [:red, [3, 8, 13]], [:blue, [4, 9, 14]], [:yellow, [5, 10, 15]]] Hash[[:white, :black, :red, :blue, :yellow].zip(a.transpose)] # => {:white=>[1, 6, 11], :black=>[2, 7, 12], :red=>[3, 8, 13], :blue=>[4, 9, 14], :yellow=>[5, 10, 15]}

Categories : Ruby On Rails

equals / Arrays.deepequals returns false on identical arrays
From the Javadoc: Two possibly null elements e1 and e2 are deeply equal if any of the following conditions hold: - e1 and e2 are both arrays of object reference types, and Arrays.deepEquals(e1, e2) would return true - e1 and e2 are arrays of the same primitive type, and the appropriate overloading of Arrays.equals(e1, e2) would return true. - e1 == e2 - e1.equals(e2) would return true. About the class of the objects you have in your arrays, make sure that overrides equals() and hashcode() properly. UPDATE Consult the Object javadoc, basically you need to add this to your class: @Override public boolean equals(Object other) { // Add here code to verifiy that this object is "equals" // to the method argument "other". // return true if they are equal or false oth

Categories : Java

create a PHP function that works for simple arrays and nested arrays
Try this: <?php /** * Applies callback function recursively to every element of the given array. * * If the array contains inner arrays or objects, the callback is also applied * to these. * * Caution: If $arrayOfObject is an object, only public members are processed. * * @param callback $func * @param array|object $array * * @return array */ public static function array_map_recursive($func, $arrayOrObject) { $array = is_array($arrayOrObject) ? $arrayOrObject : get_object_vars($arrayOrObject); foreach ($array as $key => $val) { $array[$key] = is_array($val) || is_object($val) ? self::array_map_recursive($func, $val)

Categories : PHP

How do I avoid recursively adding arrays when I need to merge two arrays in a while-loop?
Easiest way to "empty" every array at the end of each frame is just to set them as empty at the end of each loop: while game==True: #your game code goes here charArray,collideArray = [],[]

Categories : Python

Correct way to allocate and free arrays of pointers to arrays
I want to create an array of pointers to arrays of 3 floats. What is the correct way to do this? Why do you want an array of pointers to arrays? Wouldn't an array of arrays be sufficient? (Keep in mind that arrays are already pointer-like, they are not passed by value, rather the address of the first element is passed when an array is passed as an argument to a function). // stack allocation, no need to free float array[SIZE][3]; for (int i = 0; i < SIZE; i++) { // do something with array[i][0], array[i][1], array[i][2] } Then how would I free the data? In this case you wouldn't, since the data is stack allocated (will be cleaned up automatically once out of scope). Just remember the rule of thumb is that for every memory allocation you make, a corresponding free is n

Categories : C

VBscript gives out of range error with arrays within loop but not with arrays outside
The first line of your test file does not contain a comma, thus the array strValues has a single entry only during the first iteration. place an extra strLine = inputFile.ReadLine before the do while loop and you should be fine.

Categories : Arrays

Sort array of arrays according to child arrays count
For this case is enough to implement a simple comparator: NSArray* sortedArray= [array sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { return [obj2 count] - [obj1 count]; }]; Further explanation NSComparisonResult is this enum: enum { NSOrderedAscending = -1, NSOrderedSame, // 0 NSOrderedDescending // +1 }; So subtracting the two arrays counts you get the right order, avoiding to write the usual boring if-then-else. For readability and to don't confuse ideas to beginners I add the long version here: NSArray* sortedArray= [array sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) { if([obj1 count] > [obj2 count]) return NSOrderedAscending; if([obj1 count] < [obj2 count]) return NSOr

Categories : Objective C

Searching Multidimentional arrays to match keys of two arrays with Php
Ok, I'm assuming you want to add injuries to players. The output will be the list of players, with the injuries added (where they apply) $output = array_map(function($x) use ($array1) { $id = $x['id']; $valid = array_filter($array1['injuries']['injury'], function($injury) use ($id) { return $injury['id'] == $id; }); if(count($valid) > 0) { $x = array_merge($x, $valid[0]); } return $x; }, $array2['players']['player']); print_r($output); The output is this: Array ( [0] => Array ( [position] => TMDL [name] => Bills, Buffalo [id] => 0251 [team] => BUF ) [1] => Array ( [position] => TMDL [name] => Colts, Indianapolis [

Categories : PHP

C/C++ performance of static arrays vs dynamic arrays
As to which choice provides better performance, then the answer will largely depend on your specific circumstances. The only way to know if one way is better or if they are roughly equivalent is to measure the performance of your application. Some things that would be a factor are: how often you do it, the actual size of the arrays/data, how much memory your system has, and how well your system manages memory. If you have the luxury of being able to choose between the two choices, it must mean the sizes are already nailed up. Then, you do not need the multiple allocation scheme that you illustrated. You can perform a single dynamic allocation of your 2D array. In C: int (*array)[COLUMNS]; array = malloc(ROWS * sizeof(*array)); In C++: std::vector<std::array<int, COLUMNS>>

Categories : C++

object arrays inside knockout arrays
If you want to display students by teacher, something like this should work. Teacher = function (data) { var self = this; self.Id = ko.observable(data.Id || 0); self.Name = ko.observable(data.Name || ''); // See JSFiddle for mapping self.Students = ko.mapping.fromJS(data.Students, StudentMapping); return self; }; Student = function (data) { var self = this; self.Id = ko.observable(data.Id || 0); self.Name = ko.observable(data.Name || ''); return self; }; StaffViewModel = function (data) { var self = this; // See JSFiddle for mapping ko.mapping.fromJS(data, StaffMapping, self); return self; }; I'm using the original Knockout mapping plugin, but you could use the viewmodel plugin. If you'd like to display students and teachers i

Categories : Javascript

Difference between Arrays.sort() and Arrays.parallelSort()
Arrays.parallelSort() : The method uses a threshold value and any array of size lesser than the threshold value is sorted using the Arrays#sort() API (i.e sequential sorting). And the threshold is calculated considering the parallelism of the machine, size of the array and is calculated as: private static final int getSplitThreshold(int n) { int p = ForkJoinPool.getCommonPoolParallelism(); int t = (p > 1) ? (1 + n / (p << 3)) : n; return t < MIN_ARRAY_SORT_GRAN ? MIN_ARRAY_SORT_GRAN : t; } Once its decided whether to sort the array in parallel or in serial, its now to decide how to divide the array in to multiple parts and then assign each part to a Fork/Join task which will take care of sorting it and then another Fork/Join task which will take care of merging th

Categories : Java

Why do literal arrays work, but not coded arrays?
It seems likely that whatever you are passing to your constructor for labels and data is not in the correct form. For us to help identify exactly what your issue is, you will have to show us the code you are using to create those data structures. If you do it like this, it will reproduce what was in the sample code: // array of names var names = ["January","February","March","April","May","June","July"]; // array of objects var items = [ { fillColor : "rgba(220,220,220,0.5)", strokeColor : "rgba(220,220,220,1)", pointColor : "rgba(220,220,220,1)", pointStrokeColor : "#fff", data : [65,59,90,81,56,55,40] }, { fillColor : "rgba(151,187,205,0.5)", strokeColor : "rgba(151,187,205,1)"

Categories : Javascript

Arrays.compareTo for byte[] arrays in Java
The meaning of compareTo on an array depends on your use case. Thus it is not implemented in java.util.Arrays and because not every array contains comparable objects.. If you want to implement a compareTo Method on an array you have to answer the question: When is one array less than, equal to or greater than another array? If the array is a byte[] that is based on an ascii string it might be easy, but then you have a special use case. Take a look at these questions to understand what I mean: How would you compare an array of Comparables when you don't know much more about the elements than that they are Comparables? What kind of information do you get if you know that one array of Comparables is less than another array of Comparables because each element at the same index is l

Categories : Java

Removing specific Arrays out of multidimensional arrays
Okay I have two solutions. version1 is basic and could use some optimizing while version2 should be faster with bigger, evenly distributed lists. If you're only going to have a few items, use one. It only has a few lines of code, so it won't be a distraction. If you have a big array and it'll be pretty evenly distributed, then use two. I actually did a test with the sample data, and version2 has less iterations than version1. V1 ran 11 times in the outer loop, and 79 times in the inner loop. V2 ran 11 times in the first outer loop, 4 times in the second one. The inner loop of the second loop ran 11 times, and the loop inside that ran only 7 times. So the total iterations of v2 was about 40% of v1. When I double the items, v2 only uses 30% of the iterations. Version2 has a coupl

Categories : Javascript

Why are 1-dimensional arrays faster than Jagged arrays in C#?
Maybe because "Jagged Arrays" are array of pointers (to arrays)... In your example you have 4 levels of indirections: jagged[i][j][k][l] gets offset i from "jagged" gets offset j from previous result gets offset k from previous result gets offset l from previous result

Categories : C#

How can I use wildcards or regular expressions to control Path-based authorization / access control for svn?
as of June 2013 it is impossible to do this. So, the solution to the problem is to re-organize the repository so this isn't necessary. When a thing is too difficult it usually leads to a large rethink of the design or approach. At present maven structure leads to this requirement: root/pom.xml root/project1/pom.xml root/project2/pom.xml etc.. We can replace this with /root/pom.xml /project1/pom.xml /project2/pom.xml etc.. We can set the svn perms as follows granting all read access to the top level project and read write to their project. If an continuous integration build server populates an internal maven repo with the root snapshot then the users only need to checkout specific projects. [repo:/root] * = r @releng = rw [repo:/project1] @teamOne = rw [repo:/project2] @teamTwo =

Categories : Svn

Update parent control when the child control is manually removed in the designer
To wrap it up, I found a solution to my problem. Like a TabControl, my ButtonList contains two collections: ControlCollection inherited from the Control class ButtonListItemCollection (TabControl has TabPageCollection) Adding ButtonListItems is done via the collection editor in the properties. Removing can be done either in the collection editor or just by selecting the ButtonListItem in the designer and pressing the DEL button on the keyboard (manual deletion). When using the collection editor, ButtonListItems are added/removed to/from the ButtonListItemCollection and then to/from the ControlCollection. However, when a ButtonListItem is manually deleted it is only deleted from the ControlCollection not from the ButtonListItemCollection. So what needs to be done is to detect when the

Categories : C#

Tap event on dynamically added custom control is handled by another control of same type
I figured out the problem, and I am chocking it up to lack of experience with WPF. When I made my Waypoints I created them like to var newWaypoint = new Waypoint(waypointNumber, latitude, longitude); newWaypoint.Name = "wayPoint" + waypointNumber; newWaypoint.Opacity = 100; double leftMargin = CalculateLeftMargin(longitude); double topMargin = CalculateTopMargin(latitude); newWaypoint.Margin = new Thickness(leftMargin, topMargin, 0, 0); LayoutRoot.Children.Add(newWaypoint); The problem with that was that I was setting the Margin of the control. When I set the Margin it was actually stretching out my Waypoint so I was having Waypoints on top of Waypoints. After some research I came across this article Changing Position of an Element Programmatically in WPF which showed me how to prope

Categories : C#

Black lines when adding custom control to a panel with Control's DockStyle set to Top
Finally I found the solution to my problem. I was setting the Comment control's AutoSize property to true. When I set it false, it worked. Thanks @Sayse, your comment gave me hint about it.

Categories : C#

how to restrict child control inside Parent control in Winform application?
if you add the label to the panel dynamically then you must do: this.panel1.Controls.Add(this.button1); if you don't, that the mistake. On top of that, when you move the label, make sure that the new values are inside the range of the panel, using panel1.Location.X panel1.Location.Y and share your code for more help if needed

Categories : C#

jump to search result in a repeat control with a pager control in a xpages
A few pointers that might help you to go ahead: stop paging in repeats. The extlib has a nice sample of "show more", so instead of showing 1-20, 21-40 etc. you show until the record you found (might not work for large datasets) Open the search page with URL parameters that indicate the position number of the document (e.g. 498). Then use that parameter to let the repeat control figure out the starting position (which depends on the number of documents the repeat is configured for (default is 30, but you don't know). Just make sure not to use the passed parameter unchecked. you can add <a name="[unid]"> (or id=) tags to the repeat and then [directly navigate] (http://reference.sitepoint.com/html/a) to them ....nsf/searchResults.xsp#unid?moreParameters Let us know how it goes

Categories : Misc

Button sizes changing on user control when control is added to window
You have don't have your LastChildFill property set to False on your top DockPanel. This is the reason "Ent" is changing size and moving your screen. You also have the HorizontalAlignment on "Del" set to stretch. Try setting that to Left, but might be moot with the LastChildFill correction. The overall resizing is do to HorizontalAlignment set to Stretch set that to Left.

Categories : Wpf

Border doesn't inherit Control, so how does a setter on Control.Background work?
Background dependency property in WPF is shared by many classes. It is defined in the Panel class, other classes just call AddOwner on it. Border.cs [CommonDependencyProperty] public static readonly DependencyProperty BackgroundProperty = Panel.BackgroundProperty.AddOwner( typeof (Border), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.SubPropertiesDoNotAffectRender)); Panel.cs [CommonDependencyProperty] public static readonly DependencyProperty BackgroundProperty = DependencyProperty.Register("Background", typeof(Brush), typeof(Panel), new FrameworkPropertyMetadata((Brush)null, FrameworkPropertyMetadataOptions.AffectsRender |

Categories : Wpf

adding Control to form but gap keeps doubling when added at Bottom of previous control
this is more of a hack but it works. sharpUserX.Size = sharpUserSize PnlSharpUsers.Controls.Add(sharpUserX) sharpUserX.Location = pnlAddBtn.Location if i set the size before i add the control, then set the location after it seems to apply the font scaling to the size, but not the location, which works perfectly for me.

Categories : C#

ms-access 2007 form datetime control : if control length smaller than the size of the value it shows ###
Access doesn't behave like this. You can either increase the width of the control (the best solution) specify a shorter Format for the date reduce the font size An odd approach would be to add a label which obscures some of the date-control, but such that you can still see part of the date in the background. You might consider using an event such as Focus to change the Format of the control, but this won't work as the Format only applies when you move away from the control. You could, I suppose, use two controls; one for display and one for editing.

Categories : Forms

Access Parent Page Control in Child User Control
You will have something like this in tab control. <cc1:TabContainer ID="TabContainer1" runat="server"> <cc1:TabPanel ID="TabPanel1" runat="server"> <ContentTemplate> <asp:DropDownList id="dropdownlist1" runat="Server"/> </ContentTemplate> </cc1:TabPanel> So first you need to find tabPanel1 then find dropdownlist1 like following. TabContainer TabContainer1= (TabContainer)(this.Page.FindControl("TabContainer1"); if (TabContainer1!=null){ TabPanel TabPanel1= (TabPanel)(this.TabContainer1.FindControl("TabPanel1"); if(TabPanel1 !=null){ DropDownList dropdownlist1= (DropDownList)(this.TabPanel1.FindControl("dropdownlist1"); }}

Categories : C#

How to copy an ActiveX control over to another sheet preventing the name change of the control
ActiveX You can copy an ActiveX Control from one sheet to another with the below code. Note: you cannot have two objects of the same name on one spreadsheet. Sub CopyActiveX() Application.ScreenUpdating = False Dim x As OLEObject, y As OLEObject Set x = Sheets("SRC").OLEObjects("HasCustomName") Set y = x.Duplicate Dim xName As String xName = x.Name y.Cut With Sheets("TRGT") .Paste .OLEObjects(.OLEObjects.Count).Name = xName .Activate End With Application.ScreenUpdating = True End Sub Form Control To copy a button from one sheet to another preventing the automatic name change use the below code. Excel by default gives a new name to a copied button (even on a different sheet) so you have to rename it to match the name o

Categories : Vba

I can not display binding value of a custom control's property when control loads
Try binding SelectedItem property to ControlTemplate <ScrollViewer x:Name="PART_ContentHost" Content={TemplateBinding SelectedItem} SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="Stretch"/>

Categories : Dotnet

How to make binding from user control to property of parent control?
ElementName binding works within in same XAML scope. This will work - <Grid> <CheckBox Name="checkBox1"/> <Label Content="{Binding ElementName=checkBox1, Path=Name}"/> </Grid> But if you want to do it in different UserControl, you have to tweak a bit your code and use Tag to hold name - <Grid> <CheckBox Name="checkBox1"> <local:UserControl1 Tag="{Binding ElementName=checkBox1, Path=Name}"/> </CheckBox> </Grid> UserControl.xaml <Canvas> <Label Content="{Binding Path=Tag, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"/> </Canvas> On a sidenote, in your UserControl, you know you need to bind with ElementName = checkBox1 and that's

Categories : Wpf

Custom Control: Scripts not loaded when control is hidden on pageload
I had a very similar problem earlier and came across your question. I was loading javascript for my custom control by overriding the OnPreRender method. protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); Page.ClientScript.RegisterClientScriptInclude("MyJavascript", "MyURL"); } This had worked when using the control in a normal page environment, but in this case I was using it inside an update panel and initially hiding it. Ajax post backs from the update panel would then update the Visible property to true. At this point of course ASP.NET has no opportunity to automatically inject the client script into the <head> of the page. The solution Instead of overriding OnPreRender you can override OnInit (which should always fire even when t

Categories : C#

Custom control events don't fire when control collection is cached?
The reason this doesn't work is because the controls must be recreated on the post back, and events wired up, for them to fire. See, since the server is stateless, to fire an event on an object, that object needs recreated AND readded to the form. How about cache the database result instead and continue the loop otherwise to build new, add, and hookup the controls?

Categories : C#

How can I bind a parent control's TextBox from inside a user control
You can declare the DataContext property of the <TextBlockControl /> as the Text property of the "editor" <TextBox />: <wpfSandbox:TextBlockControl DataContext="{Binding Text, ElementName=editor}" /> and inside your control: <Grid> <TextBlock Text="{Binding}" /> </Grid>

Categories : Wpf

How to access the main page control values in user control
To retrieve, for example, a textbox defined in the aspx page from an ascx control contained in it you could try: Dim myTextBox As TextBox = Ctype(Me.Parent.FindControl("myTextBoxName"), TextBox) Note that the control you want to retrieve must have a runat="server" attribute otherwise it can not be seen server side. In your question you posted three controls without runat="server"; you could use instead: <asp:HiddenField ID="HiddenField1" runat="server" Value="1" /> <asp:HiddenField ID="HiddenField2" runat="server" Value="2" /> <asp:HiddenField ID="HiddenField3" runat="server" Value="3" /> In this case the above command would become: Dim myHiddenField As HiddenField = Ctype(Me.Parent.FindControl("myHiddenFieldName"), HiddenField)

Categories : Asp Net

FlowLayout Control With User Control Item Template Not Binding
Try: public UserControl2() { InitializeComponent(); Loaded += (sender, args) => { var obj = (ViewMod)this.DataContext; if (obj == null || obj.Prop == null) return; var d = obj.Prop; if (d == null) return; grd2.Children.Add(new TextBlock { Text = d.Name }); }; } DataContext is not set instantly. Hence we use the Loaded event and add a lambda to it to do your corresponding steps. side-note: even-though this works, please do search and look at some MVVM examples. While having no code-behind is not really an MVVM requirement, I think your taking it a bit too far adding Grid children and stuff from code-behind when you can do it perfectly fine from xaml.

Categories : C#

Find radio button control in nested repeater control in asp.net?
I found the answer. Thanks foreach (RepeaterItem repeater in TabRepeater.Items) { Repeater repeater1 = (Repeater)repeater.FindControl("ContentRepeater"); foreach (RepeaterItem repItem in repeater1.Items) { for (int i = 1; i <= 4; i++) { string rdboption = ds.Tables[0].Rows[c][0].ToString() + "_" + ds.Tables[0].Rows[i - 1][2].ToString() + "_" + "Option" + i + "_" + i; PlaceHolder PlPreview = (PlaceHolder)repItem.FindControl("PlPreview"); rbt = (RadioButton)PlPreview.FindControl(rdboption); if (rbt.Checked) { // statement } } }

Categories : Asp Net

Edit Control showing a readout of Slider Control's position
What happens if you try extracting the position of the slider directly with GetPos rather than using the nPos parameter?

Categories : Windows



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