New topic: Canvas array not being recognized
<http://forums.realsoftware.com/viewtopic.php?t=41172> Page 1 of 1 [ 5 posts ] Previous topic | Next topic Author Message PremierLiteracy Post subject: Canvas array not being recognizedPosted: Wed Oct 26, 2011 11:44 am Joined: Mon Mar 15, 2010 7:28 pm Posts: 14 I have 4 custom canvases(the custom canvas is named MessageEvent) on my window and am trying to use them as an array. First I query a database for all the events and add them into an events array (events() as MessageEvent). To do this I Dim a tempMessageEvent as new MessageEvent, fill it with the data from the recordSet and then append that to events. When all the events are stored in events() I move onto putting the first 4 into my canvases to be drawn and that's where I'm running into trouble. This is the code below that is failing with the error "This method or property does not exist" in reference to MessageEventList. MessageEventList is the array of 4 controls on the main window. Code: //Fill in info for canvases for i as integer = 0 to events.Ubound if i < 4 then MessageEventList(i) = events(i) MessageEventList(i).Visible = true end if next i Can anyone tell me why this isn't working? Top kermit Post subject: Re: Canvas array not being recognizedPosted: Wed Oct 26, 2011 12:17 pm Joined: Mon May 30, 2011 12:56 am Posts: 228 Quote:MessageEventList is the array of 4 controls on the main window. No it isn't. If the canvas is called MessageEvent, and you have set the index of the four of them to be 0,1,2 and 3 then the array is MessageEvent() and your code should be MessageEvent(i) = events(i) MessageEvent(i).Visible = true But to be honest, I dont understand whet you are getting from a database. It may be some data, but it definitely isnt a canvas. So MessageEvent(i) = events(i) is likely to bork anyway. messageevent is a class with some properties you fill from a database. Assuming there are 4 of them, you want to display the data on screen. To do that you have a number of canvases. A canvas in itself has no idea how to display a class. So by all means make a canvas visible , but how will you display the data? probably you need to subclass a canvas in order to give it new properties, or you set the tag property to an instance of your messageevent class, and use the paint event ti display suitable data. without sight of the rest of the code, it is impossible to advise you better. Top PremierLiteracy Post subject: Re: Canvas array not being recognizedPosted: Wed Oct 26, 2011 12:34 pm Joined: Mon Mar 15, 2010 7:28 pm Posts: 14 Sorry, I've included some additional code this time. MessageEvent is a subclass of canvas I've created with some extra properties, it has the paint event filled in to draw the date and recipient, which defaults to todays date and a dummy name. MessageEventList is the given name to the 4 canvases on the main window. This is where the data pulled from the database gets put into the canvas events Code: //Populate data for all events for i as integer = 0 to rs.RecordCount - 1 if not rs.EOF then Dim tempEvent as new MessageEvent Dim contactID as integer contactID = rs.Field("contactID").Value innerQuery = "SELECT conName from contacts where contactID = '" + Str(contactID) + "'" innerRS = App.eventDatabase.SQLSelect(innerQuery) conName = innerRS.Field("conName").Value date.TotalSeconds = rs.Field("Date").Value message = rs.Field("message").Value tempEvent.fullDate = date tempEvent.Recipient = conName tempEvent = message events.Append(tempEvent) rs.MoveNext end if next i I've also added a MessageEventList(i).Refresh before MessageEventList(i).Visible = true for the previous code. Top kermit Post subject: Re: Canvas array not being recognizedPosted: Wed Oct 26, 2011 12:56 pm Joined: Mon May 30, 2011 12:56 am Posts: 228 The canvases already exist, yes? if so, creating new messageevents in this loop isnt creating new canvases. Try something like this instead: (non essential code removed) Code: //Populate data for all events for i as integer = 0 to rs.RecordCount - 1 if not rs.EOF then ' removed Dim tempEvent as new MessageEvent . . message = rs.Field("message").Value if i < 4 then MessageEventList(i).fullDate = date MessageEventList(i).Recipient = conName MessageEventList(i).visible = true MessageEventList(i).invalidate end if events.Append(message) rs.MoveNext end if next i Top PremierLiteracy Post subject: Re: Canvas array not being recognizedPosted: Wed Oct 26, 2011 1:17 pm Joined: Mon Mar 15, 2010 7:28 pm Posts: 14 That's the ticket, thank you. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 5 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
