DataGridView not displaying data.

This forum is meant for questions and discussions about the X# language and tools
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

DataGridView not displaying data.

Post by wriedmann »

Hi Roland,
the correct video in X# Academy is this one:
https://www.youtube.com/watch?v=iY65v-xUm78
And the download is here:
https://www.xsharp.eu/itm-downloads/dow ... amples.zip

And I have tried to run the sample, and on my machine it definitely works.
It is the sample DBFData, and you have to change the "set default to" statement to the folder where you have expanded the sample code.

Code: Select all

 InitializeComponent()
            SELF:dataGridView1:DataSource := self:bindingSource1
            SET DEFAULT TO C:VFFSamplesData
            USE Customers
            VAR oDataSource :=  DbDataSource()
            oDataSource:ShowDeleted := FALSE
            oDataSource:ShowRecno   := FALSE
            SELF:bindingSource1:DataSource := oDataSource
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

DataGridView not displaying data.

Post by wriedmann »

Hi Roland,
I have found the problem in your sample:
20-05-2023_17-26-08.png
20-05-2023_17-26-08.png (96.32 KiB) Viewed 285 times
You had defined the autogeneration of columns to false, and therefor the grid had no idea what to display.
Either set the autogeneration to on (what I have done), then the grid displays all fields in the table, or manually define your columns.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

DataGridView not displaying data.

Post by wriedmann »

Hi Dick,

you should really take the time and look and both the session video and the samples!

I think they are really useful for everyone, and if the devteam adds some things (like filling the DbDataSource directly from a filename, indicating order and RDD) this could be really a widely used class.

So again my recommendationto all here: take your time and look at this video:
https://www.youtube.com/watch?v=iY65v-xUm78
It is really great to see also for VO people like me.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
RolWil
Posts: 68
Joined: Mon Jul 18, 2022 3:16 am

DataGridView not displaying data.

Post by RolWil »

Thank you Wolfgang,

That did indeed do the trick! Also, thanks for the source code link from the Fox event.

I had looked at all the properties for the dataGridView and hadn't found anything. But setting it using code worked. Beautiful.

Cheers,
Roland
ic2
Posts: 1804
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

DataGridView not displaying data.

Post by ic2 »

Hello Wolfgang,
wriedmann post=26413 userid=336 wrote: you should really take the time and look and both the session video and the samples!
I've watched it. I understand this is a partly 'code generated' version of what I used earlier and as Robert says somewhere in the presentation"It's complicated" . And that it is indeed, it's (at least in the background, is is certainly not a one line code matter).

I do acknowledge that there are certain situation in which data binding has advantages. But if these situations do not occur, I stay away from databinding as far as possible. I've lost too much time in the past trying to find out why some data are not refreshed while being unable to debug this step by step like your own code to fill the data.

Dick
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

DataGridView not displaying data.

Post by wriedmann »

Hi Dick,
then your experience is exactly the opposite of mine: I'm using databinding whenever possible, sometimes by expanding the WPF GUI classes to make properties bindable that are not bindable by default (like binding the enter key on an edit control to a command in the viewmodel).
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply