w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Painting on Windows Forms Control with System.Drawing.Graphics
You're wanting to override OnPaint(PaintEventArgs e) in your custom control. This will give you access to the System.Drawing.Graphics (through e.Graphics) object that you use to do custom painting on your control. Graphics gives you access to a ton of methods you can use to do the painting you need. Example: public class MyControl : Control { // ... protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); // Important - makes sure the Paint event fires using (var pen = new Pen(Color.Black, 3)) { e.Graphics.DrawRectangle(pen, 0, 0, this.Width, this.Height); } } }

Categories : C#

Align two chart areas windows forms
something like this maybe? if (this.chrtMain.ChartAreas.Count > 0) { ca.AlignmentOrientation = AreaAlignmentOrientations.Vertical; ca.AlignWithChartArea = this.chrtMain.ChartAreas[0].Name; } All chart areas will be aligned as they are added this way.

Categories : C#

Adding Sharepoint List Item to Windows form list
Completely untested, made fresh while drinking morning coffee. Good luck! var list = siteWeb.Lists.TryGetList(listName); if (list == null) { return; } var items = list.GetItems(query); var countOfItems = items.Count; if (countOfItems == 0) { return; } var listItemFieldObjects = items.Cast<SPListItem>().Select(item => item[1]); foreach (var item in listItemFieldObjects) { var listViewItem = new ListViewItem("Object's value"); listView.BeginUpdate(); listViewItem.SubItems.Add(item.ToString()); listView.Items.Add(listViewItem); listView.EndUpdate(); }

Categories : Sharepoint

