Results 1 to 5 of 5

Thread: [RESOLVED] DatagridView Cell Editing Control Value

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    81

    Resolved [RESOLVED] DatagridView Cell Editing Control Value

    I am using a DGV control to get data from the user.

    1. Editing Control Value
    I have multiple columns including combo box and checkbox.

    if i need to read the value of the editing control. i.e the value of the cell before the cellediting ends.

    i can do it easily from the dgv.currencells.value after the cellediting ends.
    But i need to alert the user for entering a wrong value at the moment he enters the data not after finishing his editing.

    The same type of value needed from the combox col of the DGV. When he selects an item i have to show error for some of the item and not for all

    2.Get Combo Box Column Text Value
    I can get the value of the combobox index using the Cell Value.
    But i also need the text value of the combo box for manipulation in another column.

    Say list of combo box is
    1, name1
    2,name 2
    3,name 3

    cell value returns 1,2,3 but i need name1,name 2,name 3 for some manipulation

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DatagridView Cell Editing Control Value

    1. There seems to be a real run on this type of question lately, here's a thread I posted an answer to recently:

    http://www.vbforums.com/showthread.p...put-characters

    2. You have bound a list of some sort to the combo box column. That's where the values displayed to the user came from and that's where the cell value came from. Use it to get the text from the ID, just as you would in any other case where you had a list containing IDs and names and you wanted the name that corresponded to a specific ID.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    81

    Re: DatagridView Cell Editing Control Value

    Thanks jmcilhinney.
    Using that post i solved my problem.

    And also fixed the issues u said in the replies of that post for non numerical data & backspace and decimal point.

    but i have another doubt raised here.
    Is it necessary to declare a row and add it like dday did.
    i think not needed since i check each and every keychar of data entered in the dgv_keypress event(as of this Post).
    Is thereany advantage of using like so.

    And atlast i have not removed handler of dgv_keypresss since u said editingtextbox= nothing will do it. Am i right or need to remove handler

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DatagridView Cell Editing Control Value

    Quote Originally Posted by vpm_sampath View Post
    Is it necessary to declare a row and add it like dday did.
    i think not needed since i check each and every keychar of data entered in the dgv_keypress event(as of this Post).
    Is thereany advantage of using like so.
    I think dday9 may have misunderstood the question.
    Quote Originally Posted by vpm_sampath View Post
    And atlast i have not removed handler of dgv_keypresss since u said editingtextbox= nothing will do it. Am i right or need to remove handler
    There are two ways to attach an event handler to the editing control: you can use an AddHandler statement or you can assign it to a field declared WithEvents. You must also detach the event handler when the editing control is removed from the grid. If you used AddHandler then you must use RemoveHandler. If you assigned the control to a WithEvents variable then you simply assign Nothing to that variable.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2006
    Posts
    81

    Re: DatagridView Cell Editing Control Value

    ok so i add an removehandler.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width