Click here to Skip to main content
15,893,668 members
Home / Discussions / C#
   

C#

 
QuestionCreate Sql server alias - Remote connection Pin
calanit29-Dec-08 7:01
calanit29-Dec-08 7:01 
AnswerRe: Create Sql server alias - Remote connection Pin
Colin Angus Mackay29-Dec-08 7:17
Colin Angus Mackay29-Dec-08 7:17 
JokeRe: Create Sql server alias - Remote connection Pin
Pete O'Hanlon29-Dec-08 9:46
mvePete O'Hanlon29-Dec-08 9:46 
GeneralRe: Create Sql server alias - Remote connection Pin
calanit29-Dec-08 10:09
calanit29-Dec-08 10:09 
AnswerRe: Create Sql server alias - Remote connection Pin
Wendelius29-Dec-08 8:36
mentorWendelius29-Dec-08 8:36 
GeneralRe: Create Sql server alias - Remote connection Pin
calanit29-Dec-08 10:12
calanit29-Dec-08 10:12 
GeneralRe: Create Sql server alias - Remote connection Pin
Wendelius29-Dec-08 10:17
mentorWendelius29-Dec-08 10:17 
QuestionDataGridView with ComboBox. Need help Pin
aerinai29-Dec-08 6:26
aerinai29-Dec-08 6:26 
I have been wracking my brain for hours on this problem.

I have a DataGridView object that has a DataGridViewComboBoxColumn inside of it. The combo box displays fine and is populated from an Access database. The column has the Primary key mapped to the ValueMember variable and the column 'Type' is mapped to DisplayMember.

What I need is for each of these combo boxes to have their selected index (I think it is the Value property under DataGridViewComboBoxCell, but I'm pulling at straws at this point) be populated from another table. This took me about 6 seconds in Access. My problem is I cannot even find a way to access the Value/SelectedIndex of the Combobox once I place it in the DataGridView.

If anyone could help me out I'd greatly appreciate it.

Here is the code:
//Connection string to DB.
OleDbConnection dbCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"" + "NGDemoSetup.mdb" + "\"");

//Dataset for majority of data
DataSet ds = new DataSet();

//Dataset for the combobox
DataSet cboDs = new DataSet();

//Create a DGVComboBoxColumn to hold the Types we have in the ADDRESSTYPES Table of the DB.
DataGridViewComboBoxColumn cboCol = new DataGridViewComboBoxColumn();

//Open the DB.
dbCon.Open();

//Grab all the data we need from the Location Info table
OleDbDataAdapter da = new OleDbDataAdapter("SELECT AddrType,isRange,Value1,Value2 FROM LOCATIONINFO", dbCon);

//Grab all the columns from ADDRESSTYPES (ID and Types).
OleDbDataAdapter cboDa = new OleDbDataAdapter("SELECT * FROM ADDRESSTYPES", dbCon);

da.Fill(ds, "LocationInfo");
cboDa.Fill(cboDs, "AddressTypes");

cboCol.Width = 100;
cboCol.DataSource = cboDs.Tables[0];

cboCol.ValueMember = "ID";
cboCol.DisplayMember = "Type";
DataTable dt = ds.Tables["LocationInfo"];

grdAddressInfo.DataSource = dt;

/*
 * Somehow make the ComboBox Column display the correct Dropdown object
 * Based upon the AddrType field.
 */

//Column formatting
grdAddressInfo.Columns.Insert(0, cboCol);
grdAddressInfo.Columns[0].HeaderText = "Address Type";
grdAddressInfo.Columns[1].HeaderText = "Ranged Value";
grdAddressInfo.Columns[2].HeaderText = "From";
grdAddressInfo.Columns[3].HeaderText = "To";

dbCon.Close();

AnswerRe: DataGridView with ComboBox. Need help Pin
Member 447035429-Dec-08 7:33
Member 447035429-Dec-08 7:33 
Questiontext parsing or automatic segmentation of text in c# Pin
lawrenceinba29-Dec-08 6:13
lawrenceinba29-Dec-08 6:13 
AnswerRe: text parsing or automatic segmentation of text in c# Pin
Teuz29-Dec-08 6:52
Teuz29-Dec-08 6:52 
GeneralRe: text parsing or automatic segmentation of text in c# Pin
Member 447035429-Dec-08 7:16
Member 447035429-Dec-08 7:16 
GeneralRe: text parsing or automatic segmentation of text in c# Pin
Not Active29-Dec-08 10:56
mentorNot Active29-Dec-08 10:56 
GeneralRe: text parsing or automatic segmentation of text in c# Pin
lawrenceinba29-Dec-08 14:46
lawrenceinba29-Dec-08 14:46 
GeneralRe: text parsing or automatic segmentation of text in c# Pin
lawrenceinba29-Dec-08 14:43
lawrenceinba29-Dec-08 14:43 
GeneralRe: text parsing or automatic segmentation of text in c# Pin
Colin Angus Mackay29-Dec-08 15:03
Colin Angus Mackay29-Dec-08 15:03 
GeneralRe: text parsing or automatic segmentation of text in c# Pin
lawrenceinba29-Dec-08 15:17
lawrenceinba29-Dec-08 15:17 
GeneralRe: text parsing or automatic segmentation of text in c# Pin
Colin Angus Mackay29-Dec-08 15:30
Colin Angus Mackay29-Dec-08 15:30 
AnswerRe: text parsing or automatic segmentation of text in c# Pin
#realJSOP29-Dec-08 9:05
mve#realJSOP29-Dec-08 9:05 
AnswerRe: text parsing or automatic segmentation of text in c# Pin
Colin Angus Mackay29-Dec-08 10:19
Colin Angus Mackay29-Dec-08 10:19 
JokeRe: text parsing or automatic segmentation of text in c# Pin
Pete O'Hanlon29-Dec-08 10:23
mvePete O'Hanlon29-Dec-08 10:23 
GeneralRe: text parsing or automatic segmentation of text in c# Pin
Colin Angus Mackay29-Dec-08 11:52
Colin Angus Mackay29-Dec-08 11:52 
GeneralRe: text parsing or automatic segmentation of text in c# Pin
lawrenceinba29-Dec-08 14:50
lawrenceinba29-Dec-08 14:50 
GeneralRe: text parsing or automatic segmentation of text in c# Pin
Colin Angus Mackay29-Dec-08 14:59
Colin Angus Mackay29-Dec-08 14:59 
QuestionEvenly Space Points On Line Pin
linal29-Dec-08 5:47
linal29-Dec-08 5:47 

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.