North American Sales: 1-800-231-8588
Global Contacts
My Account
Menu
North American Sales: 1-800-321-8588
My Account
Sign In/Register
Design & Development
Design & Develop
Best Value
Infragistics Ultimate
The complete toolkit for building high performing web, mobile and desktop apps.
Indigo.Design
Use a unified platform for visual design, UX prototyping, code generation and application development.
Web
Ignite UI for Angular
Ignite UI for JavaScript
Ignite UI for React
Ultimate UI for ASP.NET
Indigo.Design
Desktop
Ultimate UI for Windows Forms
Ultimate UI for WPF
Prototyping
Indigo.Design
Mobile
Ultimate UI for Xamarin
Ultimate UI for iOS
Ultimate UI for Android
Automated Testing Tools
Test Automation for Micro Focus UFT: Windows Forms
Test Automation for Micro Focus UFT: WPF
Test Automation for IBM RFT: Windows Forms
UX
Indigo.Design Desktop
Collaborative prototyping and remote usability testing for UX & usability professionals
Indigo.Design
A Unified Platform for Visual Design, UX Prototyping, Code Generation, and App Development
Business Intelligence
Reveal Embedded
Accelerate your time to market with powerful, beautiful dashboards into your apps
Reveal App
Empower everyone in your organization to use data to make smarter business decisions
Team Productivity
Learn & Support
Support
Help & Support Documents
Blogs
Forums
Product Ideas
Reference Applications
Customer Stories
Webinars
eBook & Whitepapers
Events
Free Trials
Pricing
Product Pricing / Buy Online
Renew Existing License
Contact Us
Forums
Ultimate UI for Windows Forms
Your Privacy Matters
: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use.
Cookie Policy
Close
State
See Verified Answer
Replies
3 replies
Subscribers
7 subscribers
Views
839711 views
Users
0 members are here
UltraGrid
Share
More
Cancel
1834
What is the best way to select a ValueList item in the code when loading data?
Jamal
posted
over 16 years ago
Folks,
I have successfully used UltraDropDowns in WinGrids and am able to preselect the appropriate value in a grid's InitializeRow event.
However, with the simple case of ValueLists, I'm having a bit of trouble. What is the best way to go about selecting the right ValueItem when loading data?
Specifically, we record statuses for particular field with a single character and there's only 4 options ('I', 'E', 'M', and null). Each letter translates to a word, and my approach so far has been to add all the words as ValueListItems in the InitializeRow event:
//add value list for statuses
ValueList vlStatuses = null;
if (!e.Layout.ValueLists.Exists("STATUS_VALUE_LIST"))
{
vlStatuses = e.Layout.ValueLists.Add("STATUS_VALUE_LIST");
vlStatuses.ValueListItems.Add(" ");
vlStatuses.ValueListItems.Add("Missing");
vlStatuses.ValueListItems.Add("Extracted");
vlStatuses.ValueListItems.Add("Impacted");
}
else
{
vlStatuses = e.Layout.ValueLists["STATUS_VALUE_LIST"];
}
In the InitializeRow event for the grid, the code looks like this:
temp = e.Row.Cells["STATUS"].Value;
if (temp != null && temp != DBNull.Value)
{
switch (temp.ToString())
{
case "I":
e.Row.Cells["STATUS"].Value = "Impacted";
break;
case "E":
e.Row.Cells["STATUS"].Value = "Extracted";
break;
case "M":
e.Row.Cells["STATUS"].Value = "Missing";
break;
default:
e.Row.Cells["STATUS"].Value = " ";
break;
}
}
else
e.Row.Cells["STATUS"].Value = " ";
Is there a better way to do this? The knowledgebase article on the subject of ValueLists, UltraDropDowns, and UltraCombos being used in UltraGrids completely ignores any description of how to load data into these controls.
Thanks for your time,
J
P.S.--Am I the only one who had to add html break tags to get a carriage return when posting? Everything I wrote was all jumbled together, with none of my Enter strokes actually resulting in a newline.
Parents
2334
Verified Answer
Andrew
posted
over 16 years ago
ValueList items have a DisplayText and a Value property. Set the Value property to I, E, M, null and the DisplayText to Impacted, Extracted, Missing and " ".
vlStatuses.ValueListItems.Add(null, " "); // or DBNull.Value... not sure which you are using
vlStatuses.ValueListItems.Add("M", "Missing");
vlStatuses.ValueListItems.Add("E", "Extracted");
vlStatuses.ValueListItems.Add("M", "Impacted");
Cancel
Reply
Reject Answer
Cancel
Reply
1834
Jamal
posted
over 16 years ago
in reply to
Andrew
Awesome, thanks, that's so easy. It was so obvious, too.
On a side note, do you type in an HTML break tag to get a newline? Or does hitting Enter actually get you line breaks?
Cancel
Reply
Cancel
Children
2334
Andrew
posted
over 16 years ago
in reply to
Jamal
break tags... <br>
kind of annoying but thats how it works!
Cancel
Reply
Cancel