Change Back Color Of A Specific Cell In A Msflexgrid
In a msflexgrid, can I set a cell's back color similarly to the textmatrix property for text? I could use the cellbackcolor property but I want to do it without setting the row and col properties to those of that specific cell, i.e. without changing the current row and col values.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Setting MSFlexgrid Cell Fore And Back Color
In frmMain, I am setting the cell forecolor and backcolor of a flexgrid if a cell in the flexgrid contains a value...
For i = 0 To 1
For lngRow = 2 To .Rows - 1
For lngCol = 1 To .Cols - 1
If .TextMatrix(lngRow, lngCol) <> "" Then
.row = lngRow
.col = lngCol
.CellBackColor = &H8000& 'dark green
.CellForeColor = vbWhite
Then I want to transfer the cell values and formatting to another grid on a form called frmBackUpCurr. This is what I tried...
For i = 0 To 1
For lngRow = 2 To frmMain.mfgRunTank(i).Rows - 1
For lngCol = 0 To frmMain.mfgRunTank(i).Cols - 1
.row = lngRow
.col = lngCol
.CellForeColor = frmMain.mfgRunTank(i).CellForeColor
.CellBackColor = frmMain.mfgRunTank(i).CellBackColor
.TextMatrix(lngRow, lngCol) = frmMain.mfgRunTank(i).TextMatrix(lngRow, lngCol)
The cell values transfer OK. But the problem is that all the cells, not the individual cells containing a value, have a cellbackcolor of &H8000&. Could someone steer me in the right direction to correct this?
Msflexgrid Cell Color Without Rowsel Change?? VB6
Is there a way to set .cellpicture or .cellcolor without first setting .row and .col??? as this moves the users cursor, have a console recieves updates and I can't have the users selected cell moving all over the place. whereas .textmatrix writes to the cell without moving the cursor. HELP!
Msflexgrid Back Color
Im changing the backcolor of specific cells in code during the running of my program. This is not difficult.........the question is ..... is there a way to change ALL the cells (Not the fixed cells) backcolor back to white without looping through each and every cell.
fGrid.BackColor = vbWhite
but that doesnt do anything. Someone please help.
Thanx in advance
How To Change Back Color
I hope one of you knows how to change the background of a menu, I'm looking for it since 2 days without an answer.
Thanx a lot for reply.
Color Cell With MSFLEXGrid! Pls Help Me!
With one value for 1 cell want to set one color. Mean: if me.MSFLEXGrid.textmatrix(col, row)='A' this cell has red color
elseif me.MSFLEXGrid.textmatrix(col, row)='B' this cell has Blue color. What should I do? Please help me to solve this problem.
Thanks in advance.
MSFlexGrid Cell Color
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...
Run Macro On Specific Cell Change
Is there a way to have a VB Macro run when a specific cell changes value ? I am able to have a macro run when a "sheet data change" takes place, but do not know how to isolate a specific cell to be watched, while ignoring any other changes to the sheet.
Thanks in advance for any help !!!
Change Back Color Of Message Box
hi guys is there any body here who knows how to change back color of message box currently i am using third party control to do that but i know that its not a good idea. third party controls can create many problems and they also input many restrictions.
Change Label Back Color
I have wriiten a small proceduer for coloring the Label
Private Sub lblBox_Click()
Public Sub ColorLabel(ByVal strlabelName As String)
If strlabelName.BackColor = &H80000005 Then
strlabelName.BackColor = &H80000002
If strlabelName.BackColor = &H80000002 Then
strlabelName.BackColor = &H80000005
Bu twhen i complie it gibes me invalid qualifier..please advice..
Change Form Back Color
in my project the form background color was not changed i have write the code to change the back color at run time but that code will not working what i have to do?
Change Selection Back Color Style In RTB
Hi ever one
I want to change the selection color in RICH TEXTBOX CONTROL V6
one by one please
not the selection text that easy
NO NO NO
you know that color is black in RTB and Blue in TextBox
when you select a string the color is blue right in textbox
but in RTB is BLACk what I need is to change that Backcolor to be like TextBox
I hope that made my self clear
the answer is as simple as it seems or as complicated as I found it
and I donot think that PARAFORMAT2 Structure would do me any good
How To Change The Back Color Of Data Grid
I have Data Grid on Form and Form Backgroud is set to Dark Blue, but when I change the back color of Grid, the only Back Color of Row is changed, rest of grid color remain same. How Can I change the entrie color of Data Grid to Back Color of Form. Please help
FINALLY!! A Way To Change DTPicker Back Color
Over the last week, I have been searching and searching for a method that would allow me to change the background color of a DTPicker control. The reason I wanted to do this was as the user moves from field to field in my application, I highlight the current field that has focus. This worked fine for all the controls I used besides the DTPicker because it doesn't have a .back color property. I know you can change the colors of the dropdown calendar, but this is not what I wanted. I wanted to change the color of the entry portion of the field when the dropdown calendar wasn't displayed.
After not being able to find a method to accomplish this, I decided to tackle it myself. After a few hours, I came up with the following approach after seeing how other people have suggested or attempted to do it. Basically, you sublcass the DTPicker control to capture and monitor its messages. The message that I discovered that would need to be captured was WM_ERASEBKGND which occurs when the control is being created or refreshed. During this message, I simply get the rectangle area of the control and fill it with my desired highlighted color.
You than place your subclassing routine in the GotFocus event to highlight, and then remove the subclassing from the control in the lostfocus to remove the highlight.
I'm hoping somebody will come up with a better way to do this ( I didn't have much time to do this), but at least this puts people on the right track on how to make this functionality happen. I would be interested in better ways of doing this, but at least it works for me now.
*** USE AT YOUR OWN RISK ***
Public Declare Function GetProp Lib "user32.dll" Alias "GetPropA" (ByVal hWnd As Long, ByVal lpString As String) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function DeleteObject Lib "gdi32" Alias "DeleteObject" (ByVal hObject As Long) As Long
Public Declare Function SetProp Lib "user32.dll" Alias "SetPropA" (ByVal hWnd As Long, ByVal lpString As String, ByVal hData As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function GetClientRect Lib "user32" Alias "GetClientRect" (ByVal hwnd As Long, lpRect As RECT) As Long
Public Declare Function CreateSolidBrush Lib "gdi32" Alias "CreateSolidBrush" (ByVal crColor As Long) As Long
Public Declare Function FillRect Lib "user32.dll" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
left As Long
top As Long
right As Long
bottom As Long
Public Const GWL_WNDPROC = -4
Public Const WM_ERASEBKGND = &H14
Module Code That Work's To Subclass DTPicker Control Events
Note: You can probably use your own and it still will work.
Public Function DTPProc(ByVal hwnd As Long, ByVal iMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case iMsg
Dim lngBrush As Long ' Brush color
Dim rct As RECT ' Rectangle structure
' Color of highlighted field
lngBrush = CreateSolidBrush(&HFFFF80)
' Get rectangle area of dtpicker control
GetClientRect hwnd, rct
' Fill rectangle area with highlight color
FillRect wParam, rct, lngBrush
' Remove object from memory
DTPProc = CallWindowProc(GetProp(hwnd, "OldDTPProc"), hwnd, _
iMsg, wParam, lParam)
* Note: The GetProp(hwnd, "OldDTPProc") command above is how I keep
a past reference to the old handle of the control. You should substitute
this with how you keep reference to the old handle.
DTPicker Control's GotFocus Event
Note: In this event, subclass your DTPicker control
so that it's events are captured. You probably can
use your own or the countless subclassing routines
that do this.
HookControl ' Name of the routine I used to hook the control.
DTPicker.Refresh ' Issue a refresh so the highlight can be displayed.
DTPicker Control's LostFocus Event
Note: In this event, remove the hook to the subclassed DTPicker.
You probably can use your own or the countless subclassing routines
that do this.
DTPicker.Refresh ' Issue a refresh so the highlight is removed.
HookControl Procedure - This is the one I use.
' Stores previous instance of handle
Call SetProp(DTPicker.hwnd, "OldDTPProc", GetWindowLong(DT_Picker.hwnd, GWL_WNDPROC))
' Subclasses the dtpicker control
mlngPrevDTPProc = SetWindowLong(dtpicker.hwnd, _
UnHookControl - This is the one I use.
' mlngdtpHandle = Variable I use to store handle to current control
' mlngPrevDTPProc = Variable I use to store old handle
SetWindowLong mlngDTPHandle, GWL_WNDPROC, mlngPrevDTPProc
Can We Change The Back Color For A Data Report In VB6 ?
This is Robert.. I want to change the back color of a Data Report which is in White (default). Can we get this. And another thing is at the time of printing the color should not be printed, instead it should be default ( white ).
Change Back Color On CCRP DateTimePicker Control?
I'm using CCRP's DTP control. I have a database form on which I display all required fields with a yellow back color, but that control doesn't have that option.
Is there a way to set the back color of the control? I'm guessing the word "subclass" is going to pop up, but I don't know how to do that, so any help, examples, etc., would be greatly appreciated.
How Can I Change The Command Button Colour(back Color)?
How can i change the command button colour(back color)?
When i try to change the back colour in the design time, it doesn't do a job, it didn't change the colour that what i want?
IS it possible to change the color of command button?
because i need to do with the square thigs for monopoly.
How To Change Back Color For Listview Alternately For Rows
can some body hint me on to apply backcolor for listview which is in report view. the colors need to be applied alternately for each row (for e.g 1st row blue 2n row yellow 3rd row blue 4th row yellow and so on..)
Mind is faster than Wind --- Mahabharat
How Do I Change The Color Of Specific External App Window
How do i change the color of specific External Program Titlebar color. The application uses Bitmaps. Is what i was thinking is from a color chart drag and drop the color to the specific application and apply it right away as soon as you have dragged the icon over the Window of the Bitmapped External Application
Change Background Color Of A Specific Window?
Is there a way to change the background color of an app (such as MS Calculator), without changing the background color system-wide?
I want to change the color of a specified window, just as if I were to change the system-wide color for "3D Objects", but I want to override the default operating system colors for just a specific window handle.
How To Change Excel Cell Color
I want to change the background color of a particular cell in Excel Sheet thro' the VB program. I have done the rest of the things in getting data written into an Excel sheet.
Find Cell, Change Color
I am trying to come up with some code that will search for a certain value and change the color of the cell. It just seems so simple, but I am struggling on it. I have tried to record a macro and do it, but I dont think I am diong it right. Any suggestions?? Thanks guys!!
Change FlexGrid Cell Color
I searched forum about this problem but couldn't find enough answer for me.
I'm using flexgrid to show my result. I want to change cell fore color when my result failed .
I tried something like below
For i=1 to 10
if Result(i)<1 Then 'Result Failed
Change Cell Color In Flexgrid.
I want to change the color of each cell in a flex grid based on the value from the table.for example there are nine columns and 2 rows.each cell can get some value or the value 'F'.if it is 'F' i want green color, if it is sthg else I want red.grid1.cellbackcolor changes fro the whole row.pl suggest.
Change Color Of Cell In Datagrid
I have searched this forum but only similar information on MSFlexGrid is available. Could anyone provide hints on how to change color of cell in MSDatagrid?
Excel Cell Color Change
I was struggling all morning to get this condition happen in Excel.
The user inputs 31/11/2003 as the Due Date of a task in cell A1.
As the time passes and 31st of November actually arrives, that A1 cell color becomes Red.
According to my basic knowledge in VB, a similar situation in a Form will look as like below. Now, hope you understand what I am saying.
Private Sub Form_Load()If (txtDate.Text < Date) ThentxtDate.ForeColor = vbRedEnd IfEnd Sub
I would be grateful if anyone can help me with a code in Excel similar that in the VB Code mentioned above. Yes, the code should run when the Excel sheet opens, just like in Form_Load.
Thank you very much.
Vba Excel Change Cell Color
I'm trying to change MS Excel range of cells color to Red -> if any cell in the range has a number below 70.
trying different way but no result.
how to make the word justify to center in the cell?
Your help is appreciated.
How To Change The Color Of A Cell In Flexgrid
hi, i have flexgrid with 5 columns -
"ProductName", "QuanitityOnhand", "UsedQuantity", "OrderQuantity" and "Order"
Row1 Folger Coffee 5 bottles 10 bottles 10bottles No
Row2 FrenchFry bags 1 bag 20 bags 0 bags Yes
Row3 Sugar 5 Cases 1 Case 0 Cases No
on flexgrid load event the values for column 5 - "Order" is all "no" , and when the user dbl_clicks on a row it changes to "yes".
i hav acheived so far ,i also want to colour the selected cell(2row, 5Col - in this case)
but the selection is made by dbl_clicking on a row (row2)
i dont want the entire selected row i just want (row2 , col5 ) ("yes") to be in redColor
Thanks for any help
Change Color To A Selected Cell ?
i use code below change color selectted cell ( in event click of mshflexgird)with mshflexgrid1
.Col = 8
.Row = cRow
.CellBackColor = vbGreen
It is work but I want to when I click on order cell then I want to color of old cell return normal ! can you help me ? thank you !
MSFlexgrid : Change Row Color
I have a small problem, when I am dumping Employee data into MSFlexgrid want to change the color of row depending the designation of the employee for example : Position - > Manager Red color Row, Sales Blue color Row etc.
If any body can, Please ....?
Change Color In MSFlexGrid!!!
I want to change color for each row in MSFlexGrid but I don't know which property I should use. is there anyone had done it before, pls help me. Thanks a lot.
I am waiting for your replying!
Need To Change The Font Color In The Cell In Excel
I want to change the font color from black to red if this condition meets for this specific condition and I am using the code below. I get an error as - VB runtime error 1004 - Method 'Range' of object '_Worksheet' failed
THe code is -
If strColA = "True" Then
colorRed = oCurSheet.Range("A5:AP").InteriorColor
Change Cell Color Of Flexgrid With Certain Data
I am generating an excel type sheet using a flexgrid. It populates a top and side that is non moving and has different background colors. It has a color chart at the top for different entries of data from different groups. The groups are fixed with a certain color. I have all of that working except for when it grabs the data and populates the cells, I want it to check a certain field for the color and use that color for the cell color, any ideas? Here is my code so far.
Private Sub Form_Load()Dim db_file As StringDim statement As StringDim conn As ADODB.ConnectionDim rs As ADODB.RecordsetDim c As IntegerDim r As IntegerDim col_wid() As SingleDim field_wid As Single ' Open a connection. Set conn = New ADODB.Connection conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=TrainingManagementDB2;Data Source=kg-cfsce-2b" conn.Open ' Select the data. statement = "SELECT * FROM Vehiclenov" ' Get the records. Set rs = conn.Execute(statement, , adCmdText) ' Use one fixed row and no fixed columns. MSFlexGrid1.Rows = 6 MSFlexGrid1.FixedRows = 5 MSFlexGrid1.Cols = 4 MSFlexGrid1.FixedCols = 3 ' Display column headers. MSFlexGrid1.Rows = 6 MSFlexGrid1.Cols = rs.Fields.Count ReDim col_wid(0 To rs.Fields.Count - 1) For c = 0 To rs.Fields.Count - 1 MSFlexGrid1.TextMatrix(1, c) = rs.Fields(c).Name col_wid(c) = TextWidth(rs.Fields(c).Name) Next c ' Display the values for each row. r = 1 Do While Not rs.EOF MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1 For c = 0 To rs.Fields.Count - 1 MSFlexGrid1.TextMatrix(r, c) = rs.Fields(c).Value & vbNullString ' If MSFlexGrid1.TextMatrix(r, c) = "1" Then MSFlexGrid1.CellBackColor = &HFFF000 ' See how big the value is. field_wid = TextWidth(rs.Fields(c).Value & vbNullString) If col_wid(c) < field_wid Then col_wid(c) = field_wid Next c rs.MoveNext r = r + 1 Loop ' Change cell color of row 3 and 4 MSFlexGrid1.Row = 3 t = 0 For t = 0 To 2 For i = 0 To MSFlexGrid1.Cols - 1 MSFlexGrid1.Col = i MSFlexGrid1.CellBackColor = &HFFF000 Next t = t + 1 MSFlexGrid1.Row = MSFlexGrid1.Row + 1 Next ' Change cell color of color code chart cells MSFlexGrid1.Row = 1 MSFlexGrid1.Col = 11 MSFlexGrid1.CellBackColor = &HFF80FF MSFlexGrid1.Row = 2 MSFlexGrid1.Col = 11 MSFlexGrid1.CellBackColor = &H80C0FF MSFlexGrid1.Row = 1 MSFlexGrid1.Col = 12 MSFlexGrid1.CellBackColor = &HFF& MSFlexGrid1.Row = 2 MSFlexGrid1.Col = 12 MSFlexGrid1.CellBackColor = &HC0C0FF MSFlexGrid1.Row = 1 MSFlexGrid1.Col = 13 MSFlexGrid1.CellBackColor = &HFF00& MSFlexGrid1.Row = 2 MSFlexGrid1.Col = 13 MSFlexGrid1.CellBackColor = &HFFFF00 MSFlexGrid1.Row = 2 MSFlexGrid1.Col = 15 MSFlexGrid1.CellBackColor = &H808080 rs.MoveFirst rs.Close ' change cell color of rows 5 to end and only columns 1-3r = 5rs.Open "select count(*) as recordcount from VehicleNov" Do While Not r = rs.Fields(0).Value + 1 MSFlexGrid1.Row = r t = 0 For t = 0 To 2 For i = 0 To 2 MSFlexGrid1.Col = i MSFlexGrid1.CellBackColor = &HC0F0FF Next t = t + 1 Next r = r + 1 Loop ' Close the recordset and connection. rs.Close conn.Close ' Set the column widths. For c = 0 To MSFlexGrid1.Cols - 1 MSFlexGrid1.ColWidth(c) = col_wid(c) + 240 Next c End Sub
Change Row (or Cell) Background Color In DBGRID
I need change a row background color in a dbgrid control (or a cell background color if it isn´t posible).
I´m using SetBKColor function but it fails.
Dim dc As Long
dc = GetDC(dbgrid1.hwndeditor)
SetBkMode dc, OPAQUE
SetBkColor dc, RGB(255, 0, 0)
ReleaseDC dbgrid1.hwndeditor, dc
Somebody know how change a row background color on a dbgrid ?
Change Background Color Of A Cell In A Grid.
I want to change the background color of a few cells in a grid. The only way seems to be changing them one by one in a For Next loop :
Code:Grid1.Col = ColNum
For Counter = UpRow To DownRow
Grid1.Row = Counter
Grid1.CellBackColor = &HC0FFFF
Well , When there are more than 10 rows in a column, the execution of the loop is somehow slow and the user can see the cells being colored one by one. I was wondering if there were a method I could specify a range of cells and then change the back color at once.
Edited by - lucky_duke on 11/26/2004 7:42:06 AM