473,406 Members | 2,620 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,406 software developers and data experts.

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_RequiredField(txtFilePath)
|| !cc.Validate_RequiredField(cboDelimiter))
{
tbcWizardPages.SelectedIndex = 0;
return;
}

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

FillTableColumns();
FillImportColumns();

tabPage2.Refresh();
}

private void FillImportColumns()
{
string sColumn = "";
int iFields = 0, iIndex = 0;
this.ImportColumns.Items.Clear();
iFields = GetFileFieldCount();

if (chkHeaderRows.Checked == true)
{
StreamReader reader = new
StreamReader(txtFilePath.Text);
string sLine;
string sDelimiter =
cboDelimiter.Text.Substring((cboDelimiter.Text.Ind exOf("{") + 1), 1);

sLine = reader.ReadLine();
iIndex = sLine.IndexOf(sDelimiter);

for (int i = 0; i < iFields; i++)
{
if (iIndex >= 0)
{
this.ImportColumns.Items.Add(sLine.Substring(0,
iIndex));
}
else
{
this.ImportColumns.Items.Add(sLine);
}

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

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

sColumn =
grdImportTable.Rows[i].Cells[0].Value.ToString();
foreach( string str in this.ImportColumns.Items)
{
if (sColumn == str)
grdImportTable.Rows[i].Cells[1].Value =
str;
}
}
}
else
{
for (int i = 0; i < dataSet2.ImportHeaders.Rows.Count;
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.ImportColumns.Items.Add("Col" +
Convert.ToString(i + 1));
grdImportTable.Rows[i].Cells[1].Value = "Col" +
Convert.ToString(i + 1);
}
else
{
grdImportTable.Rows[i].Cells[1].Value =
"<default>";
}
}
}
this.ImportColumns.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 3142

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

Similar topics

4
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...
8
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...
0
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...
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...
3
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 {...
2
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...
13
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...
0
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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.