Overload resolution failed because no 'Paint' is accessible.

M

Mike Cooper

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
 
J

Jay B. Harlow [MVP - Outlook]

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 said:
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
 
M

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 said:
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 said:
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
 
J

Jay B. Harlow [MVP - Outlook]

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/default.asp?url=/library/en-us/vbcn7/html/vbconAccessibility.asp

For details on OOP, Encapsulation & how that fits with accessibility see:

http://msdn.microsoft.com/library/d...us/vbcn7/html/vbconProgrammingWithObjects.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.aspx?scid=kb;en-us;318581

http://msdn.microsoft.com/library/d...ry/en-us/dnwinforms/html/wnf_CustDataGrid.asp

A data grid column sample control can be found on this page (in the middle
or so).
http://www.windowsforms.net/Default.aspx?tabindex=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 said:
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>>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top