Click here to Skip to main content
15,881,757 members
Home / Discussions / C#
   

C#

 
QuestionProgrammingly Change treeview indexes Pin
Ronni Marker14-Mar-10 7:34
Ronni Marker14-Mar-10 7:34 
AnswerMessage Closed Pin
14-Mar-10 7:56
stancrm14-Mar-10 7:56 
GeneralRe: Programmingly Change treeview indexes Pin
Ronni Marker14-Mar-10 8:42
Ronni Marker14-Mar-10 8:42 
GeneralRe: Programmingly Change treeview indexes Pin
Dan Mos14-Mar-10 13:44
Dan Mos14-Mar-10 13:44 
QuestionEditing Text in a DataGridViewComboBoxColumn Pin
jojoba201114-Mar-10 4:48
jojoba201114-Mar-10 4:48 
AnswerRe: Editing Text in a DataGridViewComboBoxColumn Pin
Sandeep Mewara14-Mar-10 8:08
mveSandeep Mewara14-Mar-10 8:08 
QuestionRe: Editing Text in a DataGridViewComboBoxColumn Pin
jojoba201114-Mar-10 19:18
jojoba201114-Mar-10 19:18 
QuestionDataGridView Combobox DataError Exception Pin
arj_agt14-Mar-10 4:22
arj_agt14-Mar-10 4:22 
Hi EveryoneCool | :cool:
I am using Datagridview with a combobox column in my form. I am having a table in my database with a single column for "name".
On my form load event i want to get the names from the database and fill the combobox column with all the names.

I have declared the combobox like this:
ComboBox combobox;
before
Public Form1(){InitializeComponent();}

Then I have added the following code in DataGridView1_EditingControlShowing event:
if (DataGridView1.CurrentCell.ColumnIndex == 1)
{
 combobox = (ComboBox)e.Control;
 Function1();
}

This is the code for Function1():

try
{
  combobox.Items.Clear();
  string q = "select * from Table1";
  Con.Open();
  DataSet ds = new DataSet();
  NpgsqlDataAdapter da = new NpgsqlDataAdapter(q, Con);
  da.Fill(ds, "Table");
  for (int i = 0; i < (ds.Tables["Table"].Rows.Count); i++)
  {
   string name = ds.Tables["Table"].Rows[i]["name"].ToString();
   combobox.Items.Add(name);
  }
  Con.Close();
}
catch
{}


When the form loads the data is coming in the combobox from the database nicely. But after I select any of the names and leave the combobox cell I got an DataError exception. So to handle that exception i just added the following event without any code:

private void DataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
{}


Since then no error is coming but after I select a value in the combobox and leave that cell, the selected value is not coming in that combobox. Its showing blank.
I have been trying to find a solution for a long time but i couldn't. So if anybody can help i will be very much thankful.

Thanking all
Arijit Smile | :)
AnswerRe: DataGridView Combobox DataError Exception Pin
Luc Pattyn14-Mar-10 6:32
sitebuilderLuc Pattyn14-Mar-10 6:32 
GeneralRe: DataGridView Combobox DataError Exception Pin
arj_agt14-Mar-10 19:22
arj_agt14-Mar-10 19:22 
GeneralRe: DataGridView Combobox DataError Exception Pin
Luc Pattyn15-Mar-10 1:10
sitebuilderLuc Pattyn15-Mar-10 1:10 
AnswerRe: DataGridView Combobox DataError Exception Pin
arj_agt16-Mar-10 21:29
arj_agt16-Mar-10 21:29 
Questionwindows mobile mouse hook Pin
umutumsu14-Mar-10 4:20
umutumsu14-Mar-10 4:20 
AnswerRe: windows mobile mouse hook Pin
#realJSOP14-Mar-10 4:26
mve#realJSOP14-Mar-10 4:26 
GeneralRe: windows mobile mouse hook Pin
umutumsu14-Mar-10 10:43
umutumsu14-Mar-10 10:43 
GeneralRe: windows mobile mouse hook Pin
#realJSOP14-Mar-10 10:44
mve#realJSOP14-Mar-10 10:44 
GeneralRe: windows mobile mouse hook Pin
umutumsu14-Mar-10 10:48
umutumsu14-Mar-10 10:48 
GeneralRe: windows mobile mouse hook Pin
#realJSOP14-Mar-10 11:08
mve#realJSOP14-Mar-10 11:08 
GeneralRe: windows mobile mouse hook Pin
umutumsu14-Mar-10 12:06
umutumsu14-Mar-10 12:06 
GeneralRe: windows mobile mouse hook Pin
#realJSOP15-Mar-10 0:13
mve#realJSOP15-Mar-10 0:13 
QuestionAccessing another application's Controls Pin
cdpace14-Mar-10 2:20
cdpace14-Mar-10 2:20 
AnswerRe: Accessing another application's Controls Pin
#realJSOP14-Mar-10 3:46
mve#realJSOP14-Mar-10 3:46 
AnswerRe: Accessing another application's Controls Pin
Ravi Bhavnani14-Mar-10 18:24
professionalRavi Bhavnani14-Mar-10 18:24 
QuestionProblem In bind DATAGRIED Pin
shahramkeyboard13-Mar-10 23:54
shahramkeyboard13-Mar-10 23:54 
AnswerRe: Problem In bind DATAGRIED PinPopular
OriginalGriff14-Mar-10 0:31
mveOriginalGriff14-Mar-10 0:31 

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.