473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

to add datagridview columns to another table using windowsapplications.

help me
how to add datagridview columns to another table,using windowsapplications.
and set the displaymember and value member datagridviewcomboboxcolumn.

i used this below code but that not exicute.
how can i write that code.
pls send me code.



private void add_Click(object sender, EventArgs e)
{
MySqlConnection cn = new MySqlConnection("Data Source=localhost;Database=newdem;User ID=root;Password=root;");
cn.Open();
JoborderMaster jomobj = new JoborderMaster(true);
jomobj.Orderid = Convert.ToInt32(orderid);
MySqlDataAdapter dbaElements = new MySqlDataAdapter("select * from joborder_master", cn);
DataSet ds = new DataSet();
dbaElements.Fill(ds, "joborder_master");
DataTable dtbElements = new DataTable();
dtbElements = jomobj.SelectOne();
ds.Tables.Add(dtbElements);
{
dtbElements.Columns.Add("type_id", typeof(String));

dtbElements.Rows.Add("001");
dtbElements.Rows.Add("002");
dtbElements.Rows.Add("003");
dtbElements.Rows.Add("004");

dtbElements.Columns.Add("type", typeof(String));


dtbElements.Rows.Add("001", "aaa");

dtbElements.Rows.Add("002", "bbb");

dtbElements.Rows.Add("003", "ccc");

dtbElements.Rows.Add("004", "ddd");


dtbElements.Columns.Add("title", typeof(String));
dtbElements.Columns.Add("state", typeof(String));
dtbElements.Columns.Add("city", typeof(String));

DataGridViewComboBoxColumn colComboColumn = new DataGridViewComboBoxColumn();

colComboColumn.Name = type_id;
colComboColumn.DisplayMember = type;

colComboColumn.ValueMember = type_id;

colComboColumn.DataSource = "joborder_master";

dataGridView1.Columns.Add(colComboColumn);
dataGridView1.DataSource = ds;

}
Oct 3 '07 #1
0 1614

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Art | last post by:
Hi, Forgive me for posting this message in 2 groups -- it appears that the Data Access group isn't very active, so I'm posting again here: I have a DataTable that I want to fill using a...
2
by: Rich | last post by:
Hello, Following an example at http://www.vb-tips.com/dbpages.aspx?IA=DG (by Cor Lightert and Ken Tucker) on binding a dataRelation to a Datagridview for sqlClient, I was able to view rows...
1
by: DBC User | last post by:
Hi All, I am using a database which doesn't suppport and since I am using ORM I can not use join query to create table object mapping. So my question is I have a master table which has bunch...
6
by: martin1 | last post by:
Hi, all, Is there any way to change DataGridView row color based on different row data? for example, if row data in first column = 1, it is yellow, if it is 2, it is blue, if 3 it is white. That...
3
by: sklett | last post by:
I'm changing from a DataGrid to a DataGridView and have run across a problem. The items that are bound to the DataGrid have an int Property that represents a primary key of a lookup table in my...
8
by: Brian Pelton | last post by:
This is on .Net 2.0 in a WinForms application. I have a DataGridView that is bound to a BindingSource. The DataGridView has 3 columns. The first two are "normal" text columns and the last is a...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
1
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
6
by: Miro | last post by:
Sorry for the cross post. I am stuck. I have a datagridview for poker rounds. Basically there are 3 columns in this datagridview. "Round" "SmallBlind" "BigBlind" I have an issue when I tab...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.