none
Zoombox for DataGridView memo field? RRS feed

  • Question

  • Is it possible to zoom into a datagridview cell, or place it into a richtext like item for edit and then when they close it it updates the gridview textbox.

    I have a textbox with notes in it in a grid. I was hoping to pop that out into a complete view of the text for reading and editing.

    Friday, September 1, 2017 3:43 PM

All replies

  • I would suggest binding.

    YourDGV.DataSource = YourBindingSource
    YourRTBCtrl.DataBindings.Add("text", YourBindingSource, "ColumnName")


    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    Friday, September 1, 2017 3:56 PM
  • High level, this is easy when setting the DataSource property of the DataGridView to a BindingSource where the BindingSource DataSource is a DataTable.

    To get the current row we cast the BindingSource.DataSourcce to a DataRowView then access the Row followed by the field for getting via .Field(Of T) then use SetField to set the field value. Once you have the data via .Field(OF T) place the information into another appropriate control.

    Simple example of a get where bItems is the BindingSource as per above, set context to the TextBox or RichText control

    Dim contents As String = CType(bsItems.Current, DataRowView).Row.Field(Of String)("MyMemo")

    Get back the changes and place them into a variable and set the new value back from the original record. ChangedData would be taken from the text box or other control that was used to edit the data.

    CType(bsItems.Current, DataRowView).Row.SetField(Of String)("MyMemo", ChangedData)

    One nice (of many) features of a BindingSource is it makes it easy to get information from the DataGridView when setup as per the above. Sure it can be done without a BindingSource but a BindingSource component makes it easier.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Friday, September 1, 2017 4:01 PM
    Moderator
  • The datagridview is bounddata. What I am trying to do it get dgview.Column3.Textbox value that holds a memo field to show in lets say a richtextbox that when the user doubleclicks on dgview.column3.textbox is shown with the value of that current records textbox. Then when they close the richtextbox the value in dgview.column3.textbox updates to that value.
    Friday, September 1, 2017 4:23 PM
  • How is it data bound TableAdapter? If so it has a BindingSource component to work from.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Friday, September 1, 2017 4:24 PM
    Moderator
  • BindingSource
    Friday, September 1, 2017 4:28 PM
  • I got what I needed, thanks for the help.

    I ended up doing this.

    dgview.dblclick event

    panel1.vis.ible = true

    richtext1.value = dvgiew.currentcell.value

    Will end up putting a null or empty test in there but this way if the user double clicks any cell it will populate. i have a button in the panel with the richtecxt1 that closes (actually hides and moves the panel).

    Friday, September 1, 2017 4:37 PM
  • Hi Ryan,

    Glad to hear this issue has been solved by yourself. Thanks for your sharing, I will introduce this experience to other forum users who face the same condition. Please mark your reply to close this case.

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 4, 2017 1:30 AM
    Moderator