Skip to main content

here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

Hi Bernd, there is a generics sample included in the product that is worthwhile looking through.

Start the Samples browser from the start menu

Select the COBOL for .NET section

Select Generics subsection

The first sample in the solution shows how to use a generic list of strings.

Also take a look at the Collections sample.


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

ok, this helps a Little bit but i Need this lines too:

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

 List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

For more Background:

This is in the WPF:

...

       <CollectionViewSource x:Key="cvsOptions"/>

...

This line is in c#:

...

((CollectionViewSource)this.FindResource("cvsOptions")).Source = Options

...


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

For more Background:

This is in the WPF:

...

       <CollectionViewSource x:Key="cvsOptions"/>

...

This line is in c#:

...

((CollectionViewSource)this.FindResource("cvsOptions")).Source = Options

...


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

This is not right...

         set ((CollectionViewSource)this.FindResource("cvsOptions")).Source to strings


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

this is wrong too:

          set ((CollectionViewSource)this::FindResource("cvsOptions"))::Source to strings

The complier have problems wit the first "(" ...


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

Hi Bernd, casts are done in COBOL using the syntax AS type-specifier.  I've created the following to demonstrate how this might be written in COBOL.  The three lines in method m, correspond to the original three C# lines, the rest is just framework around them...

     $set ilref"presentationframework.dll"

     $set ilusing"System.Windows.Data"

      class-id a.

      method-id m.

          declare options as list[string]

          set self::FindResource("cvsOptions") as type CollectionViewSource::Source to options

          declare GridList as list[type WPFGridZeilen]

      end method.

      method-id FindResource.

      procedure division using by value s as string

                         returning ret as type CollectionViewSource.

          set ret to null

      end method.

      end class.

      class-id WPFGridZeilen.

      end class.


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

The Compiler do something wrong...

     *    ((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

         declare options as list[string]

After this Line;

         set self::FindResource("cvsOptions") as type CollectionViewSource::Source to options

The Compiler goes back to the WPF AND Not to the next Line!?

This is the next Line:      

     *      List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

         declare GridList as list[type WPFGridZeilen]


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

The Compiler do something wrong...

     *    ((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

         declare options as list[string]

After this Line;

         set self::FindResource("cvsOptions") as type CollectionViewSource::Source to options

The Compiler goes back to the WPF AND Not to the next Line!?

This is the next Line:      

     *      List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

         declare GridList as list[type WPFGridZeilen]


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

Not sure I fully understand the question, but in my last post I did omit the actual construction of the list.  This can be done either using our portable collections syntax:

         declare GridList as list[type WPFGridZeilen]

        create GridList

...or by using a standard 'new' (constructor) expression:

         declare GridList as list[type WPFGridZeilen] = new List[type WPFGridZeilen]


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

For more Background:

I will fill the List  like this: (c#)

                   GridList.Add(new WPFGridZeilen()

                   {

                       GrSpalte01 ="001",

                       GrSpalte02 = "Home Town"

                    }

For the filling i Need the "new" WPFGrifZeilen...

How can i fill the Gridines ?

1. New...

2. Filll...

???


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

Hi Bernd, I think I answered this one in my post on your other thread "Public Class for a WPF Data Grid":

The 2.2 version of Visual COBOL does have support for property initialization as part of a 'new' expression.

Try something like:

     01 o type WPFGridZeilen.

     set o to new WPFGridZeilen(property GrSpalte01 = "Hello 01"

                                property GrSpalte02 = "Hello 02")

         display o::GrSpalte01

         display o::GrSpalte02


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

But there is a Bug....

Can I send you the source?

So you can see what i mean...


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

Is the bug that you are describing that the debugger is skipping over the declare source line in the method?

What product version are you using?

Yes, please send the zipped up source to me at chris.glazier@microfocus.com and I will have a look.

If it is an actual bug then you should create a support incident with customer care as this forum is not the approriate place to report product bugs.

Thanks.


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

The Mail is on the way...


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

The Mail is on the way...


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

The debugging is stopping because an exception is being thrown on the statement and you are not trapping the exception.

You can trap the exception by doing something like the following:

          try

             set self::FindResource("cvsOptions")  as type CollectionViewSource::Source to options

          catch ex as type Exception

             display ex::Message

          end-try

The reason you are getting an exception is that you are returning a null in the FindResource method and you cannot set a null object to a value.

The docs for FindResource show the following:

Important

If you call this method for a key that cannot be found, an exception is thrown. If you do not want to handle exceptions that result from calling FindResource, call TryFindResource instead. TryFindResource returns null when a requested resource cannot be found, and does not throw an exception.


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

Something is wrong!?

I Change the Source:

          declare GridList as list[type WPFGridZeilen]

          set self::TryFindResource("cvsOptions") as type CollectionViewSource::Source to GridList

          set GZ to new WPFGridZeilen(

                                     property GrSpalte01 = "D"

                                     property GrSpalte02 = "28816"  

                                     property GrSpalte03 = "Brinkum"  

                                     property GrSpalte04 = "An den Ruschen"  

                                     property GrSpalte05 = "27a"  

                                     property GrSpalte06 = ""  

                                     property GrSpalte07 = ""  

                                     property GrSpalte08 = ""  

                                     property GrSpalte09 = ""  

                                     property GrSpalte10 = ""  

                                     property GrSpalte11 = ""  

                                     property GrSpalte12 = ""  

                                     property GrSpalte13 = ""  

                                     property GrSpalte14 = ""  

                                     property GrSpalte15 = ""  

                                     property GrSpalte16 = ""  

                                     property GrSpalte17 = ""  

                                    )

          invoke GridList::Insert(0, GZ)

But No Line will Show in the GridLine!?


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

I got it to work but I had to make a few changes.

First comment out your own FindResource method in the source so that it will not be called.
It is always returning null and I am not sure why it is being defined.

You also need to set the DataContext of the grid to the resource...

Try using the following:

           declare GridList as list[type WPFGridZeilen]
           create Gridlist
          
           declare cvsOptions as type CollectionViewSource = 
              self::FindResource("cvsOptions") as type CollectionViewSource
           set cvsOptions::Source to GridList   
           set dg::DataContext to cvsOptions
           
           set GZ to new WPFGridZeilen(
                                     property GrSpalte01 = "D"
                                     property GrSpalte02 = "28816"  
                                     property GrSpalte03 = "Brinkum"  
                                     property GrSpalte04 = "An den Ruschen"  
                                     property GrSpalte05 = "27a"  
                                     property GrSpalte06 = ""  
                                     property GrSpalte07 = ""  
                                     property GrSpalte08 = ""  
                                     property GrSpalte09 = ""  
                                     property GrSpalte10 = ""  
                                     property GrSpalte11 = ""  
                                     property GrSpalte12 = ""  
                                     property GrSpalte13 = ""  
                                     property GrSpalte14 = ""  
                                     property GrSpalte15 = ""  
                                     property GrSpalte16 = ""  
                                     property GrSpalte17 = ""  
                                    )
          
          invoke GridList::Insert(0, GZ).

here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

Did you become my E-Mails from today?


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

E-mailing me directly with product problems is not the correct way to receive product support.

Please post the problems directly to the Community Site forum so that everyone can see them or open up a support incident with Customer Care.

That being said, yes I have looked at them and there appears to be a bug in the new handling of initializing properties directly in a constructor when setting the property to another object.

It works correctly if you set the property to a string like "test" but not when setting it to a data item defined as a string.

I will rpi this problem.

As a workaround you can set the properties after the object has been instantiated.

Note that I am using the TrimEnd method to set the property as when you are using pic x data items they will be padded with spaces out to the maximum length and I don't believe that it what you want.

You should do the same thing when setting the header text in your grid or else each column will be 256 bytes wide.

     *            set GZ to new WPFGridZeilen(
     *                              property GrSpalte01 = SPStr01
     *                              property GrSpalte02 = SPStr02  
     *                              property GrSpalte03 = SPStr03
     *                              property GrSpalte04 = SPStr04
     *                              property GrSpalte05 = SPStr05
     *                              property GrSpalte06 = SPStr06
     *                              property GrSpalte07 = SPStr07
     *                              property GrSpalte08 = SPStr08
     *                              property GrSpalte09 = SPStr09
     *                              property GrSpalte10 = SPStr10
     *                              property GrSpalte11 = SPStr11
     *                              property GrSpalte12 = SPStr12
     *                              property GrSpalte13 = SPStr13
     *                              property GrSpalte14 = SPStr14  
     *                              property GrSpalte15 = SPStr15
     *                              property GrSpalte16 = SPStr16
     *                              property GrSpalte17 = SPStr17
     *                             )
                   set GZ to new WPFGridZeilen
                   set GZ::GrSpalte01 to spstr01::TrimEnd
                   set GZ::GrSpalte02 to spstr02::TrimEnd
                   set GZ::GrSpalte03 to spstr03::TrimEnd            
                   set GZ::GrSpalte04 to spstr04::TrimEnd
                   set GZ::GrSpalte05 to spstr05::TrimEnd
                   set GZ::GrSpalte06 to spstr06::TrimEnd
                   set GZ::GrSpalte07 to spstr07::TrimEnd
                   set GZ::GrSpalte08 to spstr08::TrimEnd
                   set GZ::GrSpalte09 to spstr09::TrimEnd
                   set GZ::GrSpalte10 to spstr10::TrimEnd
                   set GZ::GrSpalte11 to spstr11::TrimEnd
                   set GZ::GrSpalte12 to spstr12::TrimEnd
                   set GZ::GrSpalte13 to spstr13::TrimEnd
                   set GZ::GrSpalte14 to spstr14::TrimEnd
                   set GZ::GrSpalte15 to spstr15::TrimEnd
                   set GZ::GrSpalte16 to spstr16::TrimEnd
                   set GZ::GrSpalte17 to spstr17::TrimEnd
                   invoke GridList::Insert(z0, GZ)
                   add 1 to z0
          end-perform.


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

OK!

Now it works how i Need!!!

Many Thanks !!!


here is the c# Code:

List<string> options = new List<string>()

((CollectionViewSource)this.FindResource("cvsOptions")).Source = options

List<WPFGridZeilen> GridList = new List<WPFGridZeilen>()

What is it in Cobol ?

 

 


#OnemoreCWPFtoCobol

OK!

Now it works how i Need!!!

Many Thanks !!!