DW control in VB. NET custom control

Hi

Just attempting to investigate some DW.NET aspects. In regards to building a
ancestor object with VB.NET, why is when I create a datawindowcontrol custom
control that any reference to it is like (assuming that u_dw is the name of
the DW control):

custom_control.u_dw.DatawindowObject = "myDW"

instead of simply: u_dw.DatawindowObject = "myDW"

If I create a .NET custom control with a button on it, I can directly
reference the button's methods and properties without having to qualify it
with the custom control's name.

When I was developing with powerbuilder, it was very common to work with a
decendant of a datawindow control (eg u_dw). So I am just trying to
replicate that functionality in .NET if that is at all possible.

Thanks



0
JC
5/6/2005 12:28:13 AM
📁 sybase.datawindow.net
📃 2302 articles.
⭐ 0 followers.

💬 5 Replies
👁️‍🗨️ 1214 Views

Did you stick the dw on a userobject?  or create a new class that inherited 
from DataWindowControl?  To simulate what you are talking about in PB you 
should do the later.


"JC" <[email protected]> wrote in message news:[email protected]
> Hi
>
> Just attempting to investigate some DW.NET aspects. In regards to building 
> a
> ancestor object with VB.NET, why is when I create a datawindowcontrol 
> custom
> control that any reference to it is like (assuming that u_dw is the name 
> of
> the DW control):
>
> custom_control.u_dw.DatawindowObject = "myDW"
>
> instead of simply: u_dw.DatawindowObject = "myDW"
>
> If I create a .NET custom control with a button on it, I can directly
> reference the button's methods and properties without having to qualify it
> with the custom control's name.
>
> When I was developing with powerbuilder, it was very common to work with a
> decendant of a datawindow control (eg u_dw). So I am just trying to
> replicate that functionality in .NET if that is at all possible.
>
> Thanks
>
>
> 


0
Jack
5/6/2005 2:26:34 AM
Jack - when doing the latter (creating a new class that inherits from
DatawindowControl) - I assume this is done via code, and in a non-graphical
manner?


"Jack Addington" <[email protected]> wrote in message
news:[email protected]
> Did you stick the dw on a userobject?  or create a new class that
inherited
> from DataWindowControl?  To simulate what you are talking about in PB you
> should do the later.
>
>
> "JC" <[email protected]> wrote in message news:[email protected]
> > Hi
> >
> > Just attempting to investigate some DW.NET aspects. In regards to
building
> > a
> > ancestor object with VB.NET, why is when I create a datawindowcontrol
> > custom
> > control that any reference to it is like (assuming that u_dw is the name
> > of
> > the DW control):
> >
> > custom_control.u_dw.DatawindowObject = "myDW"
> >
> > instead of simply: u_dw.DatawindowObject = "myDW"
> >
> > If I create a .NET custom control with a button on it, I can directly
> > reference the button's methods and properties without having to qualify
it
> > with the custom control's name.
> >
> > When I was developing with powerbuilder, it was very common to work with
a
> > decendant of a datawindow control (eg u_dw). So I am just trying to
> > replicate that functionality in .NET if that is at all possible.
> >
> > Thanks
> >
> >
> >
>
>


0
JC
5/6/2005 3:55:58 AM
Nevermind. I figured out how to do it. If others are interested, I can post
how I did it.

My intention was to extend the datawindow control's DeleteRow method by
allowing some validation to take place. This way, deletion can be halted
(not sure if the DW control is the right place for it, but it was a fun
exercise anyway).


"JC" <[email protected]> wrote in message news:[email protected]
> Jack - when doing the latter (creating a new class that inherits from
> DatawindowControl) - I assume this is done via code, and in a
non-graphical
> manner?
>
>
> "Jack Addington" <[email protected]> wrote in message
> news:[email protected]
> > Did you stick the dw on a userobject?  or create a new class that
> inherited
> > from DataWindowControl?  To simulate what you are talking about in PB
you
> > should do the later.
> >
> >
> > "JC" <[email protected]> wrote in message news:[email protected]
> > > Hi
> > >
> > > Just attempting to investigate some DW.NET aspects. In regards to
> building
> > > a
> > > ancestor object with VB.NET, why is when I create a datawindowcontrol
> > > custom
> > > control that any reference to it is like (assuming that u_dw is the
name
> > > of
> > > the DW control):
> > >
> > > custom_control.u_dw.DatawindowObject = "myDW"
> > >
> > > instead of simply: u_dw.DatawindowObject = "myDW"
> > >
> > > If I create a .NET custom control with a button on it, I can directly
> > > reference the button's methods and properties without having to
qualify
> it
> > > with the custom control's name.
> > >
> > > When I was developing with powerbuilder, it was very common to work
with
> a
> > > decendant of a datawindow control (eg u_dw). So I am just trying to
> > > replicate that functionality in .NET if that is at all possible.
> > >
> > > Thanks
> > >
> > >
> > >
> >
> >
>
>


0
JC
5/6/2005 6:54:25 AM
Yes, please post your solution. I am quite sure this question will arise more
than once in the next few weeks and it could be frustrating for people searching
this group for a solution and just find: Got it. But no explanation how...... 

On 5 May 2005 23:54:25 -0700,
 in sybase.public.datawindow.net
JC <[email protected]> wrote: 
>Nevermind. I figured out how to do it. If others are interested, I can post
>how I did it.
>
>My intention was to extend the datawindow control's DeleteRow method by
>allowing some validation to take place. This way, deletion can be halted
>(not sure if the DW control is the right place for it, but it was a fun
>exercise anyway).
>
>
>"JC" <[email protected]> wrote in message news:[email protected]
>> Jack - when doing the latter (creating a new class that inherits from
>> DatawindowControl) - I assume this is done via code, and in a
>non-graphical
>> manner?
>>
>>
>> "Jack Addington" <[email protected]> wrote in message
>> news:[email protected]
>> > Did you stick the dw on a userobject?  or create a new class that
>> inherited
>> > from DataWindowControl?  To simulate what you are talking about in PB
>you
>> > should do the later.
>> >
>> >
>> > "JC" <[email protected]> wrote in message news:[email protected]
>> > > Hi
>> > >
>> > > Just attempting to investigate some DW.NET aspects. In regards to
>> building
>> > > a
>> > > ancestor object with VB.NET, why is when I create a datawindowcontrol
>> > > custom
>> > > control that any reference to it is like (assuming that u_dw is the
>name
>> > > of
>> > > the DW control):
>> > >
>> > > custom_control.u_dw.DatawindowObject = "myDW"
>> > >
>> > > instead of simply: u_dw.DatawindowObject = "myDW"
>> > >
>> > > If I create a .NET custom control with a button on it, I can directly
>> > > reference the button's methods and properties without having to
>qualify
>> it
>> > > with the custom control's name.
>> > >
>> > > When I was developing with powerbuilder, it was very common to work
>with
>> a
>> > > decendant of a datawindow control (eg u_dw). So I am just trying to
>> > > replicate that functionality in .NET if that is at all possible.
>> > >
>> > > Thanks
>> > >
>> > >
>> > >
>> >
>> >
>>
>>
>
>

Berndt
0
Berndt
5/6/2005 7:06:24 AM
Ok - here it is (keep in mind it is just some experimentation and I am
somewhat of a .NET noobie - so if there are better ways, or any advice you
can offer, please do so). Our organisation has decided to use VB .NET
(mainly because of the Lotus Notes and MS Access legacies). The instructions
below are therefore intended for VB .NET.

1. Using Visual Studio 2003, create a Class library project. I have created
a probject called "Class Library1"
2. Right click on your Class library project and select "Add Component". (I
have created Component1).
3. Right click on the new component and select code. Your code window should
appear.
4. Change the line of code that reads:
        Public Class Component1
            Inherits System.ComponentModel.Component
    to:
        Imports System.Drawing
        Public Class Component1
            Inherits Sybase.DataWindow.DataWindowControl
4. Add or replace this method (my understanding of what this section does is
allow the component to be rendered at design and run time):
        Protected Overrides Sub OnPaint(ByVal pe As
System.Windows.Forms.PaintEventArgs)
            MyBase.OnPaint(pe)
            'Add your custom paint code here
            'Declare and instantiate a drawing pen.
            Dim myPen As System.Drawing.Pen = New
System.Drawing.Pen(Color.Aqua)
            ' Draw an aqua rectangle in the rectangle represented by the
control.
            pe.Graphics.DrawRectangle(myPen, New Rectangle(Me.Location,
Me.Size))
        End Sub
5. Build your solution.
6. Select a project that has a Windows Form in it (or simply create a
windows form project). This will change the tabs that are available to you
in your toolbox.
7. Select the "My User Controls" tab.
8. Right click on that tab and select "Add/Remove Items"
9. Click the "Browse", and locate ClassLibrary1.dll. This will add graphical
custom controls within that project to your toolbar.