C# StripLine (chart) drawing by click onto the chart
a working solution is: for (int j = 0; j < chartSettlingCurve.ChartAreas[0].AxisX.StripLines.Count; j++) { if (chartSettlingCurve.ChartAreas[0].AxisX.StripLines[j].Tag.ToString() == "end") { chartSettlingCurve.ChartAreas[0].AxisX.StripLines.RemoveAt(j); j--; } } or as an alternative: bool loop = true; while (loop) { loop = false; foreach (var element in chartSettlingCurve.ChartAreas[0].AxisX.StripLines) { if (element.Tag.ToString() == "end") { chartSettlingCurve.ChartAreas[0].AxisX.StripLines.Remove(element);

Categories : C#

call a Windows Forms method from outside Windows Forms (from int WINAPI WinMain)
it looks like 'Application::Run(myInterface);' does not return until it is done doing what it has to do, which is nothing It's not nothing. Application::Run most importantly starts the Windows event message pump. This event loop is what keeps your application alive and running. Application::Run will return only when this loop exits. The event loop generally exits when you close your main form or try to close the process from task manager etc. Which means by the time Application::Run returns, your myInterface form is already closed - which makes rest of the code below it useless. You can move that code to something like Form's Load event.

Categories : C++

drawing lines from a list in pygame
Consider what happens if your loop takes, say, 23 milliseconds to run. So, the first time you call get_ticks, you get 0. Then you get 23, 46, …, 989, 1012, …, 1978, 2001, …, 2990, 3013, …, and so on. It'll be 23 seconds before you hit the first number divisible by 1000! Of course in real life, your loop time isn't constant, but highly variable, but you have basically the same problem. The right way to solve this is to reorganize your program around either an event loop, or a fixed frame-rate loop. With an event loop, you can just use set_timer to fire an event once/second. Also, instead of redrawing and flipping the screen as fast as possible even when nothing is happening, burning up 100% CPU constantly and maybe even making your game sluggish to respond to events, you'll only

Categories : Python

Can List.Distinct() apply to the list type of List>?
That's because List<T> has no Equals and GetHashCode implemented, so standard reference comparison is being performed. And it returns false, because you have two separated lists. You can write your own IEqualityComparer<List<string>> implementation and provide it as Distinct method parameter. Within the comparer you can use Enumerable.SequenceEqual) method to check if lists has the same content.

Categories : C#

DirectX 9 Triangle List drawing through itself, how do I set up a depth buffer?
The problem was I forgot to clear the zbuffer in the device.Clear call: device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.SlateGray, 1.0f, 0); and now it works!

Categories : C#

get list of logged on users on remote windows computer from a list computer
It (csv file) should be formatted as follows: computername server1 server2 server3 'Computername' is the column name. This can be derived from the code snippet as the Foreach-Object refers to the ComputerName property.

Categories : Windows

Flask forms fields into an ordered list
Simplest way is to use the Jinja dictsort filter {% for field in wtfForm._fields|dictsort %}

Categories : Python

How to populate listbox with a list of all open forms
My.Application.OpenForms is a collection of the open forms in your project. So something like: For Each f As Form In My.Application.OpenForms Me.SomeListBox.Items.Add(f) Next Then to close the selected item, it’s DirectCast(Me.SomeListBox.SelectedItem, Form).Close()

Categories : Vb.Net

How to create a list of fields in django forms
Of course you can! class MyForm(forms.Form): def __init__(self, *args, **kwargs): super(MyForm, self).__init__(*args, **kwargs) for i, q in enumerate(Question.objects.all()): self.fields['%s_field' % i] = forms.CharField(max_length=100, label=q.questionText) Note: make sure your questions are ordered between calls.. as the field list will be repopulated upon form submission, receipt, etc. If the data is ordered and static, it won't be a problem. Also you may want to look into FormSets, a list of forms which may be more fitting in your case.

Categories : Python

List of Nested Models in Backbone-Forms
I have never used Backbone-Forms before. But If I wanted to implement this without using this plugin I would go about this way. I would have 2 Models and 2 Collection. Models Bar Foo Collections Bars Foos I would have a parse method in Bar model that creates a Foo collection for each Model. Views MainView (Passed in a Bars Collection) and Rendered BarsListView (Created from MainView passed in the Bar Collection) BarView (Passed in Bar Model) FooListView (Passed in Foo Collection) FooView (Passed in Foo Model) Something in these lines.. This is just a rough example // Models var Foo = Backbone.Model.extend({}); var Foos = Backbone.Collection.extend({ model : Foo }); // Collections var Bar = Backbone.Model.extend({ initialize: function() { if(ty

Categories : Javascript

Trying to get a dynamic select list using Drupal Forms API
Yes, you need to generate your options array dynamically before the $form['selected'] array definition like this: $myOptionsArray = myOptionsCallback($param1, $param2); $form['selected'] = array( '#type' => 'select', '#title' => t('Selected'), '#options' => $myOptionsArray, '#default_value' => $category['selected'], '#description' => t('Set this to <em>Yes</em> if you would like this category to be selected by default.'), );

Categories : Drupal

Creating a list of forms with a prefix. Help to simplify
For a list of identical forms, you should use a formset (or a model formset).

Categories : Python

Add array of options as checkbox list to Symfony 2 forms
You're adding multiple fields instead of just the options. You should modify the choices or choices_list option of your items field instead. See the documentation for choice field-type. The choice field will render checkboxes if the multiple option is set to true

Categories : PHP

iterating list of array-list and assigning each list to single dynamically created div in jsp
Try this, <c:forEach var="user" items="${userList}" varStatus="count"> <div id="col${count}"> <c:out value="${user.name}"/> </div> </c:forEach>

Categories : Java

In a responsive site design, how do i put a list below other list that contains a sub-list without overlap the main lists
Pretty simple : remove the fixed height of your li.menulinks, add a "header" (green rounded rectangle with 35px height) div as first child of the li and...you're set ! Look at this fiddle : http://jsfiddle.net/32pga/ <div class="sitemap"> <div class="row-fluid"> <ul> <li class="menulinks"> <div class="menulinks-header"></div> <ul> <li class="submenulinks"> <div>Test 1</div> </li> <li class="submenulinks"> <div>Test 2</div> </li> <li class="submenulinks"> <div>Test

Categories : HTML

Python: given a list of lists, create a list ordered by the number of occurrences in inner list
You can use collections.Counter to keep a counter for each element inside each sublist. Something like this, >>> from collections import Counter >>> lst = [['a','b','c'], ['a'], ['a','b']] >>> counts = Counter() >>> for sublst in lst: ... for ele in sublst: ... counts[ele] += 1 ... >>> [ele for ele, _ in counts.most_common()] ['a', 'b', 'c']

Categories : Python

How to pass list values to the jqplot to get the stacked bar chart
$(document).ready(function(){ var s1 = [3.42, 3.68, 3.64, 3.76, 3.75, 3.54,4.14,3.95, 3.84, 4.04, 4.29, 4.19,4.09,3.77, 4.82, 4.49, 4.42, 4.85,3.98, 3.97,4.19, 4.12, 4.09, 4.16, 4.38, 4.33, 4.43, 4.03, 4.25, 3.86, 4.16]; var s3 = [1200.48, 1604.94, 1431.20, 1335.72, 1266.45, 1308.25, 1698.32, 1464.18, 1461.53, 1502.08, 1369.72,1316.11, 1260.54, 1535.39, 1925.02, 1890.05, 1658.61, 1560.57,1574.59, 1682.91, 2025.93, 2019, 1645.09, 1801.57, 1812.67, 1818.51, 2130.70, 1803.06, 1926.22, 1630.69, 1570.69]; var s2 = [351, 436, 393, 355,338,370,410,371, 381, 372, 319,314,308,407,399, 421, 375, 322,396,424,483,490, 402, 433, 414,420,481,447,453,422,378]; var axisDates = ["Jan 1", "Jan 2", "Jan 3","Jan 4","Jan 5","Jan 6","Jan 7", "Jan 8","Jan 9","Jan 10","Jan 11","Jan 12","Jan 13","Jan 14","Jan 15",

Categories : Java

How can I bind an axis of a chart to a specific index of a List()?
The easiest way I think to do this would be to add a property in your class which would be the int value of the List. e.g. int val { get { return ByteCount[0]; } } Or you could also create a converter which would take the list as binding and the index as parameter, and return the desired value. For example (I haven't tried this): public class ElementOfListConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is IList && parameter is int) { var lst = value as IList; int pos = (int)parameter; if (lst.Count >= pos) { return lst[pos]; } } return null; }

Categories : C#

How to list all forms of solution explorer in property of custom control?
so that the project programmer can specify which form will be open when login successful That really is not the task of your usercontrol. Maybe the programmer wants to do something else upon a successful login. Create a LoggedIn event which you fire upon a successful login, and subscribe to that event from the code where you use the control. The programmer can then, in that event handler, do as he or she desires.

Categories : C#

SharePoint Custom Display and edit list item forms
Go on just like what SharePoint does in order to show item data. Both display forms and edit forms start by reading the query string value "ID": string strItemId = Request.QueryString["ID"]; You can add some validations to check if the query parameter exists and if it is actually a number and if an item actually exists in that list with the given ID. Finally, store valid itemId in an integer variable and retrieve the item as follows: SPListItem item = myList.GetItemByID(itemId); Continue to fill in the controls (labels in case of display forms and text boxes, drop downs, ... in case of edit forms) with item fields as below: txtTitle.Text = item["Title"] + String.Empty; You will then need to set item fields for the edit form on save button click event and then update the item.

Categories : Sharepoint

How to modify the style in list(ordered list and unordered list) in HTML?
Here you go. WORKING DEMO The HTML: <ul style="list-style-type:decimal;"> <li>First</li> <li>Second</li> <li>Third</li> </ul> The CSS: li{ position: relative; } li:before{ position: absolute; left: -13px; content: ')'; background:white;} Hope this helps.

Categories : HTML

Why does Haskell let me return an empty list where a list inside a list is expected?
Because [] is of type [[a]] in this case: it is a list containing exactly 0 alpha lists. In general, the empty list can match any list type because every element (all zero of them) is of the correct type.

Categories : Haskell

Adding new item to a listItem (drop down list) on google Forms using apps script
Use getChoices() to get a copy of the existing list and append the choice. choices = listItem.getChoices(); choices.push(listItem.createChoice('black')); listitem.setChoices(choices);

Categories : Google Apps Script

.NET MVC / Editing List of complex types, adding additional edit forms using AJAX
Don't you just need a controller to make the insert, and an ajax handler to render the result to the page? Without more code, it is hard to say exactly how you should do this. You could also use knockout or backbone to "observe" the variables and update/add template HTML in place. Then you just pass in a new view model, and when you get the one back (with a primary key etc.) you render that in your view.

Categories : C#

How to assign List or List to List
I don't think there's an easy way to do that using only strongly typed collections1, since there is no covariant collection interface that exposes a Remove method... I see 2 possible solutions: use the non-generic ICollection interface, that is implemented by List<T>: var collection = (ICollection) CouldBeBearsOrGoats; collection.Remove(whatever); The drawback is that a collection that implements ICollection<T> might not implement ICollection... use dynamic: dynamic collection = CouldBeBearsOrGoats collection.Remove(whatever); But it's probably slower than the previous approach. 1 assuming you don't want to change the actual type of the collections by casting items to IAnimal

Categories : C#

create a list from another list and remove elements from copied list
Yes your understanding is correct. List newList = new ArrayList(collection); will do a shallow copy. You can modify the newList without affecting the original collection, but they will each reference the same elements so if you modify an element in one list, the other list's element will also get the change. This is called a Shallow Copy. Here's a visual representation of what I've described: The things at the bottom are the objects in your array.

Categories : Java

Unmarshall xml list of objects to java list without class list
You could use JAXB with StAX to do the following: import java.util.*; import javax.xml.bind.*; import javax.xml.stream.*; import javax.xml.transform.stream.StreamSource; public class Demo { public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(User.class); XMLInputFactory xif = XMLInputFactory.newFactory(); StreamSource xml = new StreamSource("src/forum17047306/input.xml"); XMLStreamReader xsr = xif.createXMLStreamReader(xml); List<User> users = new ArrayList<User>(); Unmarshaller unmarshaller = jc.createUnmarshaller(); while(xsr.getEventType() != XMLStreamReader.END_DOCUMENT) { if(xsr.isStartElement() && "User".equals(xsr.getLocalName())) {

Categories : Java

Appending to create a list instead of creating a list inside a list
Use extend: for item in items: forename = re.findall(pattern2, item) surname = re.findall(pattern3, item) mainlist.extend(surname) myList.extend(L) adds the individual elements of L onto myList. It's similar to: for element in L: myList.append(element)

Categories : Python

In python, what happens, will the length of a list decrease if I add part of the list to another list?
The string "hi" will be split into chars and assigned to example when you do example+=python[0] So example in this case will contain ['h','i']. Also, the list python will not lose an element.

Categories : Python

What kind of List is List list = Database.getAllData();?
You don't have to know; that's the point. The interface is what matters to you, not the implementation. You can't know without looking at the source of that method. But even if you do, it's immaterial to your client. All you call are List methods.

Categories : Java

Create larger list from an existing list using a list comprehension or map()
How about: >>> atom_indices = [0, 4, 5, 8] >>> coords = [3*a+k for a in atom_indices for k in range(3)] >>> coords [0, 1, 2, 12, 13, 14, 15, 16, 17, 24, 25, 26] We can nest loops in list comprehensions in the same order we'd write the loops, i.e. this is basically coords = [] for a in atom_indices: for k in range(3): coords.append(3*a+k) Don't be afraid of for loops, though, if they're clearer in the situation. For reasons I've never fully understood, some people feel like they're being more clever when they write code horizontally instead of vertically, even though it makes it harder to debug.

Categories : Python

Why does adding a list to another list, using add range, remove the elements from the first list?
It's because of the IEnumerable. When you set groupsToAdd to the result of groups1.Where(g => false == groups2.Contains(g)) there is deferred execution, which means that the query is not run until AddRange() and then again at Dump(). Because the list, groups2, now contains the elements they no longer are a result of the original query.

Categories : C#

when appending a list with math using another list, how do i make the second list the same length as the first ?
You need to iterate over each elements in start_list: for item in start_list: # for each element in `start_list` square_list.append(item ** 2) # add square of `item` in `square_list` square_list.sort(); # finally sort the list or you can use sorted() function over generator expression: >>> sorted(item ** 2 for item in start_list)

Categories : Python

Getting a list of values from a list of dict in python: Without using list comprehension
You could use map() here. map() applies the lambda to every item of testList and returns it as a list. >>> testList = [{'id': 1L, 'name': u'Library'}, {'id': 2L, 'name': u'Arts'}, {'id': 3L, 'name': u'Sports'}] >>> map(lambda x: x['name'], testList) [u'Library', u'Arts', u'Sports']

Categories : Python

Dropdown select list won't display items with custom forms of Zurb Foundation 4 and Rails 4
Ok, so I just figured out that I have repeated asset load on my browser. This is causing a javascript error. It appears that deleting in the manifest //= require turbolinks Solves the problem. I solved my multiple asset problem changing <%= javascript_include_tag "application" %> To the head in my application layout. After watching the turbolinks railscast I noticed that besides my multiple asset loading, turbolinks and foundation 4 may not be compatible, it might be a solution on this post. But still doesn't work perfect for me. I also noticed that navbar is also affected by turbolinks. I think that this is rather a turbolinks problem and not an specific foundation dropdown. I will close this question and open a new on turbolinks and foundation.

Categories : Ruby On Rails

Where should I put chart-drawing code in Rails?
If you think you might reuse the charting code for other things, make it a class, put it in lib and set it up so you can do something like this in your controller: @chart = MyChart.new(:data => @my_object.data_method, :title => 'Foo Chart', ....) send_data @chart.to_svg, ... .. This way you can extend it with other options, add .to_png, etc without mucking up your model.

Categories : Ruby On Rails

List within a List - How to put new line with LinQ after List within List is over?
Console.Write( String.Join(Environment.NewLine, f.Select(flight => { var segments = flight.Segments.Where(x => x.DepartureDate > DateTime.Now); return String.Join(" ", segments.Select(segment => { return String.Format("Departure: {0}, Arrival: {1};", segment.DepartureDate, segment.ArrivalDate)); }); }); ); I personally prefer to have a Joined extension method on IEnumerable<T> which wraps String.Join (taking a delimiter and an optional transformation delegate), and a Formatted extension method on String which wraps String.Format: var output = f.Joined(Environment.NewLine, flight => flight.Segments .Where(s => s.DepartureDate > DateTime.Now) .Joined(" ", s => "Departure:

Categories : C#



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