12 Replies - 697 Views - Last Post: 28 May 2017 - 02:11 PM

#1 Dragnorian  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 15-November 16

Datagridview Cell Click event?

Posted 25 May 2017 - 10:57 PM

Hello! I am currently developing software for a client and I am using the Datagridview. Well, they have a store and want to keep tabs on those with in store credit but also want to put notes down for when people use it. They want to be able to click on their name and have a little rich text box appear, they type what they ordered or something and click save and that rich text box be saved specifically to that name. I have the Datagridview going in alphabetical order as well so where that cell is when they make the rich text box may change. Any help is appreciated! Thank you so much!!!

Is This A Good Question/Topic? 0
  • +

Replies To: Datagridview Cell Click event?

#2 maceysoftware  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 348
  • View blog
  • Posts: 1,494
  • Joined: 07-September 13

Re: Datagridview Cell Click event?

Posted 25 May 2017 - 11:41 PM

Hello again!

This really depends on how you have your datagridview populating?

For example are you databound or are you manually populating the grid?

Regards
Was This Post Helpful? 0
  • +
  • -

#3 Dragnorian  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 15-November 16

Re: Datagridview Cell Click event?

Posted 25 May 2017 - 11:56 PM

Hello again! The user will manually input the data. I have a few textboxes and a submit button. The user inputs the data into the text boxes and then presses submit then the information is put into rows on the datagridview
Was This Post Helpful? 0
  • +
  • -

#4 maceysoftware  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 348
  • View blog
  • Posts: 1,494
  • Joined: 07-September 13

Re: Datagridview Cell Click event?

Posted 26 May 2017 - 12:08 AM

OK the question really stays the same are you databound or are you just using a datagridview?

Even for data input you would (at least I would) have some sort of data structure behind the screen to hold the data.

Without this, its just going to be a nightmare. I mean I could tell you how to do it (or at least how I would do it) without a data structure of some kind but it would be a nightmare to debug and maintain.
Was This Post Helpful? 0
  • +
  • -

#5 maceysoftware  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 348
  • View blog
  • Posts: 1,494
  • Joined: 07-September 13

Re: Datagridview Cell Click event?

Posted 26 May 2017 - 12:16 AM

AndrewSW has done a fantastic tutorial about this.

However again it uses the same concept that i was already talking about, DataBindinghave a underlying Data Structure, in his example he used a Entity Frame work object, i personally never used it.

This tutorial actually gives you all the information you would need to do it, however it doesn't actually do your example of a hidden column that's not in the DataGridView for example.

However this isn't a topic you jump into if you don't first understand DataBinding.

AndrewSW has also done another tutorial on how to Bind Data to the Windows Form DataGridView which maybe worth looking at IF you wanted to do this. the link is located in the tutorial:

http://www.dreaminco...h-datagridview/
Was This Post Helpful? 1
  • +
  • -

#6 Dragnorian  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 15-November 16

Re: Datagridview Cell Click event?

Posted 26 May 2017 - 08:48 AM

If what you mean by Manuel Populating the grid is putting text in textboxes and pressing enter then yes. I am storing all the information in CSV file. Here is the code for populating:
           
 DataGridView1.Rows.Add(txtName.Text, txtCredit.Text, txtPrize.Text, txtPurchaser.Text)


This post has been edited by Dragnorian: 26 May 2017 - 09:22 AM

Was This Post Helpful? 0
  • +
  • -

#7 maceysoftware  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 348
  • View blog
  • Posts: 1,494
  • Joined: 07-September 13

Re: Datagridview Cell Click event?

Posted 26 May 2017 - 10:53 AM

Yep, your manually populating the rows in the datagridview.

This is going to be a nightmare to maintain, extra data which will not be exposed on the datagridview.

I guess you could look into maybe storing the text in the rows tag property if the row has a tag property, can't remember and not near a pc to check.

But then you got to figure out how and when to update the tag property. Like I said a nightmare to maintain.
Was This Post Helpful? 1
  • +
  • -

#8 Dragnorian  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 15-November 16

Re: Datagridview Cell Click event?

Posted 26 May 2017 - 11:16 AM

