sql语句-组合框中的值 [英] sql statement - value in combobox

查看:80
本文介绍了sql语句-组合框中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关sql语句的帮助.

I need help with an sql statement. 

我正在管理房地产数据库.我有一张桌子属性和多张桌子卧室,浴室等.

I am managing a real estate database. I have a table Properties and multiple tables Bedrooms, Bathrooms etc. 

我有一个表格,代理可以在该表格中看到所有属性,选择他喜欢的属性,然后它将在所有组合框中显示正确的信息.

I have a form in which my agent can see in a listbox all the properties, selects the one he likes and it will display the right informations in all the combobox 

每个条件都显示在组合框中.因此,如果显示属性1,则会看到:卧室:1个卧室

Each criteria is shown in a combobox. So if you show Property 1 you see : Bedrooms: 1bedroom 

现在我的sql语句是:

Right now my sql statement is:

"SELECT AreaSize.AreaSizeID, AreaSize.DescriptionSurface, Bathrooms.BathroomID,
Bathrooms.DescriptionBathroom, Cities.CityID, Cities.DescriptionCities, Prices.PriceID,
Prices.DescriptionPrices, Properties.*, Rooms.RoomID, Rooms.DescriptionRooms,
Types.TypeID, Types.DescriptionType, Users.*
FROM Users
INNER JOIN (Types
INNER JOIN (Rooms
INNER JOIN (Prices
INNER JOIN (Cities
INNER JOIN
(Bathrooms
INNER JOIN (AreaSize
INNER JOIN Properties
ON
AreaSize.AreaSizeID = Properties.AreaSize)
ON Bathrooms.BathroomID = Properties.Bathrooms)
ON Cities.CityID = Properties.City)
ON Prices.PriceID = Properties.Price)
ON Rooms.RoomID = Properties.Rooms)
ON Types.TypeID = Properties.PropertyType)
ON Users.UserID = Properties.AgentID WHERE Users.email =@email";

我如何在组合框中显示:

How I display in a combobox: 

cboBedrooms.Text = tbListing.Rows[idx]["DescriptionRooms"].ToString();

问题在于,现在它仅显示所选属性的值,而不显示所有其他值.

The problem is that right now it only shows the value of the property selected and not all the other values.

如果我在属性2中,则卧室组合框仅显示:2间卧室
它应该显示:2间卧室,然后单击箭头,然后显示1间卧室

if i am in property 2, combobox for bedrooms shows only: 2 bedrooms 
it should show: 2 bedrooms, than you click on the arrow and shows 1 bedroom

+-----------------------------------------+
|    Properties                           |
+------------+------------+---------------+
| PropertyID | NbBedrooms | AgentID...    |
| 1          | 1          |  2...         |
| 2          | 2          |   1...        |
+------------+------------+------------+

+-------------------------+
|    Bedrooms             |
+------------+------------+
| PropertyID | NbBedrooms |
| 1          | 1bedroom   |
| 2          | 2bedrooms  |
+------------+------------+

推荐答案

hi newdev2,

Hi newdev2,

谢谢您在这里发布.

>> 它 应显示:2间卧室,然后单击箭头,然后显示1间卧室

>>if i am in property 2, combobox for bedrooms shows only: 2 bedrooms it should show: 2 bedrooms, than you click on the arrow and shows 1 bedroom

对于您的问题,您可以在中添加所有值 组合框.然后您可以使用 et 或设置索引以指定当前选择的项目.

For your question, you could add all the values in the ComboBox. And then you could use ComboBox.SelectedIndex to get or set the index specifying the currently selected item.

ComboBox.SelectedIndex.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace combobox_demo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load_1(object sender, EventArgs e)
        {
            comboBox1.Items.Add("property 1");
            comboBox1.Items.Add("property 2");
            comboBox1.DropDownStyle = ComboBoxStyle.DropDown;
        }

        private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            comboBox2.Items.Clear();
            if (comboBox1.SelectedItem == "property 1")
            {
                comboBox2.Items.Add("1 bedrooms");
                comboBox2.Items.Add("2 bedrooms");
                comboBox2.SelectedIndex = 0;
            }
            else if (comboBox1.SelectedItem == "property 2")
            {
                comboBox2.Items.Add("1 bedrooms");
                comboBox2.Items.Add("2 bedrooms");
                comboBox2.SelectedIndex = 1;
            }
        }
    }
}

我使用gif显示结果.

我希望这会对您有所帮助.

最好的问候,

温迪

Wendy


这篇关于sql语句-组合框中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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