错误的列表框值 [英] wrong listbox values

查看:102
本文介绍了错误的列表框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请进入此链接 http://imageshack.us/photo/my-images/197 /skit2.png/ [^ ],您将看到我的代码的结果.我不应该希望显示输入元素,而不是"false"和"true"两个元素.为什么我要获取此信息,如何获取列表框中的输入值以及同一行中的组合框文本?也许这段代码可以帮助您

please go inside this link http://imageshack.us/photo/my-images/197/skit2.png/[^] and you will see the result of my code. It should not be like that i want the input element to show up, not two element of "false" and "true". Why do i Get this, how can i get the the input value in the listbox as well as the combobox text in the same row?? maybe this code could make you help me

private bool ReadAndValidateInput(out string name, out double price)
       {


           ReadAndValidateName(out name);
           ReadAndValidatePrice(out price);

           //name = txtName.Text;
           //price = +Double.Parse(txtPrice.Text);

           if (ReadAndValidateName(out name) && ReadAndValidatePrice(out price))
           {
               ReadAndValidateName(out name);
               ReadAndValidatePrice(out price);
               return true;
           }
           else
               return false;

       }





public bool ReserveSeat(String name, double price)
       {
         if (m_nameList[10] ==null)
         {
               m_nameList[10] = name;
               m_priceList[10] = price;

               return true;
           }
           else
           {
               return false;
           }
       }









private void ReserveOrCancelSeat(SeatManager.DisplayOptions choice)
      {
         if (rbtnReserve.Checked == true)
          {
              // Validate data
              string name = null;
              double price = 0.0;

              if (ReadAndValidateInput(out name, out price) == true)
                  lstReservations.Items.Add(!m_seatMngr.ReserveSeat(name, price));
              {
                  if (!m_seatMngr.ReserveSeat(name, price))
                  {
                      lstReservations.Items.Add(!m_seatMngr.ReserveSeat(name, price));
                      // The seat was already reserved, ask user if we should continue with reservation
                      if (MessageBox.Show("The seat is already reserved, continue with reservation?", "Seat already reserved", MessageBoxButtons.YesNo) == DialogResult.Yes)
                      {
                          // We continue. First cancel seat.

                          // Then we reserve it
                          if (!m_seatMngr.ReserveSeat(name, price))
                          {
                              // This should not happen, throw exception
                          //    throw new Exception("The seat could not be reserved.");

                          }
                      }

推荐答案

lstReservations.Items.Add(!m_seatMngr.ReserveSeat(name, price));

ReserveSeat似乎返回一个布尔值:所以我希望在ListBox中看到一个布尔值.

我看不到您在此处发布的代码中的任何位置访问预订"下拉列表.

尝试设置断点,单步执行代码,然后观察会发生什么.

ReserveSeat appears to returns a bool: so I''d expect to see a bool in the ListBox.

I don''t see you accessing the Reservations drop-down anywhere in the code you posted here.

Try setting a break-point, and single-stepping through your code, and observing what happens.


这篇关于错误的列表框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