how to disable data grid editing and deleting

19 posts, 2 answers
  1. Bee
    Bee avatar
    11 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2012 Link to this post

    i have a data grid that populates data from sql on page load and its working fine. however  users are able to edit, delete these items although it doesnt affect the database. how do i set the data grid to avoid this
  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2012 Link to this post

    Hello,

    Just set the ReadOnly flag to true on the grid itself.

    If you have any other questions, please let me know.


    Best Regards,
    Emanuel Varga
    WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Bee
    Bee avatar
    11 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2012 Link to this post

    waal it worked like magic, many thanks, will come back with more questions though
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2012 Link to this post

    Hello,

    Glad to be able to help, if this solved your problem, please mark all appropriate answers so that other users will be able to find their answer quicker,

    Thank you,

    If you have any other questions, please let me know.

    Best Regards,
    Emanuel Varga
    Winforms MVP
  6. Bee
    Bee avatar
    11 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2012 Link to this post

    many thank for your time, on that same grid how do i add horizontal and vertical scroll bars
  7. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2012 Link to this post

    Hello again,

    You can change the default behavior of the scroll bars, using
    grid.VerticalScrollState = ScrollState.AlwaysShow;
    grid.HorizontalScrollState = ScrollState.AlwaysShow;

    The vertical scroll bar will not be visible if AutoSizeColumnsMode is set to Fill.

    If you have any other questions, please let me know.

    Best Regards,
    Emanuel Varga
    Winforms MVP
  8. Bee
    Bee avatar
    11 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2012 Link to this post

    yep you are right, that solves it... well am still a newbie to telerik rad controls thats why am bombarding with all the questions and so far so good,
  9. Bee
    Bee avatar
    11 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2012 Link to this post

    now i want to avoid a situation whereby a user can open a form while another one is open on the project.ie stipulating to one open form at a time, how will i achieve that?
  10. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2012 Link to this post

    Hell again,

    Glad to be able to help, but please don't unmark previous correct answers, because there are different questions there are multiple answers, otherwise if you prefer, please open a new thread.

    If you have any other questions, please let me know.

    Best Regards,
    Emanuel Varga
    WinForms MVP
  11. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2012 Link to this post

    Don't really understand what you want here, please try to add more details to this

    Best Regards,
    Emanuel Varga
    WinForms MVP
  12. Bee
    Bee avatar
    11 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2012 Link to this post

    i have an mdi form and within that mdi form there are multiple forms, so i dont want a situation whereby a user can open as many forms as possible. all i want is the user to open only one form at a time so that the project will not allow you to open any other form without closing an already open form
  13. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2012 Link to this post

    Hello again,

    If you have access to the MdiParent form, you can just check the number of MdiChildren.Lenght and based on this create the other form or not.

    If you have any other questions, please let me know.


    Best Regards,
    Emanuel Varga
    WinForms MVP
  14. Bee
    Bee avatar
    11 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2012 Link to this post

    i am struggling to go around it, this is the code i have to open the child forms from the parent
    dim child as new frmcustomers
    child.mdiparent=me
    child.show()
    i+=1

    so how do i restrict from this
  15. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2012 Link to this post

    if (me.MdiChildren.Lenght > 0)
    // do not create any more forms because there is at least 1 child created
       return;

    dim child as new frmcustomers
    child.mdiparent=me
    child.show()

    Best Regards,
    Emanuel Varga
    WinForms MVP
  16. Bee
    Bee avatar
    11 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2012 Link to this post

    have used
    if me.mdichildren.length>0 then
    return
    dim child as new frmcustomers
    child.mdiparent=me
    child.show()
    i+=1

    its saying unused local variable child and when i run the project and try to open the frmcustomers, it doesnt open
  17. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2012 Link to this post

    Do you have any mdichildren in the beginning? wasn't this the ideea? to have only one child active?

    Best Regards,
    Emanuel Varga
    WinForms MVP
  18. Bee
    Bee avatar
    11 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2012 Link to this post

    i have used this code and its working
    dim child as new frmcustomers
    frmcustomers.showdialog()
    i+=1

    but then it doesnt clear the dropdown with the list of forms i chose the frmcustomers from until i click somewhere
  19. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2012 Link to this post

    What dropdown? Can you please create a very small sample and post it?

    Best Regards,
    Emanuel Varga
    WinForms MVP
  20. Bee
    Bee avatar
    11 posts
    Member since:
    Nov 2012

    Posted 19 Nov 2012 Link to this post

    its not a drop down sorry,its names of child forms on my mdi. so from there i am clicking frm customers,  so i am saying that this list with form options to chose these child names(frmcustomers and frmrates) is still visible after i chose my preferred form and only disappers when i click anywhere on the screen

    Private Sub RadMenuButtonItem3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadMenuButtonItem3.Click
            Dim child As New frmcustomers
            frmcustomers.ShowDialog()
     i += 1
    end sub
    Private Sub RadMenuButtonItem4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadMenuButtonItem4.Click
            Dim child As New frmRates
            frmRates.ShowDialog()
            i += 1
        End Sub
Back to Top
UI for WinForms is Visual Studio 2017 Ready