w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
In c#, my datagrid is not showing the rows
I don't know what is going on in that Convert method, but, see this link about how to use a SqlDataReader: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.aspx Should be something like this: List<IDataRecord> records = new List<IDataRecord>(); while(re01.Read()) { //add record to list records.Add((IDataRecord)re01); } //records now has your list of data. re01.close();

Categories : C#

How to clear DataGrid rows
You can use the following code to get the desired result do { foreach (DataGridViewRow row in DataGrid_A.Rows) { try { DataGrid_A.Rows.Remove(row); } catch (Exception) { } } } while (DataGrid_A.Rows.Count > 1);

Categories : Dotnet

Add rows of comboboxes to datagrid
Simply bind the combobox column's element and editing styles to your list. This example binds it to a list in the window.cs file. public partial class MainWindow : Window { public List<string> ProductNamesList { get; set; } public MainWindow() { InitializeComponent(); ProductNamesList = new List<string>(); ProductNamesList.Add("Hamburger"); ProductNamesList.Add("Uranium"); ProductNamesList.Add("Toothbrush"); } } <DataGridComboBoxColumn Header="Products" SelectedValueBinding="{Binding ProductName}"> <DataGridComboBoxColumn.ElementStyle> <Style TargetType="ComboBox"> <Setter Property="ItemsSource" Value="{Binding Path=ProductNamesList, RelativeSource={Rel

Categories : Wpf

Add DataGrid checkboxcolumn with different values in different rows
I would recommend to use EditCellTemplate but it is up to you and task requirements. In the combobox in the DataTemplate use custom IValueConverter (I have used PlacementHeader as dependand property, you can use what actually needed or PlacementData itself): <ComboBox SelectedValue ="{Binding P_Unit}" ItemsSource="{Binding PlacementHeader, Converter={StaticResource DependedValuesConverter}}"> </ComboBox> and some sample of converter just like idea: public class DynamicValuesConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null) switch (value.ToString()) { case "Based On Injection Rate": ret

Categories : C#

Adding rows to DataGrid through XAML
Feeling lucky. Found it myself. Here's the simplest way. Create a dummy class with the same public properties (important that you define members as properties and not fields). For example: public class Dummy { public string Subject { get; set; } public string Body { get; set; } public DateTime DueDateStart { get; set; } } Import your project namespace into XAML by adding the following import at the top: xmlns:local="clr-namespace:YourProjectNamespace" Now you can add items (rows) to your DataGrid at design-time like: <DataGrid AutoGenerateColumns="False"> <DataGrid.Columns> ... </DataGrid.Columns> <local:Dummy Subject="Subject 1" Body="Body 1" ... /> <local:Dummy Subject="Subject 2" Body="Body 2" ... /> </Dat

Categories : Wpf

VB.NET-A way to insert rows into datagrid or datatable
If I understand your question which isn't very clear, the user is entering values that you want to query against rows in your database and if they exist, display some corresponding data or message. It sounds like what you want to do is bind your datagrid to a datasource, in my example an in-memory datatable, then intercept the data binding via DataGridView1.CellFormatting to compare/modify your data accordingly. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim sqlConnection As SqlConnection Dim sqlConnectionString As String = "YourConnectionString" Dim sqlDataAdapter As SqlDataAdapter Dim dataTable As New DataTable Dim sqlCommand As SqlCommand Dim sqlString As String Try sqlString = "SELECT * FROM YourTable" 'if u

Categories : Vb.Net

WPF Datagrid - How to make a change in one row affect other rows
Based on a Previous Answer: Use this as your data items: public class Selectable<T>: ViewModelBase //ViewModelBase should Implement NotifyPropertyChanged. { private T _model; public T Model { get { return _model; } set { _model = value; NotifyPropertyChange("Model"); } } private bool _isSelected; public bool IsSelected { get { return _isSelected; } set { _isSelected = value; NotifyPropertyChange("IsSelected"); if (OnIsSelectedChanged != null) OnIsSelectedChanged(this); } } public Action<Selectable<T>> OnIsSelectedChanged; } Then change your ViewModel to look like so: public class DataGridViewMo

Categories : C#

How to get all the row indices when I select datagrid rows using shift key?
Use the selectedIndices property. It will give a Vector; which is like a Typed Array. If you really need an ArrayCollection you can write a conversion routine. If you're using Apache Flex, there is also a VectorCollection class you could use.

Categories : Actionscript

Button Click Selects all checkboxes in DataGrid Rows in WPF
In the button handlers for your buttons you need the following code: foreach (var item in dataSource) { item.Checked = true; // or false for ClearAll } You change the values in the source data and the UI will update to reflect that change.

Categories : Wpf

Drag and drop of rows primefaces datatable/datagrid?
As far as i know from datatables (primefaces) in my applications, they have 2 main states/modes. It may be not the correct word but i stay with it. The 1st is display only, and 2nd editing. (In display i dont see events triggering so DnD wont work.) in editing they have a serious issue with selectivity. u have to press at the edge of the table and not in inline components reach to get the focus on the row. So The drop must be done in that area and only propably for events to trigger. If u see the examples...all drops are made on an outer component(panel etc) and the table is just updated because the ondrop event in ajax has run and changed the data the drop table will contain. That may be magic for incrementing data...but not for rearranging and updating cell or row data. SO the answer for

Categories : JSF

Saving new DataGrid Rows including DataGridComboBoxColumn Selection back to Entity Set
I think you need use dynamic binging in cs file. 1)If you create binding in cs file, you can pass oject to binding's converterParameter. You can pass ComboxColumn to converter. 2)Use column element to get current selected series id & DataContext(ContactArrangement), and get parent control's DataContext(PNSery collection). 3)use foreach to enum currect PNSery object and assign to ContactArrangment oject.

Categories : Wpf

DataGrid with small rows and no data after binding to the ItemSource with LINQ query
I suppose you should use properties instead of fields. Check the examples on MSDN public class OrderSummary { public int OrderId { get; set; } public DateTime OrderDate { get; set; } public int CustomerId { get; set; } } The second thing you may try - specify the dgrOrders DataContext, not the ItemSource.

Categories : SQL

Sort rows by clicking in the column header DataGrid with AutoGenerated columns and IEnumerable ItemsSource
Why not cast first, then convert? var ienum = (IEnumerable<object>)methodQuery.Invoke(instance, parameters); dataGrid1.ItemsSource = ienum.ToList(); (Also only use as if you are checking for null afterwards)

Categories : Wpf

DataGrid Updating for Added Rows but not for Added Columns
When adding columns you need to repaint the datagrid, reset your DataGrid.ItemSource should do it. VIEW: public SomeView(IViewModel vm) { ViewModel = vm; DataContext = ViewModel; InitializeComponent(); ViewModel.PropertyChanged += (s, e) => { switch (e.PropertyName) { case "IsResetingColumns": if (!ViewModel.IsResetingColumns) { dataGrid.ItemsSource = null; dataGrid.ItemsSource = ViewModel.Resources; } break; } }; } VIEWMODEL: public class ViewModel : INotifyPropertyChanged { private bool _isResetingColumns; public bool IsResetingColumns { get { return _isResetingCol

Categories : C#

Changing a cell in a row of a DataGrid(WPF) is changing cells in rows below
Try using this: <DataGrid Name="SimpleDataGrid" ScrollViewer.CanContentScroll="False" ... /> for scrolls in terms of physical units. It DataGrid CanContentScroll it is enabled by default. For more information see MSDN.

Categories : C#

DataGrid edition 'EditItem' is not allowed for this view` when bound to a WPF DataGrid
I tried this and the problem is that you have initialized your Level2 collection as Hashset<>. IEditableCollectionView.EditItem() throws this error while trying to update item in Hashset<>. I initialized the collection as List<> and it was working fine. I am not sure why it is not able to update item in hashset, need to look deeper into it. But changing the Hashset<> to List<> will fix this error. Hope it helps Thanks

Categories : C#

Silverlight Datagrid scrolling, DataGrid fires RowLoading event
The RowLoading event is fired because rows are virtualized. With virtualization, rows are created (and loaded) only when they are visible on screen. So every time you scroll down or up a new row is created, loaded and the RowLoading event fired. To disable the virtualization you can try to set this property: VirtualizingStackPanel.VirtualizationMode="Standard" Be aware that this can slow down the performance of your grid if you have a lot of rows.

Categories : Database

Binding ComboBoxColumn to collection from DataGrid's ItemsSource in WPF DataGrid
MSDN: DataGridComboboxColumns says: To populate the drop-down list, first set the ItemsSource property for the ComboBox by using one of the following options: A static resource. For more information, see StaticResource Markup Extension. An x:Static code entity. For more information, see x:Static Markup Extension. An inline collection of ComboBoxItem types. So basically to just bind to data object`s collection property it`s better to use DataGridTemplateColumn: <DataGridTemplateColumn Header="Log"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding log}" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> This type of c

Categories : Wpf

Validating A WPF Datagrid Against Data From Another Datagrid
From Microsoft official WPF course materials: ValidationRules are only to be used as simple validations (For instance Required fields, numeric formats, etc). If you need advanced / complex Business Rules validation, you should either implement IDataErrorInfo or create your own validation mechanism (that's what I did and it works like a charm)

Categories : C#

Copy selected row from datagrid at the end of datagrid
For Datagridview Databound you have to commit additional record to datasource (table) So, you have to do "INSERT INTO mytable ( fields here ... ) VALUES ( values here ..)" then to refresh your datagridview .. dt2.datasource = mytable ADDED : For your code ... try change like this insert_cmd.Parameters.AddWithValue("@Name", .item("Name")) insert_cmd.Parameters.AddWithValue("@Age", .item("Age"))

Categories : Sql Server

Master-Detail: On row click in master (DataGrid), display details (DataGrid)
If you searched online, you would have found a number of answers. For example, please take a look at the following articles: WPF Master Details MVVM Application Implementing a simple Master-Detail scenario for WPF in MVVM MVVM - Master Detail

Categories : Wpf

Copying data from a datagrid view to a new form with a new datagrid view VB
"Error 1 Reference to a non-shared member requires an object reference." As this message says: You need a instance of form2 - object of type form2created with New sub, which you created inside of BTN_Next_Click. But local variable frm_PI_01 can be used only inside of that function. With name of class form2 you can used only Shared member or functions/subs MSDN Shared members in VB My opinion if you need transfer some information/variables from form to another then in your case(when you transfer data only once when creating form) use a parameters in form constructors. Add another parameter to you form3 constructor. For example reference of your datagridview(this is may be not good practice referenced controls to another form, better create some variable with needed data and reference th

Categories : Vb.Net

Binding datagrid in datagrid
You have problem with DataContext here. In RowDetailsTemplate you trying to binding to a property in main view model, but DataContext of RowDetailsTemplate is the row item. If you want to binding to property in your main view model you should use RelativeSource binding. Try this: <DataGrid ItemsSource="{Binding Path=Files}" SelectedItem="{Binding Path=DataContext.CurentFile, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" AutoGenerateColumns="False" > ...

Categories : Wpf

How to add a new row in sql from datagrid and update sql row from same datagrid?
This article on codeproject does a nice (thorough) job of demonstrating what you are asking. It also comes with some demo code. http://www.codeproject.com/Articles/37430/Datagrid-Editing-Updating-Cancel-Selecting-Rows

Categories : SQL

How can embed datagrid in datagrid
I don't think it's possible. You can indeed manually replace a cell with the HTML of another grid (your "child" grid), but Dojo maintains its data in a store. Your store won't be "aware" of any changes you make in the DOM nodes of your grid, and inserting a DataGrid in a store isn't possible either since the DataGrid maps its columns to properties of the data objects.

Categories : Database

HTML+CSS Layout with 3 rows, middle row fluid sandwiched by fixed height rows
This can be achiever quite easily with absolute positioning in CSS. * { margin:0; } header { position:absolute; width:100%; height:64px; top:0; } footer { position:absolute; width:100%; height:64px; bottom:0; } div { position:absolute; width:100%; top:64px; bottom:64px; } Note, that in real code you'll want to use a class for the inner div otherwise you'll be styling all the div elements. Here's a more complete fiddle example: http://jsfiddle.net/BMxzn/

Categories : HTML

Elegantly convert rate summary rows into long binary-response rows?
Not quite clear what you're converting, but if all you need is n rows for each value in column N, then EDIT -- I was very sloppy. First thing- convert all factors in your original file to numeric or character as appropriate. then, # just put in placeholder values newdf<-data.frame(Black="n",White="n",Rate=0,stringsAsFactors=FALSE) newdf[1:rates[1,3],]<-rates[1,c(1,2,4)] newdf[4:rates[2,3],] <- rates[2,c(1,2,4)] and so on for each row in your original rates dataframe.

Categories : R

Turning a Data.Frame with 28441 Rows in it to a Dataframe with 28 Rows and 1000 Columns in R
Not sure what language this is coded in but I think I understand your problem. If your original is all in the first column of zip.codes(I assume this is the old dataframe), you want [i,1] meaning row i, first column. Your j should go from 1 to for (i in 1:length(zip.codes)) { k = i % 1000 for(j in 1:1000) { new.zip.codes[k,j]<-zip.codes[i,1] } } Using the % as a modulo operator, you can pick out the row number you want, had have j as your column control. This is extremely useful when you know your fixed table size. Hope this helps.

Categories : R

Mysql query to select rows and alternatively matching rows on other table
What you want is a left outer join: select u.*, p.* from users u left outer join posts p on u.id = p.userid and p.Postdate >= DATE_SUB(NOW(), INTERVAL 15 MINUTE); The left outer join keeps all the rows in the first table. If nothing matches in the second table, using the condition, then the values are NULL for those fields. EDIT: If you want to limit this to 50 random users, you can do this at the users level: select u.*, p.* from (select u.* from users u order by rand() limit 50 ) u left outer join posts p on u.id = p.userid and p.Postdate >= DATE_SUB(NOW(), INTERVAL 15 MINUTE); The order by rand() makes them random. You could order by anything -- name, date created, whatever. You can even leave the order by out a

Categories : Mysql

Table style layout with alternating reversed rows and without markup for rows
float 3, 4, 7 and 8 right like here: http://jsfiddle.net/KH584/ .three, .four, .seven, .eight{ float:right; }

Categories : CSS

How can I insert new rows and delete missing rows from a table given a collection of values?
Okay, so your collection is in a C# list. That makes this easier. This isn't the most efficient way to do it since it involves a lot of queries, and it would work better using a Dictionary, but it's a solution if you aren't pressed for time and don't want to use string concatenation to make a complicated query. using (SqlConnection connection = new SqlConnection(.....)) { connection.Open; using (SqlCommand command = new SqlCommand("SELECT ID, Value FROM Table")) { using (SqlDataReader reader = SqlCommand.ExecuteReader()) { while (reader.Read()) { if (THELIST.Contains(reader["Value"].ToString()) { THELIST.Remove(reader["Value"].ToString()); } else {

Categories : SQL

jQuery find table rows but ignore rows in child tables
You can use the immediate child selector: table > tbody > tr See more here http://api.jquery.com/child-selector/. Working example: http://jsfiddle.net/KLKwX/

Categories : Javascript

Selecting only rows from master table where subtable rows fullfill a condition
Clever query. But I think you can simplify it: select r.result_id from result r join image i on r.result_id = i.result_id group by r.result_id having sum(case when i.preclassification = 'P' then 1 else 0 end) > sum(case when i.preclassification = 'N' then 1 else 0 end); You can also write this as: select r.* from (select r.result_id, sum(case when i.preclassification = 'P' then 1 else 0 end) as NumPos, sum(case when i.preclassification = 'N' then 1 else 0 end) as NumNeg from result r join image i on r.result_id = i.result_id group by r.result_id ) r where NumPos > NumNeg;

Categories : SQL

Select multi rows from one query row acording to rows date Oracle
select process, from_date + n from ( select process, fromdate, todate from ( select 'A' as process, to_date('03.04.2013','dd.mm.yyyy') as fromdate, to_date('06.04.2013','dd.mm.yyyy') as todate UNION select 'B' as process, to_date('06.04.2013','dd.mm.yyyy') as fromdate, to_date('10.04.2013','dd.mm.yyyy') as todate ) s join (select level -1 as n from dual connect by level < 100) a on (s.from_date+n < s.todate)

Categories : SQL

Can I sort groups of rows in Excel so that the rows remained grouped after being sorted?
use custom sort by two columns - for each transaction add one column with unique number (maybe you already has one) and then sort first by that column and second by your desired column with date

Categories : Excel

Limit the rows to 20 in solr query but allowing cluster to search between 100 rows ?
Nope. Carrot clustering happens dynamically on the number of results fetched by Solr which is controlled by the rows parameter. So the control of Solr results has to happen on the client side. You can add clustering as last-components with request handler so that the search and clustering can be performed with a single call e.g config :- <requestHandler name="/select" class="solr.SearchHandler"> <lst name="defaults"> <str name="echoParams">explicit</str> <int name="rows">10</int> <str name="df">text</str> <bool name="clustering">true</bool> <str name="clustering.engine">default</str> <bool name="clustering.results">true</bool> <!-- Fields to cluster on --> <str n

Categories : Search

Inserting multiple rows into SQL Server 2008 table, copied from other rows with one column changed
Use a cross join. You didn't say what version of SQL you were using, so I'll low-ball it: INSERT INTO TableName( Column1, Column2, Column3, Column4, Column5, Column6) (SELECT Column1, Column2, Column3, Column4, Column5, a.[sc] FROM TableName as t cross join ( select 'NewShopCode1' as [sc] union select 'NewShopCode2' as [sc] union select 'NewShopCode3' as [sc] ) as a WHERE Column5 = 'DistinguishingValue' and not exists (select 1 from TableName as t where t.Column1 = a.Column1 and t.Column2 = a.Column2) ) Try the select by itself to see that it produces the correct results before inserting.

Categories : Sql Server

i have a table which contains more than 50 rows. i want to retrive the rows based on starting and ending count which is provided in jsp using struts
Create your query with the Session.createQuery() method (you can use also the createCriteria() or createSQLQuery() methods, the methods to use to limit the rows to a subset are the same). Then use the setFirstResult(from) and setMaxResult(max) methods of the Query class (you'll have to calculate the max value thanks to from and to values, something like max = to - from). You'll limit the ResultSet to max rows from the from value. Then execute the query with Query.list() method.

Categories : Hibernate

Efficient grouping of rows from Nx2 integer numpy array to match sequential elements in rows
If you want to find a longest "closed loop", than I think you problem is NP-complete (finding a longest simple cycle in an undirected graph). if you want to find an arbitrary cycle, try depth first search - it's about 0.02s for 1000 elements: from collections import defaultdict def ordered(data, N): edges = defaultdict() for v1, v2 in data: edges.setdefault(v1, []).append(v2) edges.setdefault(v2, []).append(v1) visited = [False] * N path = None for v in range(N): if not visited[v]: path = dfs(edges, visited, v) if path is not None: break if path is not None: return [[path[i], path[i + 1]] for i in range(len(path) - 1)] def dfs(edges, visited, v1, vp=None): path = [v1] if visited[v1]: return path

Categories : Python

Delete first X rows of MySQL table once the number of rows is greater than N
I don't think that's the right way of getting the number of rows. You need to change your statement to have a count(*) and then use MySQLs cursor.fetchone() to get a tuple of the results, where the first position (kinda like wordcount = cursor.fetchone()[0]) will have the correct row count. Your delete statement looks right, maybe you have explicit transactions? in which case you'd have to call commit() on your db object after the delete.

Categories : Python



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