none
Row not Setting .SelectedItem for Many to Many Screen RRS feed

  • Question

  • -I'm having trouble I'm following a standard set of instructions to make a list box mover and the ".SelectedItem” keeps causing exception errors because it is saying lab panel name is required as if it's not already selected. Sometimes this will pop up a window to type in a name of row in the table this however seems to only solve that one validation issue.

     

    -Additionally it seems to have created two rows for the one panel I'm working on for saving to this many to many table as there is still only one entry on the full list of the lab panels table but now when selecting a lab panel there are two one with some of the Lab parts already added and one with none saved to it. I will not want there to be possible duplicate Lab Panels in the end only one unique per Lab Panel Name.

     

    -Then the two values I'm trying to associate many to many with the row of the selected table also say the referenced Lab Panel is either not set or no longer exists. That being the one that is selected and starts that way on that screen as the lab panel is selected first.

            partial void AddLabPart_Execute()
            {
                // Write your code here.
                //LabPart is a collection shown in the list for this List control values are from the LabPart Table
                //Code refers to the item in the list selected using the list control
                if (LabPart.SelectedItem != null)
                {
                    //LabPanelAssembledPart is the table entity for the many to many relationship between LabPanel and Labpart tables
                    //This tests to see if the assembled Panel has been created before to hold associated Lab Parts
                    LabPanelAssembledPart lpExists = new LabPanelAssembledPart();
                    //then a loop searches the mapping/linking table for items displayed on the screen named LabPanelAssembledParts(LabPanelAssembledParts1)
                    //the loop goes through to figure out the Lab Parts Names to include in the current list control for the the assembled Panel
                    //this property LabPart.LabPanelFullName is the name given to a primary value of Lab Parts in refernt to the full name not abreviation
                    //the full name is a required field of the Lab Parts table and is also used as the summary property for the Linking many to many table
                    foreach (LabPanelAssembledPart lpSearch in this.LabPanelAssembledParts1)
                    {
                        if (lpSearch.LabPart.LabPartFullName == this.LabPart.SelectedItem.LabPartFullName)
                        {
                            lpExists = lpSearch;
                        }
                    }
                    //After the existstance of the parts is determined already and if it does not yet exist it is added to the many to many linking table
                    //The selected Lap Part on the right will be added and displayed on the list control for that entity on the Left which is set to this Panel Selected above 
                    if (lpExists == null || lpExists.LabPart == null)
                    {
                        LabPanelAssembledPart lpap = LabPanelAssembledParts1.AddNew();
                        lpap.LabPanel = this.LabPanelProperty;
                        lpap.LabPart = LabPart.SelectedItem;
                    }
                    //If the selected Lab Part already exists and the user trys to add it to the entity this message will pop up instead
                    else
                    {
                        ScreenExtensions.ShowMessageBox(this, LabPart.SelectedItem.LabPartFullName + " (" + LabPart.SelectedItem.LabPartAbbreviation + ") Lab Part already added to this Lab Panel.");
                    }
                }
            }
     
            partial void RemoveLabPart_Execute()
            {
                // Write your code here.
                if (LabPart.SelectedItem != null)
                {
                    LabPanelAssembledParts1.RemoveSelected();
                }
                else
                {
                    ScreenExtensions.ShowMessageBox(this, "No Lab Parts left to 'Delete'.");
                }
            }
     
     
    Summary Property in another table to show the Lab Part Name once it's been added before it's been saved visually on the List Box Mover Screen.
     
            partial void PanelParts_Compute(ref string result)
            {
                //Ok we have a table with a table field that is detectign null values Labpart is the Table and LabPartFullName is the field
                //if (Order != null && Order.OrderNotes == null) 
                /*{
                        do.something...
                  }*/
                //below is the code causing the exception becsause of the null value
                //what do.somethng can we do for null values so we are not adding data entry errors into the field?
                result = LabPart.LabPartFullName ?? "None Listed"; 
                //code to handle null values but there should be none due to it being a required field or even a primary key
            } 



    Sunday, August 25, 2019 6:52 AM

