Results 1 to 8 of 8

Thread: Question with DataGridView

  1. #1

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Question with DataGridView

    hi guys! Is it posible to have a custom font on each row of DataGridView? says, in 1st Row the text are in normal font size, in the 2nd row the Text are in Bold and in the 3rd row the Text are in Italics. Thanks in advance!

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

    Re: Question with DataGridView

    Each row has a DefaultCellStyle property of type DataGridViewCellStyle. That class has a Font property.
    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
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Re: Question with DataGridView

    Thanks JM!

  4. #4

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Re: Question with DataGridView

    I have another question guys...In my windows form i have a DatagridView, my question is why is it that everytime the form is load the "SelectionChanged" events is tiggered why is that? Since i dont make any selection yet. Or can you suggest guys to where I can put my code that I want to be executed everytime my user click on any rows of my DataGridView or Everytime the selected row has changed...Thanks in advance!
    Last edited by daimous; Oct 9th, 2007 at 10:42 PM.

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

    Re: Question with DataGridView

    As the documentation states:
    When you change the value of the CurrentCell property, the SelectionChanged event occurs
    If your grid is the first control in the tab order then it gets focus when the form loads and thus the CurrentCell becomes the first cell in the grid, thus the SelectionChanged event is raised. If the grid is not first in the tab order then the SelectionChanged event won't be raised until the grid first gets focus.
    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

  6. #6

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Re: Question with DataGridView

    Well if that is the case...i really have a problem...Can you help me guys to come up with an alternative solution..Basically what im trying to do is, I have a DataGridView and initially when that is loaded the Rows are in Bold letters but when my user click on a row the FontStyle on that row will be turned to regular and that serve as my user's cue to rows that already been selected Hope you get my point guys...Please see attached screenshot
    Attached Images Attached Images  

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

    Re: Question with DataGridView

    Just declare a boolean variable that indicates whether the form has already been shown or not. Set it to false initially and then set it to true in the Shown event handler. In your SelectionChanged event handler you test this variable and if it's false you know not to do anything.
    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

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

    Re: Question with DataGridView

    Alternatively, you can set the CurrentCell to null in the Shown event handler, which should raise the SelectionChanged event again and your code will presumably re-embolden the row.
    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

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