473,395 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Listbox response to change color of grid.

Hi, Using VB6, I need to change color of a 'Grid' I have coded under 'Declarations.

This color change notification needs to come from a listbox on my form.

I need to reference my 'Dim NewGridColorRequested' to tell the grid to now be drawn in new selected color from the list box color selected.

My Grid Code:
Expand|Select|Wrap|Line Numbers
  1. 'Draw Grid
  2. Public Sub DrawGrid(GridSize As Single)
  3.     Dim OldDMode As Integer, OldDSize As Integer, CX As Single, CY As Single
  4.     Dim GridSpan As Integer
  5.     Dim ColNumberName
  6.     Dim GridCircleColors
  7.  
  8.  
  9.     OldDMode = Document.DrawMode
  10.     MousePointer = 11
  11.     DoEvents
  12.     Document.DrawMode = vbInvert
  13.     OldDrawSize = Document.DrawWidth
  14.     Document.DrawWidth = 1
  15.     GridSpan = CInt(GridSize * 1440)
  16.     CY = GridSpan
  17.     CX = GridSpan
  18.    ' Column = 0      ' Put to start naming/numbering my columns
  19.     Rows = Int(Document.ScaleHeight / GridSpan)
  20.     For Row = 1 To Int(Document.ScaleHeight / GridSpan)
  21.     Cols = Int(Document.ScaleWidth / GridSpan)
  22.         For Col = 1 To Int(Document.ScaleWidth / GridSpan)
  23.             Document.PSet (CX, CY)
  24.             CX = CX + GridSpan                                          '
  25.             Next
  26.           CX = GridSpan
  27.         CY = CY + GridSpan
  28.     Next
  29.     Document.DrawMode = OldDMode
  30.     Document.DrawWidth = OldDrawSize
  31.      MousePointer = 0
  32. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  33.  
  34.  
  35. ColsTotal = Cols
  36.  
  37.  
  38.  
  39. DrwX = 0
  40. DrwY = 0
  41. BeepCount = 0
  42. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  43. '  START Naming my GRID in loop sample
  44. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  45.    NamedNumber = 0
  46. '   frmMDIMainPage ListCordsNamed
  47.  
  48. For Outer = 0 To Cols
  49.             DrwX = DrwX + 120
  50.     For Inner = 0 To Rows
  51.              DrwY = DrwY + 120
  52.                     Document.Circle (DrwX, DrwY), 9, RGB(255, 0, 255)
  53.  
  54.  
  55.     Next Inner
  56.     DrwY = 0
  57. Next Outer
  58.  
  59.  
  60.  
  61. End Sub
  62.  
  63. My List box code"
  64. ''''''''''''''''''''''''''''''''''''''''''''''''''''
  65. ''''''Grid Color '''''''''''''''''''''''''''''''''''''''''''''
  66. '''''''''''''''''''''''''''''''''''''''''''''''''''''
  67.  
  68. Public Sub List2_Click()
  69. Select Case List2.Text
  70. Case "Black"
  71.             Document.Cls
  72.                 DrawGrid GridPix
  73.                   '  frmElectronicPageChild.DrawGrid as
  74.                  ' I named my Form1 as frmElectronicPageChild                           'NewGridColorRequested = RGB(0, 0, 0) ' This colors the circle used as the grid points
  75. Case "Red"
  76.             Document.Cls
  77.                 DrawGrid GridPix
  78.                     GridCircleColors = RGB(255, 0, 0)
  79. Case "Green"
  80.             Document.Cls
  81.                 GridCircleColors = RGB(0, 255, 0)
  82.                     DrawGrid GridPix
  83.  
  84. Case "Yellow"
  85.             Document.Cls
  86.                 DrawGrid GridPix
  87.                     GridCircleColors = RGB(255, 255, 0)
  88. Case "Blue"
  89.             Document.Cls
  90.                 DrawGrid GridPix
  91.                     GridCircleColors = RGB(0, 0, 255)
  92. Case "Magenta"
  93.             Document.Cls
  94.                 DrawGrid GridPix
  95.                     GridCircleColors = RGB(255, 0, 255)
  96. Case "Cyan"
  97.             Document.Cls
  98.                 DrawGrid GridPix
  99.                     GridCircleColors = RGB(0, 255, 255)
  100.  
  101. End Select
  102. End Sub
Dec 5 '12 #1
6 2091
Rabbit
12,516 Expert Mod 8TB
So what problem are you having? Are you getting errors? What are the error messages? Is it not doing what you want? What is it doing instead?
Dec 5 '12 #2
The attempts I make to contact the Griddraw from my list box response are not being received by the griddraw code. My new 'specs' on color remain 'empty.
Dec 5 '12 #3
Rabbit
12,516 Expert Mod 8TB
You need to do some basic debugging first.

1) Make sure List2.Text is returning what you think it's returning.

2) Make sure GridPix is set to what you think it's being set to. I'm not even sure why you're passing GridPix when you in no way vary it's value in your code.

3) You have not defined the variable GridCircleColors so I don't see the purpose of setting it. you don't even use it for anything.
Dec 6 '12 #4
Rabbit, thanks for your prompt reply,sorry mine is a bit later - I am GMT +2.
1)Will sort it, your answer showingList2.Text certainly helped me on the right track.
A comment follows POINT 2 and 3 .
2)Here I am lost, you replied, "Make sure GridPix is set to what you think it's being set to. Then you mention, "vary it's code".
3) I will define variable, 'GridCircleColors'
Comment:
I am a serious 'Amateur' or 'Novice' at VB6.
I have learnt such as I know from self help books only.
I sourced the GridPix code off the 'Net to make a Grid where upon, later, I will want to make reference to the various points as needed.
I initially wanted to put my Controls on a MDI 'Parent' Form and allow the Picbox holding the GridPix to be on the 'Child', I fell apart trying to reference across the Forms, and in my confusion,that's probably where the errors Point 1) and 3) arose.
Thank you for helping.
Dec 6 '12 #5
Rabbit
12,516 Expert Mod 8TB
In regards to 2, you reference a variable called GridPix. But you never set it anywhere in your code. As for the varying the code, that's not what I said. I said vary the value. Basically, you seem to be passing a value that's always going to be the same. So why pass it at all?

In regards to 3, I have no idea what you said.
Dec 6 '12 #6
Rabbit, Thanks for reply and help.
My Point 2: I shall sort out GridPix. Re: reference a variable called GridPix.
My Point 3: was confusing - sorry. I was trying to say,
I am using a MDI Parent and Child Forms.
A ListBox2 response from User on Parent Form should cause Grid Color to change on Grid inside a PicBox on the Child Form.
I think the addressing is similiar to frm.MDI.(...?)
- Should I need help after my next attempt, i will ask again, with a more detailed question.
Dec 6 '12 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sugapablo | last post by:
Can anyone help me out with some code to change three table cells (<td>) when one is hovered over? I have a calendar grid where each day is made up of three table cells and I want all three to...
1
by: Robbo | last post by:
Hello, I created a datagrid with a few hyperlink columns.. How do i change the color of the hyperlink itself? BLUE is a bit bad on my datagrid color scheme. Thanks, Rob
2
by: HS1 | last post by:
Hello all Do you know how to change color of a button when the mouse is over it (like a button in manu bar can change its color in a website) in VB.net Thank you S.Hoa
3
by: Mamatha | last post by:
Hi I want to change the color of icon,How it can be opened? and how can i change color. If any one knows please let me know Thanks in advance. Mamatha
1
by: Vd | last post by:
How do I change color of the tab. I have changed the color, but when I run the application the color is still using the original color which is the control color.
2
by: TonyVal - MSDN News | last post by:
Hi All, Anyone know how to change color for a 3D button like this button control does? http://www.econtechvn.com/en/aquabutton_detail.htm I see it is really cool. But, don't know how to do...
0
by: Serdge Kooleman | last post by:
Winform (DataGrid) when i'm editing the text in the curent cell, i need to change color/font/background in it. thank you
6
by: sr | last post by:
please help i have problem: I know how to change color row in table when my mouse is over on this row and change color to another color when my mouse is out from this row. but i dont know how to...
3
by: nma | last post by:
Hi How do I make the cell change color to 'black' after I click on it. The cell will remain black color until I click another cell which will also change to black. I can do the mouseover and...
3
by: prabhuaradhan | last post by:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.