首先在GridControl中调用一个表格数据,然后对表格的每一列属性单独编辑,双击第一列中某一行数据添加到Listbox中,该咋整,谢谢

解决方案 »

  1.   

    描述的不是很清楚!
    是不是这样:
    ListBoxRooms.Items.Add(GridView1.GetFocusedRowCellValue(GridView1.FocusedColumn))
      

  2.   

    GridControl从数据库中取出一个表的某一列(如第一列)数据,然后在显示结果中双击这一列中的行,将数据在另一个控件Listbox中显示出来,并且ListBox中数据可以重新排序(可以用MouseDrog,MouseOver)
      

  3.   

    加到ListBox容易(循环取就可以了),排序及拖拽没搞过!
      

  4.   

    vb代码
    For i As Integer = 0 To GridView1.RowCount - 1
        ListBox1.Items.Add(GridView1.GetRowCellValue(i, GridView1.Columns.Item(0)))
    Next
      

  5.   

    这么简单啊,谢谢啊
    能不能把这个添加到GridControl的双击事件里啊,比如双击某一行,使双击行的所在列的数据添加到listbox中(c#语言),每次添加一个,以下是我搞的一部分程序,请指点
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.OracleClient;namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            int indexofsource;//拖动的起始索引
            int indexoftarget; //拖动的结束索引 
            public Form1()
            {
                InitializeComponent();
            }        private  void Updata()
            {
                OracleConnection conn = new OracleConnection(Properties.Settings.Default.ConnectionString1);
                OracleCommand cmd = new OracleCommand();
                cmd.Connection = conn;
                cmd.CommandText = "SELECT NAME FROM TEST1";
                OracleDataAdapter adapter = new OracleDataAdapter();
                adapter.SelectCommand = cmd;
                DataTable dt = new DataTable();
                tEST1BindingSource.DataSource = dt; 
                adapter.Fill(dt);
                
            }
            private void button1_Click(object sender, EventArgs e)
            {
                Updata();
            }
            private void button2_Click(object sender, EventArgs e)
            {
                listBox1.Items.Add(gridView1.GetFocusedRowCellValue(gridView1.FocusedColumn));
            }        private void listBox1_MouseDown(object sender, MouseEventArgs e)
            {
                indexofsource = ((ListBox)sender).IndexFromPoint(e.X, e.Y);
                if (indexofsource != ListBox.NoMatches)
                {
                    ((ListBox)sender).DoDragDrop(((ListBox)sender).Items[indexofsource].ToString(), DragDropEffects.All);
                }
            }        private void listBox1_DragDrop(object sender, DragEventArgs e)
            {   
                ListBox listbox = (ListBox)sender;
                indexoftarget = listbox.IndexFromPoint(listbox.PointToClient(new Point(e.X, e.Y)));
                if (indexoftarget != ListBox.NoMatches)
                {
                    string temp = listbox.Items[indexoftarget].ToString();
                    listbox.Items[indexoftarget] = listbox.Items[indexofsource];
                    listbox.Items[indexofsource] = temp;
                    listbox.SelectedIndex = indexoftarget;
                }        }        private void listBox1_DragOver(object sender, DragEventArgs e)
            {     //拖动源和放置的目的地一定是一个ListBox
                if (e.Data.GetDataPresent(typeof(System.String)) && ((ListBox)sender).Equals(listBox1))
                {
                    e.Effect = DragDropEffects.Move;
                }
                else
                    e.Effect = DragDropEffects.None;        }
        }