Results 1 to 10 of 10

Thread: MSFlexGrid Cell Color

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2000
    Posts
    48

    Question

    Does MSFlexGrid have a property or method so that I can
    set different color for one cell and another color for another cell? Please help! Thank you...

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Smile

    you can use the MSHFlexGrid1.CellBackColor properties to do it.

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2000
    Posts
    48
    For some reason I only have one cell colored. You have any
    code? Thank you...

  4. #4
    Lively Member
    Join Date
    Jul 2000
    Location
    Brunei
    Posts
    100
    Originally posted by laura
    Does MSFlexGrid have a property or method so that I can
    set different color for one cell and another color for another cell? Please help! Thank you...
    Hi there,

    How can I save the back ground color of the cells and rows, even after I close the form?

    That is, I want to retain the back color of the cells and rows

    Is it possible? If so, pls tell me how?

    Thanks in advance.

    Rathi


  5. #5
    New Member
    Join Date
    Aug 2000
    Posts
    6

    Wink

    Hi there.

    I'm using public constants to 'remember' the background colors for the active cell and the last activated cell

    Public Const CellLastColor as Variant ' Can't remember the right datatype
    Public const CellDefaultColor = &HFFFFFF ' plain white
    Public Const CellActiveColor = &H800000 ' vbBlue
    Public Const CellNoteColor = &HEAD5FF ' shady pink ;-)

    Since I have notes attached to some of the cells in the MSFlexgrid, I only needed to specify the note color and keep information in a list containing the row and coloumn where notes are attached.

    Do you have specific colors for each cell that you need to save?

    If you want all of your cells to have (except fixed cells)
    the nice blue color use:

    dim i as integer, j as integer
    dim intFirstRow as integer, intFirstCol as integer
    ' non-fixed that is
    dim intMaxRow as integer, intMaxCol as integer

    intFirstRow = 1
    intFirstCol = 1

    intMaxRow = MSFlexgrid1.rows - 1
    intMaxCol = MSFlexGrid1.cols - 1

    for i = intFirstCol to intMaxCol
    MSFlexGrid1.col = i
    For j = intFirstRow to intMaxRow
    MSFlexGrid1.row = j
    ' Insert update of your list if you want
    ' to save the previous Cell color
    MSFlexGrid1.CellBackColor = CellActiveColor
    ' or MSFlexGrid1.CellBackColor = vbBlue
    next j
    next i


    There you go

    Regards Kishpa

  6. #6
    Lively Member
    Join Date
    Jul 2000
    Location
    Brunei
    Posts
    100

    MSH FlexGrid color

    Originally posted by Iluvaras
    Hi there.

    I'm using public constants to 'remember' the background colors for the active cell and the last activated cell

    Public Const CellLastColor as Variant ' Can't remember the right datatype
    Public const CellDefaultColor = &HFFFFFF ' plain white
    Public Const CellActiveColor = &H800000 ' vbBlue
    Public Const CellNoteColor = &HEAD5FF ' shady pink ;-)

    Since I have notes attached to some of the cells in the MSFlexgrid, I only needed to specify the note color and keep information in a list containing the row and coloumn where notes are attached.

    Do you have specific colors for each cell that you need to save?

    If you want all of your cells to have (except fixed cells)
    the nice blue color use:

    dim i as integer, j as integer
    dim intFirstRow as integer, intFirstCol as integer
    ' non-fixed that is
    dim intMaxRow as integer, intMaxCol as integer

    intFirstRow = 1
    intFirstCol = 1

    intMaxRow = MSFlexgrid1.rows - 1
    intMaxCol = MSFlexGrid1.cols - 1

    for i = intFirstCol to intMaxCol
    MSFlexGrid1.col = i
    For j = intFirstRow to intMaxRow
    MSFlexGrid1.row = j
    ' Insert update of your list if you want
    ' to save the previous Cell color
    MSFlexGrid1.CellBackColor = CellActiveColor
    ' or MSFlexGrid1.CellBackColor = vbBlue
    next j



    next i


    There you go

    Regards Kishpa


    Hi there,

    Thank you very much for your support.

    I could have been more specific about my question.

    My form has MSHFlexgrid control and a Common dialog color control. I can color cells and rows using the dialog
    control.

    when I close the form, all the color settings are gone. How
    can I retain this?

    Your help would be greatly appreciated.

    thanks

    sincerely,
    Rathi

  7. #7
    Lively Member
    Join Date
    Jul 2000
    Posts
    104
    Use the SaveSetting and GetSetting functions to save and retrieve the colors from the registry.

    Look up the functions in MSDN for examples.

  8. #8
    Lively Member
    Join Date
    Jul 2000
    Location
    Brunei
    Posts
    100

    Unhappy MSH flex grid coloring cells

    Originally posted by ttingen
    Use the SaveSetting and GetSetting functions to save and retrieve the colors from the registry.

    Look up the functions in MSDN for examples.
    Hi there,

    Thanks a lot for your time.

    The savesetting function has four arguments. I tried to understand the parameters: Section, Key, and Setting for the whole day, but no use. Examples in MSDN did not help me.

    How can I use this function, to save the color of the cells?

    Your help would be greatly appreciated.

    Thank you.

    sincerely,

    Rathi

  9. #9
    Lively Member
    Join Date
    Jul 2000
    Location
    Brunei
    Posts
    100

    Re: MSH flex grid coloring cells

    Originally posted by rathi
    Originally posted by ttingen
    Use the SaveSetting and GetSetting functions to save and retrieve the colors from the registry.

    Look up the functions in MSDN for examples.
    Hi there,

    Thanks a lot for your time.


    There are many cells through out the grid with different colors. Is it possible to save the color settings of all the cells using the savesetting and getsetting function ?



    Your help would be greatly appreciated.

    Thank you.

    sincerely,

    Rathi

  10. #10
    Lively Member
    Join Date
    Jul 2000
    Posts
    104
    Here's a tutorial on how to use the functions:
    http://www.vb-world.net/articles/registry1/

    If you click on registry on the left-hand menu you will see a couple of other tutorials that use the registry to persist user settings, etc...

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