473,554 Members | 4,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Refresh databindings WinForm

I have a typed dataset in my WinForm and a textbox with databinding to the
dataset (all without code). Now, in a button event, I assign a new dataset
(retrieved from a function) to the dataset a had in the form, but the
textbos isn't refreshed.

Exemple code from my button click event:

dataset1 = helper.GetUser( 6);
¿How can I refresh it?
Nov 16 '05 #1
4 15962
I post a better codesnip from my code:

public class Form1 : System.Windows. Forms.Form
{
private DatasetUser datasetTest = new DatasetUser();
...

private void InitializeCompo nent()
{
this.textBox1.D ataBindings.Add ("Text", this.datasetTes t,
"T_USR.USR_ID") ;
...
}

private void button2_Click(o bject sender, System.EventArg s e)
{
datasetTest = usu.GetUsuario( 6) //Function that return a dataset;
...
//This statment fails, because it dosn't refresh the textBox1.
}
}

"Alex Bibiano" <ab******@infor matica.com> escribió en el mensaje
news:uD******** ******@TK2MSFTN GP11.phx.gbl...
I have a typed dataset in my WinForm and a textbox with databinding to the
dataset (all without code). Now, in a button event, I assign a new dataset
(retrieved from a function) to the dataset a had in the form, but the
textbos isn't refreshed.

Exemple code from my button click event:

dataset1 = helper.GetUser( 6);
¿How can I refresh it?

Nov 16 '05 #2
Alex,

The reason this doesn't work is that the controls don't know that the
data set has actually changed. The TextBox and the data grid have
references to the original value of datasetTest, and can not determine when
the reference to that changes (they hold a different reference to that
object).

What you should do is call the Clear method on the datasetTest field,
and then call Merge, passing in the result from usu.GetUsuario( 6). This
will merge the dataset with the existing data set, and the changes should
register with all controls bound to that dataset.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Alex Bibiano" <ab******@infor matica.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I post a better codesnip from my code:

public class Form1 : System.Windows. Forms.Form
{
private DatasetUser datasetTest = new DatasetUser();
...

private void InitializeCompo nent()
{
this.textBox1.D ataBindings.Add ("Text", this.datasetTes t,
"T_USR.USR_ID") ;
...
}

private void button2_Click(o bject sender, System.EventArg s e)
{
datasetTest = usu.GetUsuario( 6) //Function that return a dataset;
...
//This statment fails, because it dosn't refresh the textBox1.
}
}

"Alex Bibiano" <ab******@infor matica.com> escribió en el mensaje
news:uD******** ******@TK2MSFTN GP11.phx.gbl...
I have a typed dataset in my WinForm and a textbox with databinding to the
dataset (all without code). Now, in a button event, I assign a new dataset
(retrieved from a function) to the dataset a had in the form, but the
textbos isn't refreshed.

Exemple code from my button click event:

dataset1 = helper.GetUser( 6);
¿How can I refresh it?


Nov 16 '05 #3
A lot of thanks, this answer my question, but I have another one.

Is it better (performance, memory, ...) that my function return a dataset
and merge it whit the dataset I have in the form, or is it better modify my
function to accept a dataset as parameter and fill it?


"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> escribió
en el mensaje news:On******** ******@TK2MSFTN GP09.phx.gbl...
Alex,

The reason this doesn't work is that the controls don't know that the
data set has actually changed. The TextBox and the data grid have
references to the original value of datasetTest, and can not determine
when the reference to that changes (they hold a different reference to
that object).

What you should do is call the Clear method on the datasetTest field,
and then call Merge, passing in the result from usu.GetUsuario( 6). This
will merge the dataset with the existing data set, and the changes should
register with all controls bound to that dataset.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Alex Bibiano" <ab******@infor matica.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I post a better codesnip from my code:

public class Form1 : System.Windows. Forms.Form
{
private DatasetUser datasetTest = new DatasetUser();
...

private void InitializeCompo nent()
{
this.textBox1.D ataBindings.Add ("Text", this.datasetTes t,
"T_USR.USR_ID") ;
...
}

private void button2_Click(o bject sender, System.EventArg s e)
{
datasetTest = usu.GetUsuario( 6) //Function that return a dataset;
...
//This statment fails, because it dosn't refresh the textBox1.
}
}

"Alex Bibiano" <ab******@infor matica.com> escribió en el mensaje
news:uD******** ******@TK2MSFTN GP11.phx.gbl...
I have a typed dataset in my WinForm and a textbox with databinding to
the dataset (all without code). Now, in a button event, I assign a new
dataset (retrieved from a function) to the dataset a had in the form, but
the textbos isn't refreshed.

Exemple code from my button click event:

dataset1 = helper.GetUser( 6);
¿How can I refresh it?



Nov 16 '05 #4
Alex,

It would probably be better to accept the data set and fill it. It
should also probably clear the original data set before it filled it as
well. With the merge, you are cylcing through the result set to populate
the data set, and then cycling through it again during the merge. If you
pass it in, you would only have to cycle through once, during the initial
fill.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Alex Bibiano" <ab******@infor matica.com> wrote in message
news:u4******** *****@TK2MSFTNG P11.phx.gbl...
A lot of thanks, this answer my question, but I have another one.

Is it better (performance, memory, ...) that my function return a dataset
and merge it whit the dataset I have in the form, or is it better modify
my function to accept a dataset as parameter and fill it?


"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om>
escribió en el mensaje news:On******** ******@TK2MSFTN GP09.phx.gbl...
Alex,

The reason this doesn't work is that the controls don't know that the
data set has actually changed. The TextBox and the data grid have
references to the original value of datasetTest, and can not determine
when the reference to that changes (they hold a different reference to
that object).

What you should do is call the Clear method on the datasetTest field,
and then call Merge, passing in the result from usu.GetUsuario( 6). This
will merge the dataset with the existing data set, and the changes should
register with all controls bound to that dataset.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Alex Bibiano" <ab******@infor matica.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I post a better codesnip from my code:

public class Form1 : System.Windows. Forms.Form
{
private DatasetUser datasetTest = new DatasetUser();
...

private void InitializeCompo nent()
{
this.textBox1.D ataBindings.Add ("Text", this.datasetTes t,
"T_USR.USR_ID") ;
...
}

private void button2_Click(o bject sender, System.EventArg s e)
{
datasetTest = usu.GetUsuario( 6) //Function that return a dataset;
...
//This statment fails, because it dosn't refresh the textBox1.
}
}

"Alex Bibiano" <ab******@infor matica.com> escribió en el mensaje
news:uD******** ******@TK2MSFTN GP11.phx.gbl...
I have a typed dataset in my WinForm and a textbox with databinding to
the dataset (all without code). Now, in a button event, I assign a new
dataset (retrieved from a function) to the dataset a had in the form,
but the textbos isn't refreshed.

Exemple code from my button click event:

dataset1 = helper.GetUser( 6);
¿How can I refresh it?



Nov 16 '05 #5

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

Similar topics

9
2672
by: HAN(removethis)twister | last post by:
I've tried to create 11 textboxes as variables (not actually visible in the program, not in Windows Form Designer) and have set DataBindings to the text properties of the TextBoxes BUT according to tests I've run, it says that the DataBindings exist, but the IsBinding is set to False, and is ReadOnly (the bindings exist, they just aren't...
1
1392
by: hcs | last post by:
Hello, on a datagrid when you alter the dataset and want to show the new dataset you use datagrid.refresh(). how is this possible on a form which is based on a dataset and consists of a number of textboxes and comboboxes? i have just tried .refesh on the textboxes but it is not displaying the dataset. as a test i have placed a datagrid is...
2
1765
by: Luis Soler | last post by:
Hi: Can I lock refresh of winform to avoid to visualize some temporary changes ? I am changing bindincontext of some controls to do certain checkings and I don't want that the user sees the changes of field's contents.. Visual FoxPro, for example, has intruction: Thisform.LockScreen Thanks
2
4892
by: Matthias | last post by:
Hi Team this may be a newbie question. I have searched the discussions before posting: I'd like to re-use a form instance to edit record details. My data binding (a DataTable bound to TextBoxes) works fine the first time round. I can see, edit and update the details from my form, then close the form. I then like to select and refill...
3
4391
by: Brian Richardson | last post by:
Hi, Please can anyone kindly offer some suggestions as to why the CurrencyManager might not refresh. I am using the CurrencyManager to navigate through a DataView. I am aware that there is an issue when adding a new record with using bound CheckBoxes ('http://support.microsoft.com/default.aspx?scid=kb;en-us;326440'). Due to this...
6
50414
by: George | last post by:
Hi, I have been encountering a refresh problem with DataGridView, which is bound to a DataTable. When I make updates (Add, Delete, update) to the DataGridView, everything flow nicely to DataTable. No problem here. However, when I add data (programatically) to the DataTable, the DataGridView does not refresh right away. If I minimize...
2
5697
by: Mikus Sleiners | last post by:
I have a control - textBox1 that is binded to objects propery - "Currency" and another control - textBox2 (read only) that is also binded to same propery. Now, i have a situation where textbox1 control does NOT refresh it's display according to value set to underlying propery while at the same time textBox2 does refresh accordingly. Both...
0
2294
by: XenReborn | last post by:
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...
6
3231
by: naseemsadak | last post by:
Hi, I'm developing a program in c# 2005 and would like to know if it is possible to refresh a tab page's controls(e.g textboxes, combobox, datagridview) when a different tab is selected so when i go back to the previous tab, i don't want to see any data but rather the controls blank or refreshed. I've tried to work with selectedindexchanged but...
1
7538
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
7869
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
6121
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
5421
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
5140
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...
0
3543
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2003
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
1113
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
817
bsmnconsultancy
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...

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.