473,548 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ComboBox in DataGridView not refreshing

I am having a problem with my datagridview. I have a small table that
has two columns. The first column is bound to my dataset. The second
column is a combobox. I add items to the combobox based on the
information that I get from a text file. I then try to set the value of
the combobox to a specific value based on the first column.

The code is working to set the value, but it will not refresh and
display the selected value on the screen unless I move to a previous
tab and then back.

private void tabPage2_Enter( object sender, EventArgs e)
{
if (!cc.Validate_R equiredField(tx tFilePath)
|| !cc.Validate_Re quiredField(cbo Delimiter))
{
tbcWizardPages. SelectedIndex = 0;
return;
}

btnPrevious.Ena bled = true;
btnNext.Enabled = true;
txtImportTable. Text = msTable;

FillTableColumn s();
FillImportColum ns();

tabPage2.Refres h();
}

private void FillImportColum ns()
{
string sColumn = "";
int iFields = 0, iIndex = 0;
this.ImportColu mns.Items.Clear ();
iFields = GetFileFieldCou nt();

if (chkHeaderRows. Checked == true)
{
StreamReader reader = new
StreamReader(tx tFilePath.Text) ;
string sLine;
string sDelimiter =
cboDelimiter.Te xt.Substring((c boDelimiter.Tex t.IndexOf("{") + 1), 1);

sLine = reader.ReadLine ();
iIndex = sLine.IndexOf(s Delimiter);

for (int i = 0; i < iFields; i++)
{
if (iIndex >= 0)
{
this.ImportColu mns.Items.Add(s Line.Substring( 0,
iIndex));
}
else
{
this.ImportColu mns.Items.Add(s Line);
}

sLine = sLine.Substring (iIndex+1);
iIndex = sLine.IndexOf(s Delimiter);
}

//Now try to match up column names
for (int i = 0; i < dataSet2.Import Headers.Rows.Co unt;
i++)
{
grdImportTable. Rows[i].Cells[1].Value =
"<default>" ;

sColumn =
grdImportTable. Rows[i].Cells[0].Value.ToString ();
foreach( string str in this.ImportColu mns.Items)
{
if (sColumn == str)
grdImportTable. Rows[i].Cells[1].Value =
str;
}
}
}
else
{
for (int i = 0; i < dataSet2.Import Headers.Rows.Co unt;
i++)
{
//We need to only add these for the number of
columns that are in the file
//the rest need to be set to default.
if (i < iFields)
{
this.ImportColu mns.Items.Add(" Col" +
Convert.ToStrin g(i + 1));
grdImportTable. Rows[i].Cells[1].Value = "Col" +
Convert.ToStrin g(i + 1);
}
else
{
grdImportTable. Rows[i].Cells[1].Value =
"<default>" ;
}
}
}
this.ImportColu mns.Items.Add(" <default>");
}

Like I said, the value is set for the combobox to the correct item in
the list, but will not display. If I click on a previous tab and then
toggle back, the value will display. I have tried refreshing from every
possible object and it won't work. Any suggestions? Is it possible that
the edited cell value has not committed? If so, how do I make that
happen. I have tried EndEdit, etc...

Thanks,
Jennifer

Aug 21 '06 #1
0 3162

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8620
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone tell me if this is even possible, and if so, how to do it? If this is completely impossible, how would you suggest going about sorting a ComboBox...
8
26394
by: | last post by:
I am sure this has been asked and answered, but here goes anyway... VS.Net 2005, VB.Net How can you display more than one field in the displaymember property of a combobox inside the datagridview control? I am at a loss. Thanks, David
0
1161
by: c_shah | last post by:
I have the controls on my form display the values of the currently selected row of the DataGridView. I am binding my DataGridView to a collection (Collection - which implements IBindingList Interface). I am binding DataGridViewTextBoxColumn to the property of the objects in my collection. I have a combobox that should display a choice of...
3
94226
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 database. For example: table JobTypes 1 | Manager 2 | Controller 3 | Supervisor table Employee
3
14359
by: Przemek M. Zawada | last post by:
Dear Group, I'm developing sample window form, using DataGridView control, which is filled with data through BindingSource, which is based on type of object, as follow: public sampleClass { public int itemNumber; public string itemName;
2
20226
by: David Jackson | last post by:
Hello, I have an unbound DataGridView of which one of the columns is a ComboBox colum containing category data, plus an additional option called <newSo when the ComboBox is dropped down it looks like this <new> First Second Third
13
7431
by: honey99 | last post by:
Hi! I have to fix a problem in JSP.Actually,i have a JSP page say Ex1.jsp.In this Ex1.jsp i have an anchor tag which links into another JSP page i.e when i click on the link another pop-up window will open.My problem is the pop-up window and the parent window has same combobox.if i add data through html form in pop-up window(Ex2.jsp) it enters...
0
1676
by: Dom | last post by:
I have a datagridview control, and one column is a ComboboxColumn. I simply create a ComboboxColumn, add items to it, then add the column to the Datagridview control. If I were working with a simple ComboBox, I could capture an event that fired everytime the selected item changed. Is that possible if the DatagridView control? I've...
3
2649
by: DEC | last post by:
I have a VB application that's about 95% done. As usual, it's that last 5% that's got me stymied. The program is a Bill-of-material update program that interfaces with an SAP database. The BOM's relate to custom computer configurations. By the nature of a BOM, there are many lines, with many fields to each line. The program uses a...
0
7512
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7951
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7466
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7803
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6036
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5362
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.