I was trying to suggest to them that I could just add a new column or menu and name is Notes and they can type it there but they are really wanting it to popup when you click their name. I actually synced the Row data with the textboxes like one of the links you sent(Sync DataGridView to TextBoxes) but it is that one issue. Whenever you can, do you know good video or tutorial with manual population with when click a specific cell with certain name then "notes box" pops up? I am a novice with VB and still trying to learn.

Here is the code so we're both on same page for the sync textbox(not related to current issue but I meantioned it earlier so figured I'd show it)
        index = e.RowIndex
        Dim selectedrow As DataGridViewRow
        selectedrow = DataGridView1.Rows(index)
        If (selectedrow.Cells(0).Value = "") Then
            selectedrow.Cells(0).Value = "NULL"
        End If
        If (selectedrow.Cells(1).Value = "") Then
            selectedrow.Cells(1).Value = "NULL"
        End If
        If (selectedrow.Cells(2).Value = "") Then
            selectedrow.Cells(2).Value = "NULL"
        End If
        If (selectedrow.Cells(3).Value = "") Then
            selectedrow.Cells(3).Value = "NULL"
        End If
        txtName.Text = selectedrow.Cells(0).Value.ToString
        txtCredit.Text = selectedrow.Cells(1).Value.ToString
        txtPrize.Text = selectedrow.Cells(2).Value.ToString
        txtPurchaser.Text = selectedrow.Cells(3).Value.ToString
        If (selectedrow.Cells(0).Value = "NULL") Then
            selectedrow.Cells(0).Value = ""
            txtName.Text = ""
        End If
        If (selectedrow.Cells(1).Value = "NULL") Then
            selectedrow.Cells(1).Value = ""
            txtCredit.Text = ""
        End If
        If (selectedrow.Cells(2).Value = "NULL") Then
            selectedrow.Cells(2).Value = ""
            txtPrize.Text = ""
        End If
        If (selectedrow.Cells(3).Value = "NULL") Then
            selectedrow.Cells(3).Value = ""
            txtPurchaser.Text = ""
        End If



I added the If Statements due to when you click an empty row, it throws exception error

This post has been edited by Dragnorian: 26 May 2017 - 11:28 AM

Was This Post Helpful? 0
  • +
  • -

#9 Dragnorian  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 15-November 16

Re: Datagridview Cell Click event?

Posted 28 May 2017 - 12:50 PM

Ohhh, I replied totally wrong in my last reply, very sorry about that! I figured it out in my own little way by creating a hidden column and storing the data in that row. Thank you for the help and path in right direction though!
Was This Post Helpful? 1
  • +
  • -

#10 maceysoftware  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 348
  • View blog
  • Posts: 1,494
  • Joined: 07-September 13

Re: Datagridview Cell Click event?

Posted 28 May 2017 - 12:52 PM

I didn't even think of that. Saying that I think that's the best way you can do it without building a object structure behind your UI.
Was This Post Helpful? 0
  • +
  • -

#11 Dragnorian  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 15-November 16

Re: Datagridview Cell Click event?

Posted 28 May 2017 - 12:53 PM

View Postmaceysoftware, on 28 May 2017 - 12:52 PM, said:

I didn't even think of that. Saying that I think that's the best way you can do it without building a object structure behind your UI.

Haha thank you. I prefer that way because it is less complicated with the whole purpose of the program and doing it the other way would not have made sense for the use of the program. Thanks again for the help mate!
Was This Post Helpful? 0
  • +
  • -

#12 maceysoftware  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 348
  • View blog
  • Posts: 1,494
  • Joined: 07-September 13

Re: Datagridview Cell Click event?

Posted 28 May 2017 - 01:19 PM

You will find using a object structure program, while it may take longer will give you more flexibility in the long run


Also remember VB.Net is a OOP language
Was This Post Helpful? 1
  • +
  • -

#13 Dragnorian  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 65
  • Joined: 15-November 16

Re: Datagridview Cell Click event?

Posted 28 May 2017 - 02:11 PM

View Postmaceysoftware, on 28 May 2017 - 01:19 PM, said:

You will find using a object structure program, while it may take longer will give you more flexibility in the long run


Also remember VB.Net is a OOP language

I will remember that
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1