Welcome, Guest
Username: Password: Remember me
This public forum is meant for questions and discussions about Visual FoxPro
  • Page:
  • 1

TOPIC:

Need Help with Datagrid 12 Oct 2022 13:22 #24143

  • Florentin Lüdeking
  • Florentin Lüdeking's Avatar
  • Topic Author


  • Posts: 11
  • Hey everyone :)

    I need some help with the dataGridView because I don't really understand how to use it in X#
    I am currently setting the datasource like this:
    this.dataGridView1.DataSource = DbDataSource()
    If i use DELETE with SET DELETED ON this happens (See attachment)

    What am i doing wrong?

    Thank you very much

    Florentin

    Please Log in or Create an account to join the conversation.

    Need Help with Datagrid 12 Oct 2022 14:09 #24144

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3242
  • Hi Florentin,
    what do you like to accomplish with the Windows Forms DataGrid?
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Need Help with Datagrid 12 Oct 2022 14:14 #24145

    • Florentin Lüdeking
    • Florentin Lüdeking's Avatar
    • Topic Author


  • Posts: 11
  • Hi Wolfgang,
    i would like to use it like the grid in the Visual FoxPro Forms!

    Florentin

    Please Log in or Create an account to join the conversation.

    Need Help with Datagrid 12 Oct 2022 14:23 #24146

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3242
  • Hi Florentin,
    there are several mentions of this class in the forums here, so someone seems to have used it.
    But I think you need Robert or Fabrice here....
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Need Help with Datagrid 13 Oct 2022 05:39 #24148

    • Jamal
    • Jamal's Avatar


  • Posts: 303
  • Hi Florentin,

    I don't use FoxPro, however, after DELETE you may have to do:

    this.dataGridView1.Update()
    this.dataGridView1.Refresh()

    If this does not work, try binding the grid again.
    What happens if you reopen the form? Does the display of rows look the same?

    HTH,
    Jamal

    Please Log in or Create an account to join the conversation.

    Need Help with Datagrid 13 Oct 2022 08:06 #24149

    • Florentin Lüdeking
    • Florentin Lüdeking's Avatar
    • Topic Author


  • Posts: 11
  • Hi Jamal,

    i tried all of your suggestions and sadly none of them work for me.
    I am also using SET DELETED ON
    this is the code i use to set the DataSource:
    SELECT 0
    USE kdstm ALIAS kdstm
    this:dataGridView1:DataSource = DbDataSource()
    If I want to delete something I used this code:
    DELETE 
    this:dataGridView1:Update()
    this:dataGridView1:Refresh()

    The first screenshot shows what happens if i just delete.
    For some reason it doesn't hide the deleted row even though i use SET DELETED ON.

    The second screenshot shows what happens if i delete and then rebind the DataSource.



    Im really lost on what to do :(

    Florentin
    Attachments:

    Please Log in or Create an account to join the conversation.

    Last edit: by Florentin Lüdeking.

    Need Help with Datagrid 13 Oct 2022 08:11 #24150

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3242
  • Hi Florentin,
    IMHO you need to wait what Robert says, and before he says something I'm pretty sure he needs some time to analyze that.
    But AFAIK today is the first day of Virtual FoxFest, and maybe he had to prepare something for his presence there and was not able to check out your problem.
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Need Help with Datagrid 13 Oct 2022 22:55 #24155

    • Jamal
    • Jamal's Avatar


  • Posts: 303
  • Hi Florentin,

    Is the datasource a DBF or SQL?

    What is the code behind in DbDataSource()?

    Edit: I suggest you create a reproducible sample for the dev team to look at.

    Jamal

    Please Log in or Create an account to join the conversation.

    Last edit: by Jamal.

    Need Help with Datagrid 14 Oct 2022 09:09 #24160

    • robert
    • robert's Avatar


  • Posts: 3269
  • Florentin,
    Wolgang was right. I was busy with my session for Virtual FoxFest.
    At first glance I think the problem is that the DbDataSource returns the # of records in the table when asked by the Grid for the # of rows. And it does not subtract the # of deleted rows. That would explain why there is an empty row at the bottom.
    Give me some time to look at this.
    The alternative solution would be to use the DbDataTable(). This reads the contents from the cursor in a (detached) DataTable. A deletion in the table will remove the DataRow (move it to a list of deleted rows).
    The disadvantage of this approach is that you will have to write the changes back to the database when you commit the changes (with a button or when you close the form).
    I showed how this can be done in my session for VFF a couple of years ago,
    It boils down to:
    oTable := DbDataTable()
    SELF:DataContext := oTable
    .
    .
    .
    DbTableSave(oTable)

    To see what happens when save is executed, look here
    github.com/X-Sharp/XSharpPublic/blob/mai...DbDataTable.prg#L113

    I'll look into this asap.


    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Need Help with Datagrid 14 Oct 2022 09:57 #24162

    • Florentin Lüdeking
    • Florentin Lüdeking's Avatar
    • Topic Author


  • Posts: 11
  • Robert,

    thank you very much!

    Please Log in or Create an account to join the conversation.

    Need Help with Datagrid 14 Oct 2022 10:33 #24163

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3242
  • Hi Robert,
    is a registration of this session available anywhere?
    Maybe that would be really helpful (also for us VOers to understand how we can use these classes).
    It would be a real pity to have such useful code.
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Need Help with Datagrid 24 Oct 2022 08:26 #24248

    • Florentin Lüdeking
    • Florentin Lüdeking's Avatar
    • Topic Author


  • Posts: 11
  • Hi Robert,

    i tried using DbDataTable but now i can't use DELETE anymore.

    Tanks for looking into DbDataSource, i really need it :)

    Florentin

    Please Log in or Create an account to join the conversation.

    Need Help with Datagrid 24 Oct 2022 11:15 #24249

    • ic2
    • ic2's Avatar


  • Posts: 1573
  • Hello Wolfgang,

    It would be a real pity to have such useful code.

    :lol:

    Dick

    Please Log in or Create an account to join the conversation.

    Need Help with Datagrid 24 Oct 2022 11:21 #24251

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3242
  • Hi Dick,
    oh, I'm really sorry.... It seems I have sent my response without complete it - it without even notify that.
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1