Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Datagrid

Datagrid

Scheduled Pinned Locked Moved WPF
questioncsharpwpfdatabasedotnet
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Saksida Bojan
    wrote on last edited by
    #1

    Compared to others i am realy confused with this control. I have 2 classes: public class DataProcessItem : INotifyPropertyChanged, ICloneable, IEditableObject public class DataProcessList : ObservableCollection DataProcessItem has exposed properties: public String LongFileName public String ShortFileName public String WindowText public uint Handle public Image FileIcon so how do i bind DataProcessList to Datagrid and populate? This class will not be used with Dataset or binded from database. I will populate with a code. and second question is how do i add columns and items programaticly without editing xaml. Thank you in advance. Also a code here is not full, only a most important pieces Edit: I am using .NET framework 4.0 so i do not need WPF toolkit

    A A 2 Replies Last reply
    0
    • S Saksida Bojan

      Compared to others i am realy confused with this control. I have 2 classes: public class DataProcessItem : INotifyPropertyChanged, ICloneable, IEditableObject public class DataProcessList : ObservableCollection DataProcessItem has exposed properties: public String LongFileName public String ShortFileName public String WindowText public uint Handle public Image FileIcon so how do i bind DataProcessList to Datagrid and populate? This class will not be used with Dataset or binded from database. I will populate with a code. and second question is how do i add columns and items programaticly without editing xaml. Thank you in advance. Also a code here is not full, only a most important pieces Edit: I am using .NET framework 4.0 so i do not need WPF toolkit

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      Saksida Bojan wrote:

      DataProcessList

      You need to set the ItemSource of the Datagrid to DataProcessList. To add columns programmatically, use DataGrid.Columns.Add(new DataGridTextColumn());. You can also have a look at this thread.

      The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick Visit the Hindi forum here.

      S 1 Reply Last reply
      0
      • A Abhinav S

        Saksida Bojan wrote:

        DataProcessList

        You need to set the ItemSource of the Datagrid to DataProcessList. To add columns programmatically, use DataGrid.Columns.Add(new DataGridTextColumn());. You can also have a look at this thread.

        The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick Visit the Hindi forum here.

        S Offline
        S Offline
        Saksida Bojan
        wrote on last edited by
        #3

        Does not help me

        <DataGrid x:Name="gridSelectProcess" Grid.Row="1" ItemsSource="{Binding Source=local:DataProcessList}" AutoGenerateColumns="True">
        </DataGrid>

        Only thing is that it shows are black empty lines

        1 Reply Last reply
        0
        • S Saksida Bojan

          Compared to others i am realy confused with this control. I have 2 classes: public class DataProcessItem : INotifyPropertyChanged, ICloneable, IEditableObject public class DataProcessList : ObservableCollection DataProcessItem has exposed properties: public String LongFileName public String ShortFileName public String WindowText public uint Handle public Image FileIcon so how do i bind DataProcessList to Datagrid and populate? This class will not be used with Dataset or binded from database. I will populate with a code. and second question is how do i add columns and items programaticly without editing xaml. Thank you in advance. Also a code here is not full, only a most important pieces Edit: I am using .NET framework 4.0 so i do not need WPF toolkit

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          For datagrid you can try WPF DataGrid Practical Examples[^] Well, the example is using toolkit, but you can easily adjust the code to use your own DataGrid, as the process remains same. You can also use Grid using ListView[^] to create grid using Listview in WPF if you wish.

          Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


          Visit My Website-->**

          www.abhisheksur.com

          S 1 Reply Last reply
          0
          • A Abhishek Sur

            For datagrid you can try WPF DataGrid Practical Examples[^] Well, the example is using toolkit, but you can easily adjust the code to use your own DataGrid, as the process remains same. You can also use Grid using ListView[^] to create grid using Listview in WPF if you wish.

            Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


            Visit My Website-->**

            www.abhisheksur.com

            S Offline
            S Offline
            Saksida Bojan
            wrote on last edited by
            #5

            I did attempt to read that article. For me it confusing, because it uses DataSet and it is binded to northwind databas, while i wan't to use a custom class in non database driven source. (Such as .Accsess, MySQL or MSSQL). Gonna save in xml with a specific format. This format would be a collection of sevral diffrent types of items. also Grid using ListView seems promesing gonna check it out. Edit: Got it working, however i needed to put ItemSource in code behind, not in xaml. Final question about datagrid. How do i make DataGrid to show images? thank you for your time

            modified on Wednesday, September 22, 2010 4:28 PM

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups