Click here to Skip to main content
15,920,687 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC30-Dec-10 10:44
LAPEC30-Dec-10 10:44 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute4-Jan-11 11:40
Henry Minute4-Jan-11 11:40 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC4-Jan-11 12:05
LAPEC4-Jan-11 12:05 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute4-Jan-11 12:25
Henry Minute4-Jan-11 12:25 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute4-Jan-11 13:08
Henry Minute4-Jan-11 13:08 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC4-Jan-11 13:21
LAPEC4-Jan-11 13:21 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC4-Jan-11 14:02
LAPEC4-Jan-11 14:02 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? [modified] Pin
Henry Minute5-Jan-11 9:03
Henry Minute5-Jan-11 9:03 
Here you go

C#
private void btnSeparator_Click(object sender, EventArgs e)
 {
     string line2 = "══════ Course 1 ";
     string line3 = "══════";
     string currentGroup = GetCurrentGroup();

     if (!string.IsNullOrEmpty(currentGroup))
     {
         // Don't want to add it twice
         if (!lvwOrder.Groups[currentGroup].Items[lvwOrder.Groups[currentGroup].Items.Count - 1].Text.Contains("Course"))
         {
             switch (currentGroup)
             {
                 case "Dessert":
                     line2 = "══════ Course 3";
                     break;
                 case "Main":
                     line2 = "══════ Course 2";
                     break;
             }

             ListViewItem newItem = new ListViewItem(line2);
             newItem.SubItems.Add(line3);
             newItem.SubItems.Add(line3);
             newItem.Group = lvwOrder.Groups[currentGroup];
             lvwOrder.Items.Add(newItem);
         }
     }
 }

 private string GetCurrentGroup()
 {
     string result = string.Empty;
     if (((DataRowView)MenuBS.Current) != null)
     {
         result = ((DataRowView)MenuBS.Current)["FoodType"].ToString();
     }

     return result;
 }


I am not sure of the benefit of having both the group header and this new separator, still it's your app so.............
Also, as it is it relies on the user to hit the button at the right time. If you are going to do this, it might be better to do it automatically, say when they switch from the Starters button to the Mains, although this too has problems. What if the user enters the Starters then goes to the Mains, at which point the customer changes the order for their starter?

Bearing this in mind it might be better to add the separators automatically when the order is sent. I can't think of any problems in doing it that way. Although I'm sure that I will. Smile | :)
Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
modified on Wednesday, January 5, 2011 3:57 PM

GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC5-Jan-11 13:15
LAPEC5-Jan-11 13:15 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute5-Jan-11 13:17
Henry Minute5-Jan-11 13:17 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC5-Jan-11 13:23
LAPEC5-Jan-11 13:23 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute5-Jan-11 13:24
Henry Minute5-Jan-11 13:24 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC6-Jan-11 2:32
LAPEC6-Jan-11 2:32 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute6-Jan-11 4:36
Henry Minute6-Jan-11 4:36 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC6-Jan-11 6:01
LAPEC6-Jan-11 6:01 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute6-Jan-11 8:29
Henry Minute6-Jan-11 8:29 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC6-Jan-11 8:35
LAPEC6-Jan-11 8:35 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute6-Jan-11 11:04
Henry Minute6-Jan-11 11:04 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC6-Jan-11 11:28
LAPEC6-Jan-11 11:28 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute6-Jan-11 11:29
Henry Minute6-Jan-11 11:29 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC6-Jan-11 11:32
LAPEC6-Jan-11 11:32 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC6-Jan-11 11:57
LAPEC6-Jan-11 11:57 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute6-Jan-11 12:00
Henry Minute6-Jan-11 12:00 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC6-Jan-11 12:04
LAPEC6-Jan-11 12:04 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute6-Jan-11 13:07
Henry Minute6-Jan-11 13:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.