You should be able to drag and drop Component1 (our inherited datawindow
control) onto your form. For my testing purposes, I overloaded the normal
DeleteRow() datawindow method. I wanted to perform some validation before a
row was graphically removed from a datawindow control. Here is what I added:
'-------------------------------------------------------- code
start ---------------
    Public Overloads Sub DeleteRow(ByVal RowNumber As Integer)
        'JC experimentation:
        'Extend the ancestor's deleteRow() method with our own, and give
ourselves a chance
        'to bomb out if criterion is not met
        Dim e As New System.ComponentModel.CancelEventArgs
        RaiseEvent PreDeleteRow(RowNumber, e)

        If Not e.Cancel Then
            MyBase.DeleteRow(RowNumber)
        End If
    End Sub

    Public Event PreDeleteRow(ByVal RowNumber As Integer, ByRef e As
System.ComponentModel.CancelEventArgs)
'-------------------------------------------------------- Code
End ---------------

On the form, I added the following code to test if it will cancel a row
deletion based on some rules:

(it assumes the datawindow control is called dwcDefaultAttributes)
'-------------------------------------------------------- code
start ---------------
    Private Sub dwcDefaultAttributes_PreDeleteRow(ByVal RowNumber As
Integer, ByRef e As System.ComponentModel.CancelEventArgs) Handles
dwcDefaultAttributes.PreDeleteRow
        If dwcDefaultAttributes.GetItemString(RowNumber, "inuse") > 0 Then
            MsgBox("Cannot delete this attribute because it is in use.")
            e.Cancel = True
        End If
    End Sub
'-------------------------------------------------------- Code
End ---------------



"Berndt Hamboeck [TeamSybase]" <[email protected]> wrote in message
news:[email protected]
> Yes, please post your solution. I am quite sure this question will arise
more
> than once in the next few weeks and it could be frustrating for people
searching
> this group for a solution and just find: Got it. But no explanation
how......
>
> On 5 May 2005 23:54:25 -0700,
>  in sybase.public.datawindow.net
> JC <[email protected]> wrote:
> >Nevermind. I figured out how to do it. If others are interested, I can
post
> >how I did it.
> >
> >My intention was to extend the datawindow control's DeleteRow method by
> >allowing some validation to take place. This way, deletion can be halted
> >(not sure if the DW control is the right place for it, but it was a fun
> >exercise anyway).
> >
> >
> >"JC" <[email protected]> wrote in message news:[email protected]
> >> Jack - when doing the latter (creating a new class that inherits from
> >> DatawindowControl) - I assume this is done via code, and in a
> >non-graphical
> >> manner?
> >>
> >>
> >> "Jack Addington" <[email protected]> wrote in message
> >> news:[email protected]
> >> > Did you stick the dw on a userobject?  or create a new class that
> >> inherited
> >> > from DataWindowControl?  To simulate what you are talking about in PB
> >you
> >> > should do the later.
> >> >
> >> >
> >> > "JC" <[email protected]> wrote in message
news:[email protected]rums-1-dub...
> >> > > Hi
> >> > >
> >> > > Just attempting to investigate some DW.NET aspects. In regards to
> >> building
> >> > > a
> >> > > ancestor object with VB.NET, why is when I create a
datawindowcontrol
> >> > > custom
> >> > > control that any reference to it is like (assuming that u_dw is the
> >name
> >> > > of
> >> > > the DW control):
> >> > >
> >> > > custom_control.u_dw.DatawindowObject = "myDW"
> >> > >
> >> > > instead of simply: u_dw.DatawindowObject = "myDW"
> >> > >
> >> > > If I create a .NET custom control with a button on it, I can
directly
> >> > > reference the button's methods and properties without having to
> >qualify
> >> it
> >> > > with the custom control's name.
> >> > >
> >> > > When I was developing with powerbuilder, it was very common to work
> >with
> >> a
> >> > > decendant of a datawindow control (eg u_dw). So I am just trying to
> >> > > replicate that functionality in .NET if that is at all possible.
> >> > >
> >> > > Thanks
> >> > >
> >> > >
> >> > >
> >> >
> >> >
> >>
> >>
> >
> >
>
> Berndt


0
JC
5/9/2005 1:28:07 AM
Reply: