Ok this should be simple.
I made a form, added a combobox (for selecting items to edit, not for updating fields), several textboxes, a few checkboxes etc. On formshow it connects to my database, draws down the existing data, no problem. All the records in the datatable that were the result of a query, I could select from, and the other databound components would display the records contents, no problem..... however.... when i add a new row, the combobox updates, but if i select the NEW item in it, all the databound objects are still pointing to the record to which I had selected prior, and if i make changes to their contents, it updates the fields associated with the priorily selected record, I can still select the original records and edit their contents just fine... but the NEW record's contents never display, and the record to which the databound objects are pointing, never change either... can someone please help before all my hair turns white ? LOL
the setup code that establishes databindings and populates the data table is as follows. -
mySqlDataAdapter1.SelectCommand =
-
new MySql.Data.MySqlClient.MySqlCommand(
-
"SELECT *,CONCAT(ENTRY_NO,\":\", TYPENAME) AS DISPLAYVAL FROM FILEINFO.FILETYPE ORDER BY TYPENAME",
-
mySqlConnection1);
-
-
mySqlDataAdapter1.Fill(dataSet1);
-
-
ComboList = new DataTable();
-
-
ComboList = dataSet1.Tables[0];
-
-
comboBox1.DataSource = ComboList;
-
comboBox1.DisplayMember = "DISPLAYVAL";
-
comboBox1.ValueMember = "ENTRY_NO";
-
-
-
FILENAME.DataBindings.Clear();
-
FILENAME.DataBindings.Add("TEXT", ComboList, "TYPENAME");
-
-
DESCRIPTION.DataBindings.Clear();
-
DESCRIPTION.DataBindings.Add("TEXT", ComboList, "DESCRIPTION");
-
-
FILEEXT.DataBindings.Clear();
-
FILEEXT.DataBindings.Add("TEXT", ComboList, "EXTENSION");
-
-
RECLENGTH.DataBindings.Clear();
-
RECLENGTH.DataBindings.Add("TEXT", ComboList, "RECORDLENGTH");
-
RECLENGTH.CausesValidation = true;
-
-
ISRECDELIM.DataBindings.Clear();
-
ISRECDELIM.DataBindings.Add("CHECKED", ComboList, "IS_RECORD_DELIM");
-
-
ISFIELDDELIM.DataBindings.Clear();
-
ISFIELDDELIM.DataBindings.Add("CHECKED", ComboList, "IS_FIELD_DELIM");
-
-
ISFLATFILE.DataBindings.Clear();
-
ISFLATFILE.DataBindings.Add("CHECKED", ComboList, "IS_FLAT");
-
-
RECDELIM.DataBindings.Clear();
-
RECDELIM.DataBindings.Add("TEXT", ComboList, "RECORD_DELIM");
-
-
FIELDDELIM.DataBindings.Clear();
-
FIELDDELIM.DataBindings.Add("TEXT", ComboList, "FIELD_DELIM");
-
I have a button which is labeled new record, its click event handlers is as follows: -
private void button3_Click(object sender, EventArgs e)
-
{
-
-
DataRow r = ComboList.NewRow();
-
-
r["ENTRY_NO"] = DBNull.Value;
-
r["TYPENAME"] = "NEW FILE TYPE";
-
r["DISPLAYVAL"] = "X: " + r["TYPENAME"].ToString();
-
ComboList.Rows.Add(r);
-
}
-
Code mapped to the datatables.onco lumnchanged event is as follows.... -
private void UpdateDisplayVal ( Object sender,
-
DataColumnChangeEventArgs e)
-
{
-
if (e.Column.ColumnName == "TYPENAME")
-
{
-
e.Row["DISPLAYVAL"] = e.Row["ENTRY_NO"].ToString() + ": " + e.Row["TYPENAME"].ToString();
-
}
-
}
The combobox updates with a value "X: NEW FILE TYPE", when i select a new item in it
none of the other bound objects update with the new value, as they do when i selected
the old item.
0 2296 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Timothy White |
last post by:
I have a Windows Form Which Displays one record at a
time. The DataTable object which is bound to the Form
Controls only contains the record that is being
displayed. When I need to display a different record, any
changes in the current record are saved to an Access
Database, the DataTable's Row Collection is Cleared and
the New Record is read into the DataTable. (This is done
to ensure that when the User goes to view a record, they
get...
|
by: al |
last post by:
Greetings,
As I understands it, SelectedValud of combobox reads its value from
ValueMember property of the combobox. This doesn't work with me. What
happens is just randome update. This is the code,
'Here I set connectin and commands
Dim cn As SqlConnection = New SqlConnection(str)
|
by: MadCrazyNewbie |
last post by:
Hey group,
I keep getting the following error:
"An unhandled exception of type 'System.IndexOutOfRangeException' occurred
in system.data.dll
Additional information: There is no row at position 1."
on the following line of code:
|
by: Tom |
last post by:
I have a dataset called "employees" with a field
called "gender". How do I bind a combobox to it so that
the user is only allowed to select "M" or "F" and that
value ends up in the dataset?
Note that M and F are not in a table of a database. I
have entered them directly into the Items collection of
the combobox via the property editor.
Thanks
|
by: roy_ware |
last post by:
I have a sweet application developed in MS Access 2000, but need to
re-develop it in VB.NET to completely hide Access and make it a wee bit more
user-friendly.
I've developed MS Access/VB 5 applications in the past, but this VB.NET is a
whole new beast. How does one gain simple access to the database - other
than that butt-ugly Data Grid? I've been using Wrox's Beginning VB.NET, but
could sure use some suggestions on better reference...
| |
by: dbuchanan |
last post by:
ComboBox databindng Problem
== How the ComboBox is setup and used:
My comboBox is populated by a lookup table. The ValueMember is the
lookup table's Id and the DisplayMember is the text from a
corresponding field in the lookup table. In my data table we store the
ID in what I will call the 'key' field.
== Description of the desired operation:
|
by: jon f kaminsky |
last post by:
Hi-
I've seen this problem discussed a jillion times but I cannot seem to
implement any advice that makes it work. I am porting a large project from
VB6 to .NET. The issue is using the combo box bound to a table as a lookup,
drawing values from another table to populate the available selections. This
all worked fine in VB6.
I have distilled the problem down to a simple form drawing data from the
Northwind database for a representative...
|
by: dbuchanan |
last post by:
VS2005
I've been reading all the help I can on the topic (MSDN, other) but I
can't make sense of this.
Desired behavior;
The user is to choose from the displayed list of the databound combobox
and the coresponding 'Id' from the lookup table is to be inserted into
the field of the new record.
I have two simple tables. "tblPerson" is the data table. The lookup
|
by: Anil Gupte |
last post by:
After reading a tutorial and fiddling, I finally got this to work. I can
now put two tables created with a DataTable class into a DataRelation.
Phew! And it works!
Dim tblSliceInfo As New DataTable("SliceInfo")
Dim tblSliceRatings As New DataTable("SliceRatings")
'.... All the adding datacolumns, datarows, etc. goes here..
DatasetInit.Tables.Add(tblSliceInfo)
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |