C# - Datagrid: Generate Columns From A Property Of The ItemsSource Collection
Nov 18, 2011
I'm trying to create a datagrid with auto generating columns. Let's say my Collection is a property named Articles of my viewmodel of type ObservableCollection<ArticleWrapper>.
I bind now the ItemsSource to this collection:
<wpf:DataGrid ItemsSource={Binding Articles} />
The class ArticleWrapper is like this:
[c#]
public class ArticleWrapper
{
public ArticleConfigurationSet ArticleConfigurationSet { get; set; }
public string Description { get; set; }
[Code]....
But now my problem: I want to bind the displayed data to my ArticleConfigurationSet property. But I cannot change my ItemsSource Binding, because the SelectedItem property of the datagrid must be of ArticleWrapper (for command handling).
The datagrid should also look like this:
View 3 Replies
ADVERTISEMENT
Jun 14, 2010
UPDATE: See the bottom of this question for what I did to solve the problem.I'm trying to understand how the ItemsSource and DataContext properties work in a Silverlight Toolkit DataGrid. I'm currently working with dummy data and trying to get the data in the DataGrid to update when the value of a combo box changes.
View 2 Replies
Mar 25, 2009
I'm trying to get images to display in a WPF ListView styled like a WrapPanel as described in this old ATC Avalon Team article: How to Create a Custom View. When I try to populate the ListView with a LINQ-to-Entities queried collection of ADO.NET Entity Framework objects I get the following exception:
[Code]...
View 9 Replies
Aug 8, 2011
I've reviewed the links that were offered and don't find an answer. Neither has a lot of searching helped, probably because I can't think of a reasonably short way to ask the question. I hope that I've at least found the proper forum and category.
In my VB 2010 code, I've defined a structure that has about 30 elements. I want to sum the properties (they are all singles) of two members of the corresponding collection. I understand that I can do something like:
member1.property1=member2.property1+member 3.property1 for the entire set of properties of member2 and member3 to produce a completely defined member1 What I wonder is whether or not there is a way that uses fewer lines of code - I know that I can't do:member1=member2+member3, for example.
View 7 Replies
Jul 11, 2010
So what I'm trying to do is not so much generate a random word but pick one from a collection. I was thinking on generating a random number since that is very easy, then picking a word acording to the number generated. Is there a more efficient way of doing this?
View 9 Replies
Oct 25, 2011
I have a three column table which lists every person, every event they may have attended, and what percentage of the time they were there. I would really like to display this on one page with the person names on the side and the event names across the top.
Here' an example of what I have:
NAME EVENT %ATTENDANCE
Smith Rock Climbing 50
Allen Rock Climbing 78
[Code]....
View 2 Replies
May 22, 2012
I generate csv content type export.
added columns like "A","B","C","D" by
columns = string.format("""{0}"",""{1}"",""{2}""","A","B","C")
stream.writeline(columns);
the csv file was exported but the first column don't having the double quotes. i need double quote with every column. i tried so many ways with in that one of the way is working fine that is columns = string.format(" ""{0}"",""{1}"",""{2}""","A","B","C") -- put space before first column.
but i need result without space.
Sample Code:
Public Class CSVExporter
Public Shared Sub WriteToCSV(personList As List(Of Person))
Dim attachment As String = "attachment; filename=PerosnList.csv"
[Code]....
View 1 Replies
Nov 13, 2011
I have a materials library that I am adding into a database, the library has a number of columns, the one I am concerened with here is the Item Code column.
All Item codes start with 'M' and then have an integer after them (M1, M2, M3.....M9999 etc) What I want to do is to auto generate the next available item code when a new line is added.
The next available code should be based on the last value in the 'Item Code' Datagrid View column but I don't know how to do this.
I have tried getting the next available code from the database but this doesnt work as I want it to.
[code...]
View 2 Replies
Jan 14, 2011
I am trying to set the itemssource for my WPF-based VB 2010 project to a datatable item. The datatable is "roster_table" and the column name I want to display the items from in the list box is "DATA_NAME". The listbox is "lstNames".
I can't find a straight answer anywhere. How do I set the itemssource for the listbox to the datatable's column, as described above?
View 1 Replies
Sep 17, 2010
As the title suggests I am looking for the key sequence to generate the standard Property syntax in a vb.net class. Example below so there is no confusion on what
Public Property MyProperty() As String
Get
Return _MyProperty
[code].....
View 1 Replies
Jul 14, 2009
I have class called "Employee" and I have a class called Department. They have an association. I need to create a colleciton of employees with the creation of a Departmant. I know how to do with using "private" member _AllMyEmployees. But I need to expose this private member using properties. therefore how do i covert thsi private member to a property? [code]
View 2 Replies
May 6, 2012
I am using a Dim All_PriceLists As System.Collections.ObjectModel.ObservableCollection(Of BSPLib.PriceLists.PriceListPrime) where PriceListPrime implements Inotify for all properties in it.
I bound the All_PriceList to a datagrid as DataGrid1.ItemsSource = All_PriceLists but when I do All_PriceLists=Getall() where Getall reads and gets the data from the DB, the datagrid is not updating.[code
View 3 Replies
Nov 26, 2011
I have set up my connection to SQL Database.
Public Sub ConnectToSql()
Dim conn As New SqlClient.SqlConnection
' TODO: Modify the connection string and include any
' additional required properties for your database.
[Code] .....
How can I export specific columns from datagrid to specific SQL Table (and match up the columns (column names in datagrid are different to Column Names in SQL Table).
View 1 Replies
Nov 15, 2011
I have some nested objects arranged like this:
Process
Persons
Workflows
Tasks
So you have one Process. Then multiple Persons can be added to and multiple WorkFlows can be added Process as well. Multiple Tasks can be added to each WorkFlow but I need a way to tie which Person is doing each task. I basically need a way that for each Person added to the Process it, in it's constructor, assigns a Person.ID property that can then be assigned into each Task's PersonID property...
Dim myProcess as New Process()
Dim myPerson as New Process.Person()
myProcess.AddPerson(myPerson)
[code]....
View 2 Replies
Jan 29, 2009
Thought I had got this sorted earlier but unfortunately not. A property in a class is a collection of objects.
[Code]...
View 4 Replies
Nov 14, 2011
Ive recently written a control called a ButtonRow in VB.NET that allows you to dynamically place buttons on it through a typed collection property. The property itself is tagged with the <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>. However it works really bad. First of all, whenever you add buttons to it and you delete the controlafterwards, the designer code file still have the buttons declared but without the aButtonRow to who's collection they would be added. Secondly, you cannot copy the controlfrom one form to another. It would just copy the ButtonRow object without the buttons
View 6 Replies
May 26, 2012
I'm working on a small project and got into some troubles trying to keep it OOP.I have a global variable:
Public Stations As New Microsoft.VisualBasic.Collection()
And 2 classess: Station & Unit:
Public Class Station
[code].....
View 1 Replies
Feb 2, 2009
I had read on pages like this
that when adding objects to a CheckedListBox, it takes the .ToString() function of each added object as the text string.
I added instances of SortedDictionary as this[code]...
View 11 Replies
Sep 1, 2011
I have a list of Active Directory entries (computer names) as a Collection data type. How can I add the computer entries and the pertinent columns to the DataGrid control on my WinForm? I have borrowed this code from some web site to add the list of computer to the pcList which is a Collection type.
pcList.Add(dirSearchResults.GetDirectoryEntry().Name.ToString())
View 4 Replies
Jun 24, 2011
How can I set up my WPF datagrid to sort on multiple columns similar to having two sortable columns, clicking on the header of the first column for a primary sort and then SHIFT clicking on the header of the second column for a secondary sort. I would like the multiple column sort to happen automatically when the user clicks on the header of the first column without having to SHIFT click on the second column header. Is there a way to do this entirely in the xaml? If not how can I do this in the code behind? Currently using VB.Net but a C# snippet is acceptable if you have one.
View 2 Replies
Feb 9, 2010
i want to make a datagrid with 2 columns and many rows
the columns i want to have databinding with a datatable
i want the 1 row 1 column of datagrid have data from 1 row of datatable
i want the 1 row 2 column of datagrid have data from 2 row of datatable
[code].....
View 2 Replies
Aug 22, 2011
Got a data grid view with two check box columns in it. Currently, got one set up and working how I want it using this
[Code]...
View 7 Replies
Sep 1, 2011
I am using DataGrid control in VB. I have created a DataTable at runtime and added 5 columns in this Datatable. I binded the data table with DataGrid control.
Width of DataGrid is 880. The default width of 5 columns of data table in DataGrid is 100. So for 5 columns width used = 500. So an empty space of 380 left at the right hand cornor of DataGrid. I want to fill this empty space with these 5 columns. I want to increase the width of columns so that it fully covered in DataGrid.
View 1 Replies
Apr 18, 2012
I'm in the process of converting an app to vb.net 2008. I was using an msflexgrid previously. I am not using a database to fill the datagrid but as the application recieves data via a tcp connection I place the data into the datagrid's columns. The problem I am having is with column widths. I found this code by doing a search on here and added to my form.
[Code]...
View 2 Replies
Jul 31, 2010
In my datagrid, I know the number of rows that it will have - it will always have 12 rows.Can I scroll through the cells downwards via the columns instead of the usual horizontal way via the rows?
View 3 Replies
Nov 20, 2010
I want to add more than one column to a grid...The following does NOT work, how can i do it?
Dim AmountRounds As Integer
DataGridView1.ColumnCount = Amount + 2
Dim contcolumn As New DataGridViewTextBoxColumn
For AmountRounds = 1 To Amount - 1
[code]....
View 1 Replies
Jul 22, 2009
how can I know what are the indexes of the columns in my datagrid?
View 6 Replies
Apr 27, 2010
I am trying to refresh my combobox when an item is selected and added the highlighted code as shown below; [code]Items collection cannot be modified when the DataSource property is set.
View 3 Replies
Aug 12, 2011
I have an object with a property that is a collection. When I point the PropertyGrid to the object it displays the ellipses for the collection. When I click it I get the generic collectioneditor. Of course the Add put fails because my collection is strongly typed. I need an example of how to create a collectioneditor that will create my collection's objects.
View 4 Replies
May 15, 2011
I want to allow the user to select which table they want to be displayed in the datagrid by selecting the table name from a comboBox - this bit I have managed but I want to limit the number of columns displayed. Each of my tables have the same fields (it is for a plant database, there is a table for each type of plant tree, shrub etc) so I know the column headings but
View 2 Replies