All replies

  • Hi reigh7,

    Thank you for posting here.

    First, I want to know what is your current project.

    Second, I think it is best for you to divide your current problem into multiple easy-to-understand problems.

    Last, could you tell me what do you want to do about your current project.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 26, 2019 5:37 AM
  • The current project is to make a Many to Many screen to handle associating the Lab Panel with Lab Parts of a Blood Lab.

    A panel incudes things like a common name for a group of measures parts of the blood. A Lab Part is a single part and will have fields like the name and several ranges high, low, crit high, crit low and can even get into age and gender for each of those ranges ad different excepted results. I can further normalize those possible repeated fields even more later for now I like them as repeats because it's easier for data entry to have on 2D table to import into from excel.

    I am doing this theoretical design to feed the data to excel via power pivot. What I'm using may be out of date but it's all I know so I'm not mentioning it's name.

    In this scenario I am following an old tutorial By Andy Kung for this tool within VS 2012/2013 to build a list box mover. I could get into why I'm not using a check box tree to build the many to many associations basically because to the type of user I'm targeting this visual of moving items to in the list box communicates well but honestly isn't as efficient since you have to select the item t move and push a button not just check boxes in a tree.

    The Main Problem;
    So in doing some digging it doesn't appear to me now to be an issue that the lab part .SelectedItem are not moving to be associated those do visually move. It seems that some how the Lap Panel even though it shows up in the drop down and I select it on screen may not be recognized as the .SelectedItem Panel to associate the each of the lab parts to. As I mentions this is a tool so much of the code for wiring up databinding is done based on the visual tree I posted a picture of. I'm following the instructions but wondering if somehow something in the code they suggest isn't correctly targeting the .SelectedItem or the Lap Panel table correctly. Not to be confused with the connecting table here for the many to many LabPannelAssembledParts.

    The status here is that figuring out this structure would allow me to normalize where needed and in the case of data design to build labs and maintain the ability to build new ones futureproofing and update a needed. I could use this same template screen in several places but this is currently causing many non descript run time errors when I go to save to the Db and things it say things indicating the Panel selected isn't set. I know this the code example as setting up the screens are common but I may be mixing up something as simple as which table to define or which table to target to build that tree of user control pictured.

    I don't now hw to interpret what I want to do about my current project. This project is something on my mind a lot and want to finish it for whatever purpose it serves even if just to say I finished it or show relatives or pass it on. I don't think there is much interest anymore the ideas served their purpose even if it wasn't for me to gain work. I'd love any help I could get even if just poking at it again and asking questions here on the forum when my mind is clear and it helps me feel valuable and gives me a little purpose to my time. I can't ever explain well how this whole things is architected and why I choose things I did I have a fairly good set of notes on the project now minus the endless notes on the properties of every user control in every screen. I didn't keep track of which ones are standard setting from the tool and which I modified to keep screen space, or character counts or formatting. The rest I got up to date in case I can share it. I mean I have kind of a terrible reputation of trying anything even giving it away. I also was working at first with no formal training in code so my explanations have been muddled with the wrong terminology or not accurately got to people what I needed and was lead down a lot of stray paths to make, or solve something else entirely.

    My mind comes and goes into focus on things I can get done. This was something I assigned a lot of my value to since I couldn't find work in my field I though I'd put something of my organization into making something on my own for the field. I put so much passion and hope into this mantel to large for me even if I finished the code. I looked into business plans but same story there are just pieces I can't put together on my own. So I guess this is at best my last shot at a demonstration piece of what I'd hoped to make from the beginning of it all. Since explaining it in words doesn't work finishing it and posting an interactive version online, possible limited access/permissions ability for people to edit given its the nature of the field it's for healthcare and people not knowing not to enter real personal data. Just a thing to be used and thing to send a link to for relatives or to showing my grandma now at end of life. To show something for everything I'd been through not a lot else I can expect anymore though I once did and inside often do so hope. I'm adapting to being more realistic though. -sigh
    Saturday, August 31, 2019 10:27 AM
  • Hi reigh7,

    Thanks for the feedback.

    According to your detailed description, I think this problem is not related to c#.You could post it in the correct place.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, September 3, 2019 5:17 AM
  • There is no more forum support for the platform you speak of so no place to post to them specifically. I was just trying to look at the basic code here for any obvious syntax errors calling a many to many table structure with a connection table this way. Seems that intel-sense see's no error and is selected would be right just looking why the supporting code is not grabbing or saving the selected code correctly. I mean The windows OS is weird too won't save text files to certain folders, won't encrypt un encrypt the parent file and sub files just a scattering of them, wont create zip package files this is in the normal OS. I had to run a your scripts to check for corruption but found none. I'm worried about the windows enterprise OS these days I have of course the student versions of enterprise given out in the initial windows 10 launch to students but... is there a lack of businesses paying for subscriptions to support the platform. Maybe it's just a smattering of things on your end. I also had to manually go into debug server port because Office 2010 actually even MS SQL Developer could not find my published applications and I use the Debug server port I got from the output window in VS 2012 pro to import my Db structure and place holder data to develop the Documents. But if you can't look for syntax errors in my C# for these object or treat them as general then I don't know what to work on next. I mean I could set up my interface tables in the documents for the print reports and work on the macros to automate. The deal is though that the pivot table will be way different even in number of columns and in possible intricate details I can't work out without normalizing this first and I can't upgrade even to VS 2013 h final version for Auditing until I have this in place. So what next I may just have to dump 10 years of research we are at like the final phase of architecting this design just a few polishing moves with making a custom data grid control with some buried UI Tweaks using conditional logic and color to match the controls visual alert colors from assignment to align with the Administration forms. Not really necessary but hey I made this clock work smooth as butter up to this point might as well make it flow together as one consistent unit of UI UX and products, services, documents and assemblies .Net Development. I mean I'm only one guy.
    Tuesday, September 3, 2019 12:21 PM
  • See I'm trying to program to make a workign demo of the screen and workflow as a demo piece but LightingSwish aka LightSwich forums are not supported. So if you people have not a single piece of working software from OS, to Office, to SQL to VS. No way to expose the objects and properties and methods I'm programming against so I can try catch the errors most specifically in the allowing null values to be save or checked for and/or the method isSelected() so I can make the framework of a rudimentary many to many. If you can't even treat these tables parent child many to many connection tables to look at the basic syntax and structure. If the user of the OS cannot use the right click option to send to a compressed package file as a user only. Then everything must be broken you need to pack it in and own up. We already know about the data collections violating privacy even when these are turned off and you refuse to opt us out of manually transcribing those to verify your own Ai for a profit even when we opt out having actual people reading and or listening to our conversations. I mean at least some companies capitulated and let those with privacy setting opt out of staking, creepy voyeurisms. why not edit or at least verify my C# structures are correct here because Satya Nadella wouldn't want the whole company to fall apart wont you?
    Sunday, September 8, 2019 9:53 AM