Results 1 to 7 of 7

Thread: VB2015/WPF/DataGrid

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2017
    Posts
    1

    VB2015/WPF/DataGrid

    How do I import a .csv file into a WPF/DataGrid using VB2015?

    it MUST be DataGrid (not DataGridView)/WPF: I need to be able to rotate the grid 90 degrees to display correctly in my application, and I believe WPF/DataGrid is my only VB option.

    I've read multiple posts, watched YouTube, but for the life of me I can't get past what should be a simple thing.

    Can anyone provide me with VB code to perform this task? Frustrated that I can't do this myself.

    Your help, appreciated.

  2. #2
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    Re: VB2015/WPF/DataGrid

    Quote Originally Posted by chijb55 View Post
    it MUST be DataGrid (not DataGridView)/WPF:
    Ha!

    I thought, here's a chance to take a look at DataGrid, so I opened a trial project to do just that. I figure that using VS2019 oughtn't to be an insurmountable problem.

    I can't even find a DataGrid!
    A DataGridView... no problem.

    Didn't even get off the ground.

    Ah well... such is life.


    Poppa
    Along with the sunshine there has to be a little rain sometime.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: VB2015/WPF/DataGrid

    Quote Originally Posted by Poppa Mintin View Post
    I can't even find a DataGrid!
    A DataGridView... no problem.
    There is a DataGrid control in Windows Forms but that was effectively deprecated with the introduction of the DataGridView in 2005 and .NET 2.0.

    This question is about WPF though, so the DataGrid control is the one to use.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: VB2015/WPF/DataGrid

    Have you actually created a WPF project in the first place? You can embed WPF controls in Windows Forms apps and vice versa but it is not a trivial exercise and should be avoided if possible.

    What exactly do you mean by rotating? Are you talking about how the text is rendered or just pivoting rows and columns or something else?

    Regardless, it seems hard to believe that you can't find information about populating a DataGrid. I'm quite sure that there would be examples around of how to load a collection or DataTable into it. That means that your problem then becomes how to populate a collection or DataTable from a CSV, which you should also be able to find examples of. Don't assume that you should be able to find exactly what you want from start to finish already done on the web to copy and paste. Put some thought into the problem, break it down into smaller parts and address each part separately. DataGrids have got nothing to do with CSV files. There's obviously at least two separate parts there.

  5. #5
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    Re: VB2015/WPF/DataGrid

    Quote Originally Posted by jmcilhinney View Post
    There is a DataGrid control in Windows Forms but that was effectively deprecated with the introduction of the DataGridView in 2005 and .NET 2.0.

    This question is about WPF though, so the DataGrid control is the one to use.
    John, How would one do that ?
    With reference to adding a DataGrid to a form, the only useful (?) thing I can find is: -
    "This class is not available in .NET Core 3.1 and later versions. Use the DataGridView control instead".
    Maybe that's the answer... You can't !


    Poppa
    Along with the sunshine there has to be a little rain sometime.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: VB2015/WPF/DataGrid

    Quote Originally Posted by Poppa Mintin View Post
    John, How would one do that ?
    With reference to adding a DataGrid to a form, the only useful (?) thing I can find is: -
    "This class is not available in .NET Core 3.1 and later versions. Use the DataGridView control instead".
    Maybe that's the answer... You can't !


    Poppa
    As I said, the DataGrid was effectively deprecated with the introduction of the DataGridView. Windows Forms had to be reimplemented for .NET Core so they presumably saw no point in reimplementing a control that they didn't want you to use anyway. If you create a .NET Framework project then you would be able to use it. The DataGridView is superior in almost every way though, so there would not really be any point. The only thing that I'm aware of that the DataGrid can do that the DataGridView can't is navigate relations within a single control. You could do that yourself in a DataGridView anyway though.

  7. #7
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    Re: VB2015/WPF/DataGrid

    Thanks John.
    Along with the sunshine there has to be a little rain sometime.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width