Hi,
I have taken over a project that has passed through 5+ developers all of which I don't have access to. On the form for this project there are 12+ Comboboxes that are populated from XML data and then based on the selection poupulate a lable with the matching Code. For example there are two ways the Combobox lists are populated. On the screen you see the DisplayMember in the ComboBox for your selection and the ValueMember in a Lable on the form, but when you print the form it shows the ValueMember for both. I need it to print like it is on the screen. Any ideas or suggestions?
//Load lookup dataset
dsLookups = new System.Data.DataSet("Lookups");
String dsFilename = @".\Schema\DropDownLookups.xml";dsLookups.ReadXml(dsFilename);
//Load lists
InitializeCBL( cblHair, "HairColor");
InitializeCBL( cblEyes, "EyeColor");
//Populates the the ComboBox on the form
System.Data.DataSet dsOffenses =
new System.Data.DataSet("Offenses");dsFilename = @".\Schema\Offenses.xml";
dsOffenses.ReadXml(dsFilename);
IncidentOffense.DataSource = dsOffenses;
IncidentOffense.DisplayMember= "row.dept_code_desc";
IncidentOffense.ValueMember = "row.ucr_code";
StevenPosted Sep 6, 2007, 8:21 AM
Thanks for the reply. I finaly got this figured out and the problem was that while the correct data was getting stored in the table there was a section of code in UpdateFormImage() that was setting all comboboxes like this:
if
(c is ComboBox){
if (((ComboBox)c).SelectedValue != null)g.DrawString(((ComboBox)c).SelectedValue.ToString(), c.Font, br, X+1, Y+2);
}
I edited this code to this:
if
(c is ComboBox){
switch(c.Name){
//********Sets each individual combobox to print the displayed text for the selection that is
//********made. Futher down in this code will set each combobox to print abreviations for what
//********is selected.
case "sector_cb": case "IncidentOffense": case "zone_cb": case "district_cb": case "cblArrestingAgency": case "cblReportingAgency": case "cblTCA": case "OfficerList_cb":g.DrawString(((ComboBox)c).Text, c.Font, br, X+1, Y+2);
break;//********Sets comboboxes to only print the abbreviations for the selection that is made******
default: if (((ComboBox)c).SelectedValue != null)g.DrawString(((ComboBox)c).SelectedValue.ToString(), c.Font, br, X+1, Y+2);
break;}
Scott LyslePosted Sep 6, 2007, 12:29 AM