|
hi
can i move a image or bitmap from one cell to another using keyboard or mouse.
Hope a good result from you.
with regards / Ravikumar.G
|
|
|
|
|
Yep this is possible but you must use mouse move, when you do every pixel in a cell is an event. I found a way around this, the code is long in the dll and my runtime. Just make sure your code only picks one pixel and no more in a cell, and you need code for the four quadrants - top left - top right - bottom right - bottom left if selecting more than one cell, I wrote this code and put it into the graphicgrid class. Here's somthing to get you wondering and thinking: Lysis.
'Step One:
'---------
'Create a form,
'Add a grid or two,
'Open up the code editor
'Add - Dim CellBorder As Boolean = True
'
'Step Two:
'---------
'Open up the graphicgrid.VB* control and replace everthing with the following, don't
'change the cCell.VB code:
'
'You now have HIGHLIGHT and CROSS HAIRS on the grids - Enjoy - LYSIS 20006
'==============================================================================
'
Public Class graphicgrid
Inherits System.Windows.Forms.UserControl
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'UserControl1 overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents grid As System.Windows.Forms.PictureBox
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.grid = New System.Windows.Forms.PictureBox
Me.SuspendLayout()
'
'grid
'
Me.grid.Dock = System.Windows.Forms.DockStyle.Fill
Me.grid.Location = New System.Drawing.Point(0, 0)
Me.grid.Name = "grid"
Me.grid.Size = New System.Drawing.Size(128, 88)
Me.grid.TabIndex = 0
Me.grid.TabStop = False
'
'graphicgrid
'
Me.Controls.Add(Me.grid)
Me.Name = "graphicgrid"
Me.Size = New System.Drawing.Size(128, 88)
Me.ResumeLayout(False)
End Sub
#End Region
' Define Events, for descriptions see the event subs
'
Public Event gridClick(ByVal sender As Object, ByVal GridPoint As Point)
Public Event gridDoubleClick(ByVal sender As Object, ByVal GridPoint As Point)
Public Event gridMouseMove(ByVal sender As Object, ByVal GridPoint As Point)
Public Event gridMouseUp(ByVal sender As Object, ByVal e As Windows.Forms.MouseEventArgs, ByVal GridPoint As Point)
Public Event gridMouseDown(ByVal sender As Object, ByVal e As Windows.Forms.MouseEventArgs, ByVal GridPoint As Point)
' A few vars to hold custom Properties
'
Public propShowGrid As Boolean = True
Public propGridColor As Color = Color.White
Public propCells As New Size(10, 10) 'Number Cells X Y - Default is (10, 10)
Public CellSize As Size 'Size = Grid Size X and Y
Public CellContains As New cCell
'Use for Highlight 1st grid clicked
Public propCellBorder As Boolean = False 'Highlight - Boolean Switch
Public propCrossHair As Boolean = False 'Cross Hairs - Boolean Switch
''Private Sub Graphicgrid2_MouseMove(ByVal sender As System.Object, ByVal GridPoint As System.Drawing.Point) Handles Graphicgrid2.gridMouseMove
'
' Events, make sure to update the grid when these happen
'
Private Sub graphicgrid_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.BackColorChanged
setGrid()
End Sub
Private Sub graphicgrid_ForeColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.ForeColorChanged
setGrid()
End Sub
Private Sub graphicgrid_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
setGrid()
End Sub
Private Sub graphicgrid_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
setGrid()
End Sub
Private Sub graphicgrid_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Move
setGrid()
End Sub
Private Sub graphicgrid_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
setGrid()
End Sub
' Properties
'
Public Property CellBorder() As Boolean 'Toggle - Call From Code - Show highlight if true...
Get
Return propCellBorder
End Get
Set(ByVal Value As Boolean)
propCellBorder = Value
setGrid()
End Set
End Property
Public Property CrossHair() As Boolean 'Toggle - Call From Code - Draw Cross Hairs if true...
Get
Return propCrossHair
End Get
Set(ByVal Value As Boolean)
propCrossHair = Value
setGrid()
End Set
End Property
Public Property ShowGrid() As Boolean
Get
Return propShowGrid
End Get
Set(ByVal Value As Boolean)
propShowGrid = Value
setGrid()
End Set
End Property
Public Property GridColor() As Color
Get
Return propGridColor
End Get
Set(ByVal Value As Color)
propGridColor = Value
setGrid()
End Set
End Property
Public Property Cells() As Size 'Cells = Number of cells for X and Y, Name = graphicGrid
Get
Return propCells
End Get
Set(ByVal Value As Size) 'PropCells = Me.Grid.Size
propCells = Value
setGrid()
End Set
End Property
' Sets the background image of the grid
'
Private Sub graphicgrid_BackgroundImageChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.BackgroundImageChanged
grid.BackgroundImage = Me.BackgroundImage
End Sub
' Resets or Applies new grid settings
'
Private Sub setGrid()
grid.BackColor = Me.BackColor
grid.ForeColor = Me.ForeColor
CellSize.Width = Me.Width / propCells.Width 'CellSize.Width = Grid.Width / Number of cells wide
CellSize.Height = Me.Height / propCells.Height
grid.Invalidate()
End Sub
' Sub: setCell
' Diz: Sets the contents of the cell by adding the attributes
' to the collection.
' Use: object.setCell(new point(1, 1), color.red)
'
Public Overloads Sub setCell(ByVal Cell As Point, ByVal newColor As Color)
CellContains.add(Cell, newColor)
grid.Invalidate()
End Sub
' Sub: setCell
' Diz: Sets the contents of a range of cells by adding the attributes
' to the collection.
' Use: object.setCell({new point(1, 1), new point(1, 2)}, color.red)
'
Public Overloads Sub setCell(ByVal Cells As Point(), ByVal newColor As Color)
Dim tmpPoint As Point
For Each tmpPoint In Cells
CellContains.add(tmpPoint, newColor)
Next
grid.Invalidate()
End Sub
' Sub: setCell
' Diz: Sets the contents of the cell by adding the attributes
' to the collection.
' Use: object.setCell(new point(1, 1), new bitmap("cell.bmp"))
'
Public Overloads Sub setCell(ByVal Cell As Point, ByVal newBitmap As Bitmap)
CellContains.add(Cell, newBitmap)
grid.Invalidate()
End Sub
' Sub: setCell
' Diz: Sets the contents of a range of cells by adding the attributes
' to the collection.
' Use: object.setCell({new point(1, 1), new point(1, 2)}, new bitmap("cell.bmp"))
'
Public Overloads Sub setCell(ByVal Cells As Point(), ByVal newBitmap As Bitmap)
Dim tmpPoint As Point
For Each tmpPoint In Cells
CellContains.add(tmpPoint, newBitmap)
Next
grid.Invalidate()
End Sub
' Sub: removeCell
' Diz: Removes a cell by deleting the attributes from the collection
' Use: object.removeCell(new point(1, 1))
'
Public Overloads Sub removeCell(ByVal Cell As Point)
CellContains.remove(Cell)
grid.Invalidate()
End Sub
' Sub: removeCell
' Diz: Removes a range of cells by deleting the attributes from the collection
' Use: object.removeCell({new point(1, 1), new point(1, 2)})
'
Public Overloads Sub removeCell(ByVal Cells As Point())
Dim tmpPoint As Point
For Each tmpPoint In Cells
CellContains.remove(tmpPoint)
Next
grid.Invalidate()
End Sub
' Sub: clearCell
' Diz: Removes all the cells by deleting the attributes from the collection
' Use: object.clearCells
'
Public Sub clearCells()
CellContains.Clear()
grid.Invalidate()
End Sub
Dim MUPoint As Point 'New Point(0, 0)
Dim MMPoint As Point 'New Point(0, 0)
Dim MDPoint As Point 'New Point(0, 0)
' Event: grid_MouseDown
' Diz: When the user moves the mouse inside the grid
' Return: The mouse and A point structure indicating the grid's cell
'
Private Sub grid_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grid.MouseDown
Dim clientPoint As System.Drawing.Point = Me.PointToClient(Me.MousePosition)
RaiseEvent gridMouseDown(Me, e, New Point(Int(clientPoint.X / CellSize.Width), Int(clientPoint.Y / CellSize.Height)))
'
'The following MDPoint returns top left X and Y for clicked cell
' WORKING....
If CellBorder = True Then
Dim myPointX As Integer
Dim myPointY As Integer
myPointX = clientPoint.X - (CellSize.Width / 2)
myPointY = clientPoint.Y - (CellSize.Height / 2)
myPointX = myPointX / CellSize.Width
myPointY = myPointY / CellSize.Height
MDPoint = New Point(Int(myPointX * CellSize.Width), Int(myPointY * CellSize.Height))
End If
End Sub
'Dim MDPoint2 As Point 'Negative of mouse down
' Event: grid_MouseMove
' Diz: When the user moves the mouse inside the grid
' Return: A point structure indicating the grid's cell
'
Private Sub grid_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grid.MouseMove
Dim clientPoint As System.Drawing.Point = Me.PointToClient(Me.MousePosition)
RaiseEvent gridMouseMove(Me, New Point(Int(clientPoint.X / CellSize.Width), Int(clientPoint.Y / CellSize.Height)))
'
'The following MMPoint returns lower right X and Y for clicked cell
' WORKING....
If CellBorder = True Then
Dim myPointX As Integer
Dim myPointY As Integer
myPointX = clientPoint.X - (CellSize.Width / 2)
myPointY = clientPoint.Y - (CellSize.Height / 2)
myPointX = myPointX / CellSize.Width
myPointY = myPointY / CellSize.Height
MMPoint = New Point(Int(myPointX * CellSize.Width + CellSize.Width), Int(myPointY * CellSize.Height + CellSize.Height))
End If
End Sub
' Event: grid_MouseUp
' Diz: When the user moves the mouse inside the grid
' Return: The mouse and A point structure indicating the grid's cell
'
Private Sub grid_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grid.MouseUp
Dim clientPoint As System.Drawing.Point = Me.PointToClient(Me.MousePosition)
RaiseEvent gridMouseUp(Me, e, New Point(Int(clientPoint.X / CellSize.Width), Int(clientPoint.Y / CellSize.Height)))
If CellBorder = True Then
MUPoint = New Point(e.X, e.Y)
End If
End Sub
'Point = New Point(0, 0)
' Event: grid_Paint
' Diz: Paints the grid
'
Private Sub grid_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles grid.Paint
Dim contents As cCell
Dim x As Integer
Dim y As Integer
' If there are any custom attributes draw them out
'
For Each contents In CellContains
If contents.cellbitmap Is Nothing Then
e.Graphics.FillRectangle(New SolidBrush(contents.cellColor), contents.cellPoint.X * CellSize.Width, _
contents.cellPoint.Y * CellSize.Height, CellSize.Width, CellSize.Height)
Else
e.Graphics.DrawImage(contents.cellbitmap, contents.cellPoint.X * CellSize.Width, _
contents.cellPoint.Y * CellSize.Height, CellSize.Width, CellSize.Height)
End If
Next
' If they want the grid draw that as well
'
If ShowGrid = True Then
For x = 0 To Cells.Width
For y = 0 To Cells.Height
e.Graphics.DrawRectangle(New Pen(GridColor), x * CellSize.Width, y * CellSize.Height, CellSize.Width, CellSize.Height)
Next
Next
End If
'
'
'XXXXXXXXXXXX Grid HIGHLIGHT and BORDER COLOR XXXXXXXXXXXX By Eric Blake 2006 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'WORKING - Pens - Style - Color - Size:
Dim gridUpperXY As Point = New Point(0, 0)
Dim gridLowerXY As Point = New Point(CellSize.Width * propCells.Width, CellSize.Height * propCells.Height)
Dim myColorF As Color = Color.FromArgb(100, 192, 156, 214) 'Change the FILL color here
Dim myColor1 As Color = Color.FromArgb(150, 255, 255, 255) 'Change 1st cell color here
Dim myPen As New Pen(Color.FromArgb(255, 40, 20, 194), 2) 'Top Border Color - pen attributes
Dim myPenL As New Pen(Color.Cornsilk, 2) 'Lower Border Color - pen attributes
Dim myPenB As New Pen(Color.FromArgb(255, 70, 130, 180), 2) '(255, 40, 20, 194), 2) 'LightSteelGrey - Grid Border - pen attributes
Dim myPenCrossHair As New Pen(Color.Red, 0.25) 'FromArgb(255, 189, 24, 240), 1)
myPen.DashStyle = Drawing2D.DashStyle.Dot
myPenL.DashStyle = Drawing2D.DashStyle.Solid
myPenB.DashStyle = Drawing2D.DashStyle.Solid
'
'Grid Border Color
e.Graphics.DrawRectangle(myPenB, gridUpperXY.X, gridUpperXY.Y, gridLowerXY.X, gridLowerXY.Y)
'
'Highlight.......Start..........................................................................................................
'Highlighted Rectangle fill color
'First cell of selection is transparent
'Border = two colors, one on top of the other - Lower drawn first
'
'WORKING Draw rectangle if x and y are positive of 0 when mouse moves
If CellBorder = True Then
Dim pt1x As Integer = MDPoint.X 'Top Left
Dim pt1y As Integer = MDPoint.Y '
Dim pt2x As Integer = MMPoint.X 'Bottom Right
Dim pt2y As Integer = MMPoint.Y
If pt2x <> 0 Or pt2y <> 0 Then 'Make sure nothing happens till mouse move has a value.
If pt2x > pt1x And pt2y > pt1y Then 'From mouse down to positive xy numbers
e.Graphics.FillRectangle(New SolidBrush(myColorF), _
Math.Min(pt2x + 1, pt1x + 1), _
Math.Min(pt2y + 1, pt1y + 1), _
Math.Abs(pt2x - pt1x - 1), _
Math.Abs(pt2y - pt1y - 1))
e.Graphics.FillRectangle(New SolidBrush(myColor1), _
MDPoint.X + 1, _
MDPoint.Y + 1, _
CellSize.Width - 1, _
CellSize.Height - 1)
e.Graphics.DrawRectangle(myPenL, _
Math.Min(pt2x, pt1x), _
Math.Min(pt2y, pt1y), _
Math.Abs(pt2x - pt1x), _
Math.Abs(pt2y - pt1y))
e.Graphics.DrawRectangle(myPen, _
Math.Min(pt2x, pt1x), _
Math.Min(pt2y, pt1y), _
Math.Abs(pt2x - pt1x), _
Math.Abs(pt2y - pt1y))
'If CrossHair = True Then 'If true draw both cross hairs
Dim halfX As Integer = pt2x - CellSize.Width / 2
e.Graphics.DrawLine(myPenCrossHair, halfX, 0, halfX, Size.Height)
Dim halfy As Integer = pt2y - CellSize.Height / 2
e.Graphics.DrawLine(myPenCrossHair, 0, halfy, Size.Width, halfy)
'End If
End If
'WORKING Draw rectangle if x and y are Negative of 0 when mouse moves
If pt2x < pt1x + CellSize.Width And pt2y < pt1y + CellSize.Height * 2 Then
pt2x = pt2x - CellSize.Width * 2
pt2y = pt2y - CellSize.Height * 2
e.Graphics.FillRectangle(New SolidBrush(myColorF), _
Math.Min(pt2x + CellSize.Width, pt1x), _
Math.Min(pt2y + CellSize.Height, pt1y), _
Math.Abs(pt2x - pt1x), _
Math.Abs(pt2y - pt1y))
e.Graphics.FillRectangle(New SolidBrush(myColor1), _
MDPoint.X + 1, _
MDPoint.Y + 1, _
CellSize.Width - 1, _
CellSize.Height - 1)
e.Graphics.DrawRectangle(myPenL, _
Math.Min(pt2x + CellSize.Width, pt1x), _
Math.Min(pt2y + CellSize.Height, pt1y), _
Math.Abs(pt2x - pt1x), _
Math.Abs(pt2y - pt1y))
e.Graphics.DrawRectangle(myPen, _
Math.Min(pt2x + CellSize.Width, pt1x), _
Math.Min(pt2y + CellSize.Height, pt1y), _
Math.Abs(pt2x - pt1x), _
Math.Abs(pt2y - pt1y))
Dim halfX As Integer = pt2x + CellSize.Width / 2 + CellSize.Width
e.Graphics.DrawLine(myPenCrossHair, halfX, 0, halfX, Size.Height)
Dim halfy As Integer = pt2y + CellSize.Height / 2 + CellSize.Height
e.Graphics.DrawLine(myPenCrossHair, 0, halfy, Size.Width, halfy)
End If
'WORKING Draw rectangle if X is Negative and Y is positive of 0 when mouse moves
If pt2x < pt1x + CellSize.Width And pt2y > pt1y Then
pt2x = pt2x - CellSize.Width * 2
e.Graphics.FillRectangle(New SolidBrush(myColorF), _
Math.Min(pt2x + CellSize.Width, pt1x), _
Math.Min(pt2y + 1, pt1y + 1), _
Math.Abs(pt2x - pt1x), _
Math.Abs(pt2y - pt1y))
e.Graphics.FillRectangle(New SolidBrush(myColor1), _
MDPoint.X + 1, _
MDPoint.Y + 1, _
CellSize.Width - 1, _
CellSize.Height - 1)
e.Graphics.DrawRectangle(myPenL, _
Math.Min(pt2x + CellSize.Width, pt1x), _
Math.Min(pt2y + CellSize.Height, pt1y), _
Math.Abs(pt2x - pt1x), _
Math.Abs(pt2y - pt1y))
e.Graphics.DrawRectangle(myPen, _
Math.Min(pt2x + CellSize.Width, pt1x), _
Math.Min(pt2y + CellSize.Height, pt1y), _
Math.Abs(pt2x - pt1x), _
Math.Abs(pt2y - pt1y))
Dim halfX As Integer = pt2x + CellSize.Width / 2 + CellSize.Width
e.Graphics.DrawLine(myPenCrossHair, halfX, 0, halfX, Size.Height)
Dim halfy As Integer = pt2y - CellSize.Height / 2
e.Graphics.DrawLine(myPenCrossHair, 0, halfy, Size.Width, halfy)
End If
'WORKING Draw rectangle if Y is Negative and X is positive of 0 when mouse moves
If pt2x > pt1x And pt2y < pt1y + CellSize.Height Then
pt2y = pt2y - CellSize.Height * 2
e.Graphics.FillRectangle(New SolidBrush(myColorF), _
Math.Min(pt2x + CellSize.Width, pt1x), _
Math.Min(pt2y + CellSize.Height, pt1y), _
Math.Abs(pt2x - pt1x), _
Math.Abs(pt2y - pt1y))
e.Graphics.FillRectangle(New SolidBrush(myColor1), _
MDPoint.X + 1, _
MDPoint.Y + 1, _
CellSize.Width - 1, _
CellSize.Height - 1)
e.Graphics.DrawRectangle(myPenL, _
Math.Min(pt2x + CellSize.Width, pt1x), _
Math.Min(pt2y + CellSize.Height, pt1y), _
Math.Abs(pt2x - pt1x), _
Math.Abs(pt2y - pt1y))
e.Graphics.DrawRectangle(myPen, _
Math.Min(pt2x + CellSize.Width, pt1x), _
Math.Min(pt2y + CellSize.Height, pt1y), _
Math.Abs(pt2x - pt1x), _
Math.Abs(pt2y - pt1y))
Dim halfX As Integer = pt2x - CellSize.Width / 2
e.Graphics.DrawLine(myPenCrossHair, halfX, 0, halfX, Size.Height)
Dim halfy As Integer = pt2y + CellSize.Height / 2 + CellSize.Height
e.Graphics.DrawLine(myPenCrossHair, 0, halfy, Size.Width, halfy)
End If
End If
Else
'Reset Mouse Position to zero
MDPoint = New Point(0, 0)
MMPoint = New Point(0, 0)
MUPoint = New Point(0, 0)
End If
'Dispose of pens
myPen.Dispose()
myPenL.Dispose()
myPenB.Dispose()
myPenCrossHair.Dispose()
End Sub
' Event: grid_Click
' Diz: When the user clicks inside the grid
' Return: A point structure indicating the grid's cell
'
Private Sub grid_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles grid.Click
Dim clientPoint As System.Drawing.Point = Me.PointToClient(Me.MousePosition)
RaiseEvent gridClick(Me, New Point(Int(clientPoint.X / CellSize.Width), Int(clientPoint.Y / CellSize.Height)))
End Sub
' Event: grid_DoubleClick
' Diz: When the user clicks inside the grid
' Return: A point structure indicating the grid's cell
'
Private Sub grid_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles grid.DoubleClick
Dim clientPoint As System.Drawing.Point = Me.PointToClient(Me.MousePosition)
RaiseEvent gridDoubleClick(Me, New Point(Int(clientPoint.X / CellSize.Width), Int(clientPoint.Y / CellSize.Height)))
End Sub
End Class
|
|
|
|
|
Hello!
I made a big grid, and fill them with .bmp-s.
But then I can't get back the image name, or any other property to compare the cells images with the images that i fill the grid.
THX!
T
|
|
|
|
|
Hi,
How can I get a property from a single cell.
For example:
I would like to change the color of a cell filled with green color to red and vise versa.
<br />
Private Sub gPlot_gridClick(ByVal sender As Object, ByVal GridPoint As System.Drawing.Point) Handles gPlot.gridClick<br />
If gPlot.CellContains.cellColor.Equals(Color.Red) Then gPlot.setCell(GridPoint, Color.Green)<br />
If gPlot.CellContains.cellColor.Equals(Color.Green) Then gPlot.setCell(GridPoint, Color.Red)<br />
<br />
End Sub
How do I make this possible?
best regards /Joakim .A
Joakim .A - State: VB6 -> VB.NET
|
|
|
|
|
Hi from Sydney - This is a great grid
Yes you can change the color in code I have done it!
Try somthing like:
Dim c1 As Color.Color.Red
Dim c2 As Color.Color.Green
Dim c3 As Color.Color.Yellow
Dim c4 As Color.Color.Blue
graphicgrid.sellColor(Cell, New(x, y), Color.Color.c1
Then use the veriable in your code to test and change the color!
Hope this help's
EAB lysis_lysis@yahoo.com.au
|
|
|
|
|
The DLL currently doesn't allow you to read the properties of any given cell.
However, I have modified the source code and compiled a working DLL to allow you to do this. Essentially I have added a "getCell(Point) as Color" function, which returns the colour of any given cells' points.
This can be found at www.n7studios.co.uk
Sample Code for use in your form:
Dim currCellColor As Color
currCellColor = gridSchedule.getCell(GridPoint)
If currCellColor = Color.Empty Then
' Cell is using BackColor property - set cell to = backcolor...
gridSchedule.setCell(GridPoint, gridSchedule.BackColor)
' ... and re-get the cell's color
currCellColor = gridSchedule.getCell(GridPoint)
End If
If currCellColor = Color.Green Then
gridSchedule.setCell(GridPoint, Color.Red)
Else
gridSchedule.setCell(GridPoint, Color.Green)
End If
|
|
|
|
|
|
Can the grid be made to scroll? I have tried to set auto scroll to true, but it doesn't do it. The component will be very useful to me if I can make it scroll as I need at least 50 cells. Thank you.
|
|
|
|
|
You can use scrollbars...
I will give you the following hints:
You can't use auto scroll on a form or some other controls!
so you need to set them up manualy.
1)Open a new form
2)Put a panel on it
3)Put a vscroll and hscroll on the panel and dock them left and bottom
4)Load a grid onto the panel
5)Code the scrollbars for min, max and output as integers
6)Convert the output integers to negative numbers put into variables
7)Put these variables into the grids start location....
grphicalGrid1.Location(-100, -100) etc
Hope this helps you learn a bit more about VB.Net
lysis_lysis@yahoo.com.au
Lysis 30-10-05
Sydney Australia
|
|
|
|
|
Hi,
Is there any way to 'read' attributes of each individual cell in the grid? For example, I would like to scan thru the whole grid for each cell individually for the cell color, so that i can 'do' something if a certain cell have been found to be of certain color.
|
|
|
|
|
I would like to know this too.
|
|
|
|
|
Hi,
Can we draw line, circle, text, polygon in grid.
Swapnil Pithwa
|
|
|
|
|
There's the possibility to draw letter, or graphics with GDI on each cell ?
Thanks
|
|
|
|
|
Hi,
Can anybody tell me compitable version of .NET to use this Graphical grid component.
Thanks
Swapnil Pithwa
|
|
|
|
|
I am sorry, I don't think I fully understand what you need.
You should be able to use the grid with any version of .NET.
Matthew Hazlett
Windows 2000/2003 MCSE
Never got an MCSD, go figure...
|
|
|
|
|
Visual Studio.NET Version 7.0.9466
Microsoft .NET Framework 1.0.3705
= This code won't work. Not only does Visual Studio not allow the import of the DLL file, I can't even open the .SLN file. Meh, time to upgrade. Stupid Microsoft.
|
|
|
|
|
Anyone have any ideas for adding a button to the grid. The grid is a picture box and and a picture box doesn't seem to allow a button on it. I'd like something like:
Graphicgrid1.setCell(New Point(Int(Point1, Point2)), myButton)
Any ideas?
Thanks
|
|
|
|
|
Well it should be possible.
Possibility #1:
Put the bitmap of the button you want in the cell then just check to see if it was clicked.
Possibility #2:
Modify the DLL code and add a button overload. Set it to the x,y,z of the cell.
Matthew Hazlett
Windows 2000/2003 MCSE
Never got an MCSD, go figure...
|
|
|
|
|
Hmmm.
Possibility #1 - Are you just saying to create an image file of the button and add that to the cell? I can do that but the button has properties that I'd like to use as well (text, etc..)
Possibility #2 - I tried this but it doesn't seem to work. Its pretty easy to just take the bitmap overload functions and create button overloads out of them so I don't think I did it wrong. However the button doesn't show up. After I did the setCell call and passed it the button, I looked at the GraphicGrid.controls.count property and it was 1 (the grid). So my button isn't being added. Also, how do you set the z property?
Thanks again.
|
|
|
|
|
Place a panel in the grid then add a button to it.
Works for me
Lysis
|
|
|
|
|
Matt,
I am relatively new to OO and classes and only a novice programmer. My question is a basic one. I have reviewed the cCell class and have tried to reference it in my code. I would like to randomly color cells in the grid control without having to reference each one with its (x,y) coordinate notation. My thought was to use the cCell collection, basically:
for each cell in graphicgrid.cCell
Paint the cell
next cell
Is this pseudo code correct? Is cCell a collection of all of the cells in a graphicgrid object?
Thanks in advance,
Fred
|
|
|
|
|
I've checked back religiously in hopes that someone would answer my question. I realize it is rather simple, but can't move past it. Can anyone help? I definitly like the control, and just want to make the most efficient code that I can with it.
Thanks,
Fred
|
|
|
|
|
No, you can not use foreach. The cells are not a collectioon you need to do each cell indivigually. Maybe try a for loop ?
Matthew Hazlett
Windows 2000/2003 MCSE
Never got an MCSD, go figure...
|
|
|
|
|
|
I like this alot, but I'm having a little problem.
When I try this: object.setCell( {New Point(2,0), New Point(5,0) }, Color.Blue)
It will not draw anything.
Wasn't is supposed to fill cells from 2-5 in row 0?
Jens, Denmark
|
|
|
|
|