I have been staring at the above error for over a week now! I have a
an inherited data class looking like thus:
Public Class DataGridBoolColumnInherit
Inherits System.Windows.Forms.DataGridBoolColumn
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal
bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum
As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal
alignToRight As Boolean)
---------------------
Then in my Main() I have the following relevent code:
Friend WithEvents DataGridBoolColumnInherit1 As
DataGridBoolColumnInherit
Me.DataGridBoolColumnInherit1 = New DataGridBoolColumnInherit()
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim dgt As DataGridTableStyle = Main_DataGrid.TableStyles(0)
Dim cm As CurrencyManager = CType(Me.BindingContext _
(Main_DataSet.Tables(dgt.MappingName)), CurrencyManager)
Dim cellRect As Rectangle
Dim cellrow As Integer = 5
Dim cellcolumn As Integer = 1
cellRect = Main_DataGrid.GetCellBounds(3, 0)
hehe = dgt.GridColumnStyles(0)
Dim gridCol As MyGridColumn
Dim graph As Graphics = Main_DataGrid.CreateGraphics()
Dim fBrush As New SolidBrush(Color.Yellow)
Dim bBrush As New SolidBrush(Color.Yellow)
DataGridBoolColumnInherit1.Paint(graph, cellRect, cm, cellrow,
bBrush,
fbrush, False)
For some reason the program does not "see" the Paint method inherited
from datagridboolcolumn. This problem has "simple answer" written all
over it. But I don't see it! Can anyone else? Please?
Mike Cooper 3 1830
Mike, Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal
The Paint method of DataGridBoolColumn is Protected, this means that only
the DataGridBoolColumn class or a class derived from it can use the method.
The Button1_Click is not a member of the DataGridBoolColumn class or a class
derived from it, so Button1_Click cannot use the method.
Hope this helps
Jay
"Mike Cooper" <bi******@yahoo.com> wrote in message
news:8b**************************@posting.google.c om... I have been staring at the above error for over a week now! I have a an inherited data class looking like thus:
Public Class DataGridBoolColumnInherit Inherits System.Windows.Forms.DataGridBoolColumn
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean)
---------------------
Then in my Main() I have the following relevent code:
Friend WithEvents DataGridBoolColumnInherit1 As DataGridBoolColumnInherit Me.DataGridBoolColumnInherit1 = New DataGridBoolColumnInherit()
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dgt As DataGridTableStyle = Main_DataGrid.TableStyles(0)
Dim cm As CurrencyManager = CType(Me.BindingContext _ (Main_DataSet.Tables(dgt.MappingName)), CurrencyManager)
Dim cellRect As Rectangle Dim cellrow As Integer = 5 Dim cellcolumn As Integer = 1 cellRect = Main_DataGrid.GetCellBounds(3, 0) hehe = dgt.GridColumnStyles(0) Dim gridCol As MyGridColumn Dim graph As Graphics = Main_DataGrid.CreateGraphics() Dim fBrush As New SolidBrush(Color.Yellow) Dim bBrush As New SolidBrush(Color.Yellow) DataGridBoolColumnInherit1.Paint(graph, cellRect, cm, cellrow, bBrush, fbrush, False)
For some reason the program does not "see" the Paint method inherited from datagridboolcolumn. This problem has "simple answer" written all over it. But I don't see it! Can anyone else? Please?
Mike Cooper
Hello Jay,
Thank you for responding. I guess the large gaps in my knowledge of
visual basic are showing. Can you elaborate? I had assumed that
objects of classes could be instantiated anywhere with full access to
there own defined methods. In my code in I created an object of my
datagridboolcolumninherit class, and tried to have it execute its
paint method. The humble purpose of the code I showed was to color a
certain datagrid cell whenever a button was pushed. How would a
button click color a cell if not through the datagrid's own paint
method?
Thank you,
Mike Cooper
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:<OX**************@TK2MSFTNGP10.phx.gbl>... Mike, Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal The Paint method of DataGridBoolColumn is Protected, this means that only the DataGridBoolColumn class or a class derived from it can use the method.
The Button1_Click is not a member of the DataGridBoolColumn class or a class derived from it, so Button1_Click cannot use the method.
Hope this helps Jay
"Mike Cooper" <bi******@yahoo.com> wrote in message news:8b**************************@posting.google.c om... I have been staring at the above error for over a week now! I have a an inherited data class looking like thus:
Public Class DataGridBoolColumnInherit Inherits System.Windows.Forms.DataGridBoolColumn
Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal [source] As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean)
---------------------
Then in my Main() I have the following relevent code:
Friend WithEvents DataGridBoolColumnInherit1 As DataGridBoolColumnInherit Me.DataGridBoolColumnInherit1 = New DataGridBoolColumnInherit()
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dgt As DataGridTableStyle = Main_DataGrid.TableStyles(0)
Dim cm As CurrencyManager = CType(Me.BindingContext _ (Main_DataSet.Tables(dgt.MappingName)), CurrencyManager)
Dim cellRect As Rectangle Dim cellrow As Integer = 5 Dim cellcolumn As Integer = 1 cellRect = Main_DataGrid.GetCellBounds(3, 0) hehe = dgt.GridColumnStyles(0) Dim gridCol As MyGridColumn Dim graph As Graphics = Main_DataGrid.CreateGraphics() Dim fBrush As New SolidBrush(Color.Yellow) Dim bBrush As New SolidBrush(Color.Yellow) DataGridBoolColumnInherit1.Paint(graph, cellRect, cm, cellrow, bBrush, fbrush, False)
For some reason the program does not "see" the Paint method inherited from datagridboolcolumn. This problem has "simple answer" written all over it. But I don't see it! Can anyone else? Please?
Mike Cooper
Mike, Thank you for responding. I guess the large gaps in my knowledge of visual basic are showing. Can you elaborate? I had assumed that objects of classes could be instantiated anywhere with full access to there own defined methods.
The object itself has full access to its methods, other objects have access
only to certain methods, based on the accessibility of the method, this
accessibility can be Public, Private, Protected, Protected Friend, and
Friend.
For details on Accessibility see: http://msdn.microsoft.com/library/de...essibility.asp
For details on OOP, Encapsulation & how that fits with accessibility see: http://msdn.microsoft.com/library/de...ithObjects.asp
How would a button click color a cell if not through the datagrid's own paint method?
The button should not 'color a cell', a button should tell the cell what
color to use, the cell then should paint itself, assuming of course the cell
is even visible. In other words the 'cell' should have a Color property,
when you set this color property it should Invalidate the window, so as to
have Windows raise the Paint event, in response to the Paint event the Cell
should paint itself the color it needs to be.
However! remember that the Cell in question is actually part of the DataGrid
control, which has its own ideas of how to paint cells...
I would recommend the following articles to properly create a custom data
grid column: http://support.microsoft.com/default...en-us%3B318581 http://msdn.microsoft.com/library/de...stDataGrid.asp
A data grid column sample control can be found on this page (in the middle
or so). http://www.windowsforms.net/Default....dex=3&tabid=49
A suite of Data Grid Column Styles you can purchase: http://www.datagridcolumnstyles.net/default.asp
Hope this helps
Jay
"Mike Cooper" <bi******@yahoo.com> wrote in message
news:8b**************************@posting.google.c om... Hello Jay,
Thank you for responding. I guess the large gaps in my knowledge of visual basic are showing. Can you elaborate? I had assumed that objects of classes could be instantiated anywhere with full access to there own defined methods. In my code in I created an object of my datagridboolcolumninherit class, and tried to have it execute its paint method. The humble purpose of the code I showed was to color a certain datagrid cell whenever a button was pushed. How would a button click color a cell if not through the datagrid's own paint method?
Thank you, Mike Cooper
<<snip>> This discussion thread is closed Replies have been disabled for this discussion. Similar topics
reply
views
Thread by Eph0nk |
last post: by
|
5 posts
views
Thread by Gang Zhang |
last post: by
|
reply
views
Thread by Cailin |
last post: by
|
1 post
views
Thread by steve |
last post: by
|
reply
views
Thread by bcobra |
last post: by
|
4 posts
views
Thread by Kevin Burton |
last post: by
|
2 posts
views
Thread by jason |
last post: by
|
1 post
views
Thread by =?Utf-8?B?QU1lcmNlcg==?= |
last post: by
|
2 posts
views
Thread by Bart |
last post: by
| | | | | | | | | | |