| Refresh only the CurrentRow of a DataGridView? |
|
 |
Index ‹ DotNet ‹ Winforms
|
- Previous
- 1
- ADO >> One Has Many relation via Dataset to XML questionHi,
I am trying to import/export XML from a database. For the purpose of
this posting I will keep the datastructures as simple as possible. Just
imagine a table 'User' and a table 'Roles', and then a table
'UserHasRole' that specifies what users have what roles (m:n relation).
The idea is that these tables store information about users and the
roles they have got assigned.
--- Tables start
Table User:
UserId
Name
Table Role:
RoleId
Name
Table UserHasRole:
UserHasRoleId
UserId
RoleId
--- Tables end
Now, what I would like is to export data from a database with the above
table layout to XML, let a (rather experienced) user edit the XML file
and then reimport the modified XML file. (Our system has no notion of
deleting users or roles, which significantly simplifies my task) Ideally
I would like to end up with an XML file similar to the following:
--- sample XML file start
<my_xml_io>
<Users>
<User id="1">
<Name>Foo</Name>
<HasRoles>
<Role id="1"/>
<Role id="3"/>
<Role id="4"/>
</HasRoles>
</User>
<User id="2">
<Name>Bar</Name>
<HasRoles>
<Role id="2"/>
</HasRoles>
</User>
</Users>
<Roles>
<Role id="1">
<Name>Admin</Name>
</Role>
<Role id="2">
<Name>Guest</Name>
</Role>
<Role id="3">
<Name>Developer</Name>
</Role>
<Role id="4">
<Name>Manager</Name>
</Role>
</Roles>
</my_xml_io>
--- sample XML file end
I.e. the m:n relation is represented implicitly in the 'User' element.
Now with all the DataSet automation support in VS.NET my first try,
was to visually design some typed datasets, fill them from the db and
then use 'WriteXML'. But the XML I get looks like this (simplified a bit):
--- generated XML file start
<my_xml_io>
<User id="1">
<Name>Foo</Name>
</User>
<User id="2">
<Name>Bar</Name>
</User>
<Role id="1">
<Name>Admin</Name>
</Role>
<Role id="2">
<Name>Guest</Name>
</Role>
<Role id="3">
<Name>Developer</Name>
</Role>
<Role id="4">
<Name>Manager</Name>
</Role>
<UserHasRole id="1">
<UserId>1</UserId>
<RoleId>1</RoleId>
</UserHasRole>
<UserHasRole id="2">
<UserId>1</UserId>
<RoleId>3</RoleId>
</UserHasRole>
<UserHasRole id="3">
<UserId>1</UserId>
<RoleId>4</RoleId>
</UserHasRole>
<UserHasRole id="4">
<UserId>2</UserId>
<RoleId>2</RoleId>
</UserHasRole>
</my_xml_io>
--- generated XML file end
What is the best way to archive my desired XML representation, instead
of the normalized one I currently get?
many thanks in advance,
Andreas
- 2
- Microsoft Project >> Differing task TypesI have an Integrated Plan with approx 20 sub-projects linked into it. I have
noticed that these plans are a mixture of Fixed Unit default task type plans
and Fixed Duration default task type plans. Is this a problem when the
Integrated plan performs its calculations?
- 3
- Winforms >> databinding problems using a datagridI have a datagrid refresh problem. I manually create a datatable, add in the
data rows and bind it to a datagrid. To refresh, I clear the databindings,
remove the datatable from the dataset, recreate the datatable, add the new
rows and bind it to the datagrid.
It works fine when the datatable is created the first time. But when it is
refreshed, the original rows are still displayed in the datagrid.
To demostrate the problem, add a couple of buttons, a datagrid and dataset
to a form, and add the following code to the button click events.
private void button1_Click(object sender, System.EventArgs e)
{
dataGrid1.DataBindings.Clear();
if (dataSet1.Tables.Contains("mytable")) dataSet1.Tables.Remove("mytable");
DataTable dataTable = dataSet1.Tables.Add("mytable");
dataTable.Columns.Add("column1", typeof(string));
dataTable.Columns.Add("column2", typeof(string));
dataTable.Columns.Add("column3", typeof(string));
dataTable.Columns.Add("column4", typeof(string));
dataTable.Rows.Add(new object[]{ "R1C1", "R1C2", "R1C3", "R1C4" });
dataTable.Rows.Add(new object[]{ "R2C1", "R2C2", "R2C3", "R2C4" });
dataTable.Rows.Add(new object[]{ "R3C1", "R3C2", "R3C3", "R3C4" });
dataTable.Rows.Add(new object[]{ "R4C1", "R4C2", "R4C3", "R4C4" });
dataGrid1.SetDataBinding(dataSet1, "mytable");
}
private void button2_Click(object sender, System.EventArgs e)
{
dataGrid1.DataBindings.Clear();
if (dataSet1.Tables.Contains("mytable")) dataSet1.Tables.Remove("mytable");
DataTable dataTable = dataSet1.Tables.Add("mytable");
dataTable.Columns.Add("column1", typeof(string));
dataTable.Columns.Add("column2", typeof(string));
dataTable.Columns.Add("column3", typeof(string));
dataTable.Columns.Add("column4", typeof(string));
dataTable.Rows.Add(new object[]{ "R4C4", "R4C3", "R4C2", "R4C1" });
dataTable.Rows.Add(new object[]{ "R3C4", "R3C3", "R3C2", "R3C1" });
dataTable.Rows.Add(new object[]{ "R2C4", "R2C3", "R2C2", "R2C1" });
dataTable.Rows.Add(new object[]{ "R1C4", "R1C3", "R1C2", "R1C1" });
dataGrid1.SetDataBinding(dataSet1, "mytable");
}
Binding using dataGrid1.SetDataBinding(dataSet1, "mytable"); or
dataGrid1.DataSource = dataSet1; dataGrid1.DataMember = "mytable"; causes
the problem.
Binding using dataGrid1.SetDataBinding(dataSet1.Tables[ "mytable" ], ""); or
dataGrid1.DataSource = dataSet1.Tables[ "mytable" ]; dataGrid1.DataMember =
""; works fine.
Regards,
Phil.
- 4
- Dotnet >> Closed Captioning: from a DVD to a StringHello all!
I'm trying (read: becoming frustrated) to write a DVD viewer in VB.NET. I
can embed the DVD picture using DirectX technology, but it seems to be
impossible to obtain closed captioning from the DVD and convert it to a
string. There were a few tips on getting the captioning in the MSDN, I know,
but they were rather cryptic (unusual) and didn't convert the captioning to a
string.
If there is anyone who can help me, or even just tell me what I'm trying is
impossible, I'd be most grateful.
--
Wraith Daquell
...there is only one Daquell.
- 5
- Winforms >> Form control re-build when entering the MDI containerWe have a huge activex control embedded in a Form window. When the Form
has its MDIParent set to a mdi container, the window handle of the Form
is replaced by a new one, and our control has to be InPlaceActivate
twice plus one InPlaceDeactivate( The window handles of the standard
controls within are also replaced ), This causes side effects to our
activex control. The activation involves lengthy initializations such
as downloading data from internet and heavy rendering work, so it is
too expensive to do InPlaceActivate frequently. And our control has
some operations depending on the parent window. Is there any workaround
to avoid frequent inplace activation and window re-building, for
example, creating the mdi child form directly from the MDI container?
- 6
- 7
- ADO >> How to INSERT pure <NULL> Into SmallDataTime Field (MS SQL Server)I need to insert NULL into the field with SmallDataTime datatype.
In .NET when I tried to use "" or DBNull.Value it insert "" what
will be automatically converted into '1/1/1900' by SQL Server...
I need to have the Insert statement like this:
INSERT tblTest (Name,smDate) Values ('John',NULL)
But using pure NULL without double quotes ("") is not allowed in .NET.
When I use double quotes ("NULL"), .NET interpreted it as
character string and I got the SQL converting error.
Thank you for the help.
Eugene
- 8
- Visual C#.Net >> control helpI have 10 textboxes on my page, textbox1 - textbox10. Rather than modify
them individually, I would like to modify them with a variable something
like this:
for (int i = 0; i <= 10; i++)
{
textbox[i].text = "some text";
}
Is this possible? Would I need to create some kind of control array?
Thanks,
Dave
- 9
- Visual C#.Net >> How to get instance of a container from the control insideI have a class extending PictureBox. I use it as container adding a
Label control inside the PictureBox.
I use this kind of "widget" in another class, and I want to catch the
event on mouse click on the label only. That works.
But in the event function, I want to call a function to modify the
container, but I don't know how to do that.
Example:
namespace xxx
class myPictureBox : System.Windows.Forms.PictureBox
{
private Label txt;
public myPictureBox()
{
txtTab = new Label();
this.Controls.Add(txtTab);
}
public void SetPictureBoxAttributes(//some stuff)
{
//set some stuff
}
public Label GetTabLabel()
{
return txt;
}
}
class myApp
{
public myApp()
{
xxx.MyPictureBox pb = new xxx.MyPictureBox();
pb.SetPictureBoxAttributes(//some stuff);
pb.GetTabLabel().MouseDown += new
System.Windows.Forms.MouseEventHandler(this.pblabMouseDown);
}
public void thetabMouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
Label currentlabel = (Label)sender;
currentlabel.????? // what to call to retreive the container pb
and
// call the function
SetPictureBoxAttributes();
// ???????????????????????
}
}
Thank you
François
*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
- 10
- Microsoft Project >> Language mixtureToday I installed english versions of MS Project 2007 and Project 2003 on a
PC, were previously a german version of Project 2003 was installed. Both
english versions are working fine, but the are showing in some menus (e.g.
"Filters" and "Views") elements of the older, not longer existing german
version. This mixed user interface is confusing. How can I remove the old
text elements?
Regards
Claus
- 11
- Visual C#.Net >> Binding problemHello!
at runtime, when the execution reaches this line:
oGetExpression.DataBindings.Add("Expression",myDataSet,"ADR.Condition");
where: <Expression> is a public property of type string
<myDataSet> is the datasource
<"Adr.Condition"> is the datamember from dataset:
table.tableField
this exception is thrown:
"Object type cannot be converted to target type."
why is this happening?
Thank you.
- 12
- Net Framework >> Memory leak in C#?????I have a button on a form, and when you click the button, it performs
the following:
using (FormMS f = new FormMS())
{
f.ShowDialog();
}
The new form that is shown (FormMS) has a DataGrid that gets bound to
a large DataTable. The DataTable is static so it only gets created
once. So I open FormMS as a dialog and then close it. I continue to
open and close it several times and each time, the memory used by my
application goes up a lot. It doesn't seem to deallocate the memory
needed by the DataGrid. I try calling GC.Collect() after the FormMS
closes and it doesn't do the trick. I tried letting the application
sit overnight to see if it would deallocate the memory and that
doesn't work. I try calling the DataGrid.Dispose method inside my
FormMS.Dispose method and that doesn't work. I have to restart the
application to get it to deallocate the memory. I keep opening it
again and again to see if I must use up all my physical memory before
it deallocates, and that doesn't work either.
Any ideas?
Thanks in advance.
- 13
- Visual C#.Net >> Threading problem - Urgent HelpHi,
I have the following problem. I created a
Properties section:
private SerialComm oComm = new SerialComm(); // Wraps a DLL to handle Serial
//comms.
private Thread PrinterThread = null; // Serial Communications Thread
private void Form_load(...)
{
PrinterThread = new Thread(new ThreadStart(StartPrinter));
PrinterThread.Name = "SerialPrinter";
}
// The Thread is started in this procedure
private void button_click(....)
{
if (PrinterThread.ThreadState.ToString() == "Unstarted")
{
try
{
PrinterThread.Start();
Thread.Sleep(0);
}
catch (Exception Ex)
{
//Handle exception
}
}
// This is the procedure the for the Thread
private void StartPrinter()
{
Thread.Sleep(0);
LogInfo("Label Printing: printing thread started");
oComm.sendToPrinter(sFactor,false);
// Calls the serial printing process. It starts its own receiving Thread
within it.
// Returns to this procedure when done. The receiving thread must have
been
//aborted.
if (oComm.lStatus)
this.sMessage.Text = "Printing label has Finished";
// I got an Thread exeption here. After the aborting the receiving
thread
// If this.sMessage.txt is not there, it doesn't happen. Why????
// The exception says: ThreadException found while thread is being
aborted.
// I think it refers to the receiving thread.
this.cmdLabel.Enabled = true;
this.cmdReprint.Enabled = true
}
Thank you,
Carlos
- 14
- Visual C#.Net >> Display Linked-List in a DataGridView?How do I set a linked-list as a data source for a DataGridView control?
Should the linked list be a member on a form or its own global class
(or doesn't matter...???) Right now when I set the list as the data
source, the only columns I get are Count, First, and Last. I want data
from the nodes displayed but they are not available as columns to be added.
- 15
- Visual C#.Net >> unhandled exception of type 'System.Net.WebException' occurred in system.web.services.dllI have a C# MRS application that uses the ReportingService's Render
method to retrieve a byte array containing a report.
The following error message occurs
An unhandled exception of type 'System.Net.WebException' occurred in
system.web.services.dll
Additional information: The operation has timed-out.
I saw the following post on MSDN
An unhandled exception of type 'System.Net.WebException' occurred in
system.web.services.dll Additional information: The operation has
timed-out.
To avoid this problem, set the timeout value for the XML Web service
call to infinite, as shown in this example:
Service1 obj = new Service1();
obj.TimeOut = -1; // infinite time out.
My question is how do I incorporate the code into my application - I get
a
Invalid token '=' in class, struct, or interface member declaration
Error message
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
|
| Author |
Message |
playmissy4me

|
Posted: Thu May 03 00:02:03 CDT 2007 |
Top |
Winforms >> Refresh only the CurrentRow of a DataGridView?
I have a DGV that is read only. When selecting a row, the item is edited in
individual controls elsewhere on the form, also bound to the same
bindingsource. The default behavior is that when the value is changed in a
textbox, it only repaints the value in the DGV cell after the textbox commits
the value to the underlying object. I want it to update the DGV cell's
display in real time. To do this, I have code in the textbox's TextChanged
event to update the underlying object's property and refresh the DGV. This
works ok. However, if there are more than a handful of records displayed,
this refresh is slow and distracting.
So two questions:
1) Am I approaching this the correct way? Is there a better way to have the
DGV reflect the changes in real time?
2)If this is the best way, is there any way to refresh/repaint only the
currently selected row?
Thanks for any ideas.
Barry
DotNet259
|
| |
|
| |
 |
RobinS

|
Posted: Thu May 03 00:02:03 CDT 2007 |
Top |
Winforms >> Refresh only the CurrentRow of a DataGridView?
Are you using a BindingSource? .Net 1.1 or .Net 2.0? C# or VB?
Robin S.
---------------------
"Barry Gilbert" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
>I have a DGV that is read only. When selecting a row, the item is edited
>in
> individual controls elsewhere on the form, also bound to the same
> bindingsource. The default behavior is that when the value is changed in
> a
> textbox, it only repaints the value in the DGV cell after the textbox
> commits
> the value to the underlying object. I want it to update the DGV cell's
> display in real time. To do this, I have code in the textbox's
> TextChanged
> event to update the underlying object's property and refresh the DGV.
> This
> works ok. However, if there are more than a handful of records displayed,
> this refresh is slow and distracting.
>
> So two questions:
> 1) Am I approaching this the correct way? Is there a better way to have
> the
> DGV reflect the changes in real time?
> 2)If this is the best way, is there any way to refresh/repaint only the
> currently selected row?
>
> Thanks for any ideas.
>
> Barry
|
| |
|
| |
 |
BarryGilbert

|
Posted: Thu May 03 01:04:00 CDT 2007 |
Top |
Winforms >> Refresh only the CurrentRow of a DataGridView?
Bindingsource: Yes.
2.0
VB
Barry
"RobinS" wrote:
> Are you using a BindingSource? .Net 1.1 or .Net 2.0? C# or VB?
>
> Robin S.
> ---------------------
> "Barry Gilbert" <EMail@HideDomain.com> wrote in message
> news:EMail@HideDomain.com...
> >I have a DGV that is read only. When selecting a row, the item is edited
> >in
> > individual controls elsewhere on the form, also bound to the same
> > bindingsource. The default behavior is that when the value is changed in
> > a
> > textbox, it only repaints the value in the DGV cell after the textbox
> > commits
> > the value to the underlying object. I want it to update the DGV cell's
> > display in real time. To do this, I have code in the textbox's
> > TextChanged
> > event to update the underlying object's property and refresh the DGV.
> > This
> > works ok. However, if there are more than a handful of records displayed,
> > this refresh is slow and distracting.
> >
> > So two questions:
> > 1) Am I approaching this the correct way? Is there a better way to have
> > the
> > DGV reflect the changes in real time?
> > 2)If this is the best way, is there any way to refresh/repaint only the
> > currently selected row?
> >
> > Thanks for any ideas.
> >
> > Barry
>
>
>
|
| |
|
| |
 |
RobinS

|
Posted: Sun May 06 23:29:59 CDT 2007 |
Top |
Winforms >> Refresh only the CurrentRow of a DataGridView?
I guess my question would be why are you doing this? It seems to me to make
more sense for the user to put in all the fields and then maybe hit a
<Save> button and it upgrades all the entries in that row at the same time.
Maybe he would like to see what the old values are before committing the
new ones?
If you are committed to this course of action, my question is when you say
this:
>> > it only repaints the value in the DGV cell after the textbox
>> > commits
>> > the value to the underlying object
what do you mean? Are you forcing an EndEdit() on the binding source, or a
Validate() or do you mean actually updating the data source?
Seems to me you might be able to accomplish this by databinding the same
data source to the same binding source. So you have a table that is data
bound to your DGV, and then you bind the textbox to the same data source
with the same binding source. I think it will show the same information?
Have you tried that?
Are you using data tables/datasets or business objects? If you are using
business objects, you can implement INotifyPropertyChanged and it will
repaint the grid automatically.
Robin S.
---------------------
"Barry Gilbert" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> Bindingsource: Yes.
> 2.0
> VB
>
> Barry
>
> "RobinS" wrote:
>
>> Are you using a BindingSource? .Net 1.1 or .Net 2.0? C# or VB?
>>
>> Robin S.
>> ---------------------
>> "Barry Gilbert" <EMail@HideDomain.com> wrote in
>> message
>> news:EMail@HideDomain.com...
>> >I have a DGV that is read only. When selecting a row, the item is
>> >edited
>> >in
>> > individual controls elsewhere on the form, also bound to the same
>> > bindingsource. The default behavior is that when the value is changed
>> > in
>> > a
>> > textbox, it only repaints the value in the DGV cell after the textbox
>> > commits
>> > the value to the underlying object. I want it to update the DGV cell's
>> > display in real time. To do this, I have code in the textbox's
>> > TextChanged
>> > event to update the underlying object's property and refresh the DGV.
>> > This
>> > works ok. However, if there are more than a handful of records
>> > displayed,
>> > this refresh is slow and distracting.
>> >
>> > So two questions:
>> > 1) Am I approaching this the correct way? Is there a better way to
>> > have
>> > the
>> > DGV reflect the changes in real time?
>> > 2)If this is the best way, is there any way to refresh/repaint only
>> > the
>> > currently selected row?
>> >
>> > Thanks for any ideas.
>> >
>> > Barry
>>
>>
>>
|
| |
|
| |
 |
BarryGilbert

|
Posted: Mon May 07 08:43:01 CDT 2007 |
Top |
Winforms >> Refresh only the CurrentRow of a DataGridView?
Robin,
Thanks for your reply.
"RobinS" wrote:
> I guess my question would be why are you doing this? It seems to me to make
> more sense for the user to put in all the fields and then maybe hit a
> <Save> button and it upgrades all the entries in that row at the same time.
> Maybe he would like to see what the old values are before committing the
> new ones?
I want the user to see the results of their changes in the dgv in real time.
This is why I want this behavior. If I don't do this, the behavior can be
confusing. Besides textboxes, I also have checkboxes. If the default behavior
is retained, it isn't obvious to the user that they have successfully changed
the checkbox's value until the leave the control. The next control they need
to click might be the Save button, but there are some validation rules which
disable the save button. In this case, it seems clumsy to ask the user to tab
off every control to see his changes, especially if they only want to click
Save.
> If you are committed to this course of action, my question is when you say
> this:
>
> >> > it only repaints the value in the DGV cell after the textbox
> >> > commits
> >> > the value to the underlying object
>
> what do you mean? Are you forcing an EndEdit() on the binding source, or a
> Validate() or do you mean actually updating the data source?
When I say this is the default behavior, I mean that it's how the
BindingSource/dgv work without any intervention on my part. I already have
both the dgv and the individual textboxes bound to the same bindingSource.
When you do this, the dgv only reflects changes to the bndingSource, which is
only updated when the textbox's value is committed, by exiting the control.
> Seems to me you might be able to accomplish this by databinding the same
> data source to the same binding source. So you have a table that is data
> bound to your DGV, and then you bind the textbox to the same data source
> with the same binding source. I think it will show the same information?
> Have you tried that?
>
> Are you using data tables/datasets or business objects? If you are using
> business objects, you can implement INotifyPropertyChanged and it will
> repaint the grid automatically.
>
I am binding to custom business objects which do implement
INotifyPropertyChanged. However, as I've mentioned, while it does repaint the
grid automatically, it does so only after the property in the bindingsource
is updated, which occurs only after the textbox's value is committed, when
leaving the control.
Barry
|
| |
|
| |
 |
BarryGilbert

|
Posted: Mon May 07 08:45:01 CDT 2007 |
Top |
Winforms >> Refresh only the CurrentRow of a DataGridView?
Robin,
Thanks for your reply.
"RobinS" wrote:
> I guess my question would be why are you doing this? It seems to me to make
> more sense for the user to put in all the fields and then maybe hit a
> <Save> button and it upgrades all the entries in that row at the same time.
> Maybe he would like to see what the old values are before committing the
> new ones?
I want the user to see the results of their changes in the dgv in real time.
This is why I want this behavior. If I don't do this, the behavior can be
confusing. Besides textboxes, I also have checkboxes. If the default behavior
is retained, it isn't obvious to the user that they have successfully changed
the checkbox's value until the leave the control. The next control they need
to click might be the Save button, but there are some validation rules which
disable the save button. In this case, it seems clumsy to ask the user to tab
off every control to see his changes, especially if they only want to click
Save.
> If you are committed to this course of action, my question is when you say
> this:
>
> >> > it only repaints the value in the DGV cell after the textbox
> >> > commits
> >> > the value to the underlying object
>
> what do you mean? Are you forcing an EndEdit() on the binding source, or a
> Validate() or do you mean actually updating the data source?
When I say this is the default behavior, I mean that it's how the
BindingSource/dgv work without any intervention on my part. I already have
both the dgv and the individual textboxes bound to the same bindingSource.
When you do this, the dgv only reflects changes to the bndingSource, which is
only updated when the textbox's value is committed, by exiting the control.
> Seems to me you might be able to accomplish this by databinding the same
> data source to the same binding source. So you have a table that is data
> bound to your DGV, and then you bind the textbox to the same data source
> with the same binding source. I think it will show the same information?
> Have you tried that?
>
> Are you using data tables/datasets or business objects? If you are using
> business objects, you can implement INotifyPropertyChanged and it will
> repaint the grid automatically.
>
I am binding to custom business objects which do implement
INotifyPropertyChanged. However, as I've mentioned, while it does repaint the
grid automatically, it does so only after the property in the bindingsource
is updated, which occurs only after the textbox's value is committed, when
leaving the control.
Barry
|
| |
|
| |
 |
Brian

|
Posted: Mon May 07 10:47:32 CDT 2007 |
Top |
Winforms >> Refresh only the CurrentRow of a DataGridView?
Is there a reason you're using a read-only DataGridView instead of an
editable grid, which would save all this synchronization trouble?
--
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets
"Barry Gilbert" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> Robin,
> Thanks for your reply.
>
> "RobinS" wrote:
>
>> I guess my question would be why are you doing this? It seems to me to
>> make
>> more sense for the user to put in all the fields and then maybe hit a
>> <Save> button and it upgrades all the entries in that row at the same
>> time.
>> Maybe he would like to see what the old values are before committing the
>> new ones?
>
> I want the user to see the results of their changes in the dgv in real
> time.
> This is why I want this behavior. If I don't do this, the behavior can be
> confusing. Besides textboxes, I also have checkboxes. If the default
> behavior
> is retained, it isn't obvious to the user that they have successfully
> changed
> the checkbox's value until the leave the control. The next control they
> need
> to click might be the Save button, but there are some validation rules
> which
> disable the save button. In this case, it seems clumsy to ask the user to
> tab
> off every control to see his changes, especially if they only want to
> click
> Save.
>
>> If you are committed to this course of action, my question is when you
>> say
>> this:
>>
>> >> > it only repaints the value in the DGV cell after the textbox
>> >> > commits
>> >> > the value to the underlying object
>>
>> what do you mean? Are you forcing an EndEdit() on the binding source, or
>> a
>> Validate() or do you mean actually updating the data source?
>
> When I say this is the default behavior, I mean that it's how the
> BindingSource/dgv work without any intervention on my part. I already have
> both the dgv and the individual textboxes bound to the same bindingSource.
> When you do this, the dgv only reflects changes to the bndingSource, which
> is
> only updated when the textbox's value is committed, by exiting the
> control.
>
>> Seems to me you might be able to accomplish this by databinding the same
>> data source to the same binding source. So you have a table that is data
>> bound to your DGV, and then you bind the textbox to the same data source
>> with the same binding source. I think it will show the same information?
>> Have you tried that?
>>
>> Are you using data tables/datasets or business objects? If you are using
>> business objects, you can implement INotifyPropertyChanged and it will
>> repaint the grid automatically.
>>
> I am binding to custom business objects which do implement
> INotifyPropertyChanged. However, as I've mentioned, while it does repaint
> the
> grid automatically, it does so only after the property in the
> bindingsource
> is updated, which occurs only after the textbox's value is committed, when
> leaving the control.
>
> Barry
|
| |
|
| |
 |
BarryGilbert

|
Posted: Mon May 07 11:00:00 CDT 2007 |
Top |
Winforms >> Refresh only the CurrentRow of a DataGridView?
Brian,
I beat my head against the wall for three weeks trying to use in-line
editing in the dgv. There were too many issues, especially with combobox
columns. In my humble opinion, the dgv is still a disappointing
work-in-process. Using seperate editing controls ended up being a better,
more intuitive solution.
Barry
"Brian Schwartz" wrote:
> Is there a reason you're using a read-only DataGridView instead of an
> editable grid, which would save all this synchronization trouble?
>
> --
> Brian Schwartz
> FishNet Components
> http://www.fishnetcomponents.com
> Fish Grid .NET Light: Powerful Layouts for Small Datasets
>
> "Barry Gilbert" <EMail@HideDomain.com> wrote in message
> news:EMail@HideDomain.com...
> > Robin,
> > Thanks for your reply.
> >
> > "RobinS" wrote:
> >
> >> I guess my question would be why are you doing this? It seems to me to
> >> make
> >> more sense for the user to put in all the fields and then maybe hit a
> >> <Save> button and it upgrades all the entries in that row at the same
> >> time.
> >> Maybe he would like to see what the old values are before committing the
> >> new ones?
> >
> > I want the user to see the results of their changes in the dgv in real
> > time.
> > This is why I want this behavior. If I don't do this, the behavior can be
> > confusing. Besides textboxes, I also have checkboxes. If the default
> > behavior
> > is retained, it isn't obvious to the user that they have successfully
> > changed
> > the checkbox's value until the leave the control. The next control they
> > need
> > to click might be the Save button, but there are some validation rules
> > which
> > disable the save button. In this case, it seems clumsy to ask the user to
> > tab
> > off every control to see his changes, especially if they only want to
> > click
> > Save.
> >
> >> If you are committed to this course of action, my question is when you
> >> say
> >> this:
> >>
> >> >> > it only repaints the value in the DGV cell after the textbox
> >> >> > commits
> >> >> > the value to the underlying object
> >>
> >> what do you mean? Are you forcing an EndEdit() on the binding source, or
> >> a
> >> Validate() or do you mean actually updating the data source?
> >
> > When I say this is the default behavior, I mean that it's how the
> > BindingSource/dgv work without any intervention on my part. I already have
> > both the dgv and the individual textboxes bound to the same bindingSource.
> > When you do this, the dgv only reflects changes to the bndingSource, which
> > is
> > only updated when the textbox's value is committed, by exiting the
> > control.
> >
> >> Seems to me you might be able to accomplish this by databinding the same
> >> data source to the same binding source. So you have a table that is data
> >> bound to your DGV, and then you bind the textbox to the same data source
> >> with the same binding source. I think it will show the same information?
> >> Have you tried that?
> >>
> >> Are you using data tables/datasets or business objects? If you are using
> >> business objects, you can implement INotifyPropertyChanged and it will
> >> repaint the grid automatically.
> >>
> > I am binding to custom business objects which do implement
> > INotifyPropertyChanged. However, as I've mentioned, while it does repaint
> > the
> > grid automatically, it does so only after the property in the
> > bindingsource
> > is updated, which occurs only after the textbox's value is committed, when
> > leaving the control.
> >
> > Barry
>
>
>
|
| |
|
| |
 |
BarryGilbert

|
Posted: Tue May 08 14:40:01 CDT 2007 |
Top |
Winforms >> Refresh only the CurrentRow of a DataGridView?
For posterity, I've figured out how to do this:
myDataGridView.InvalidateRow(myDataGridView.CurrentRow.Index)
Barry
"Barry Gilbert" wrote:
> I have a DGV that is read only. When selecting a row, the item is edited in
> individual controls elsewhere on the form, also bound to the same
> bindingsource. The default behavior is that when the value is changed in a
> textbox, it only repaints the value in the DGV cell after the textbox commits
> the value to the underlying object. I want it to update the DGV cell's
> display in real time. To do this, I have code in the textbox's TextChanged
> event to update the underlying object's property and refresh the DGV. This
> works ok. However, if there are more than a handful of records displayed,
> this refresh is slow and distracting.
>
> So two questions:
> 1) Am I approaching this the correct way? Is there a better way to have the
> DGV reflect the changes in real time?
> 2)If this is the best way, is there any way to refresh/repaint only the
> currently selected row?
>
> Thanks for any ideas.
>
> Barry
|
| |
|
| |
 |
| |
 |
Index ‹ DotNet ‹ Winforms |
- Next
- 1
- ADO >> assigning null value to the Yes/No field of MS Access database tablehi
I want to assign null value to Yes/No field. So that the value of the field
of MS Access database table is neither YES nor NO. Is this possible? The
field properties show that there is a property called "Allow Null". I have
set it to TRUE. But this does not help.
I thereafter try to access this table from VB.NET and try to read the value
or insert a record with this field value as NULL. But when I read the record
as DBBoolean, I always get value as FALSE.
Can somebody throw some light on the same?
warm regards
Haresh Gujarathi
- 2
- Visual C#.Net >> about inheritanceHello!
Assume I have a base class called Base and a derived class called Sub.
Assume all the property for the Base class can't fit exactly for the Sub
class.
I mean some of the property for the Base class is wrong for the Sub class is
it then allowed
to inherit from class Base.
The main issue when using inheritance is that Sub is a Base.
//Tony
- 3
- Winforms >> Newbie question: how to set focus to a usercontrolI have a usercontrol that contains another usercontrol,
which in turn contains a PictureBox control.
Under a certain condition, I need to set the input
focus on the outermost usercontrol. But once the PictureBox
control (the outermost usercontrol's grandchild) has got
the input focus, I cannot transfer the focus back to the
outermost usercontrol (at least not by simply invoking its
Focus() member function).
Why is this? What can I do to take away the keyboard input
focus from that grandchild, the PictureBox control, and
transfer it back to the outermost usercontrol? (I have tried
to find information about keyboard focus handling that seems
relevant to this question, but what I have found seems rather
far removed from what I need to understand here...)
Note: My application requires very little keyboard input:
mainly a few keyboard-accelerators, and the copy/paste/
cut/delete key. But the copy/paste/cut/delete key must
go to the right usercontrol, because copy/paste/cut/delete
must be handled differently, depending on which usercontrol
has the input focus (or, rather, should have it, from my
point of view). In essence, I am trying to base input
focus on the position of the mouse pointer: if that grandchild
PictureBox control does not have the mouse pointer within
its bounds, it should not receive keyboard input, i.e.
should not have input focus.
Regards and thanks in advance for any enlightenment on
this question,
Christian
- 4
- Net Framework >> rotating pictures on the flyIs there a way in vb.net to, 1) detect if an image has been taken with a
> camera on a vertical axis, and 2) rotate the picture for display - across
> an
> intranet (asp.net), with huge files sizes (2 - 3 MB), that doesn't take
> too long?
> (LOL)
>
> Thanks,
> Jim
- 5
- Visual C#.Net >> Mouse move eventsHi,
I have an MDI app that allows user to create flowcharts.
User can drag flowchart objects (squares, rectangles,
elipses, etc) from the toolbar and put on a form. They
should be able to move the objects around on the form.
This is where the problem is, I have implemented this
using the mouse_down, mouse_up and mouse_move events of
the form. When user selects a object, I receive the
mouse_down mesg, in which I save the current mouse
coordinates. When user drags the object around I receive
mouse move events, in which I compute the distance that
the mouse has moved and move the object by that distance.
When the object is moved, that itself generates new
mouse_move events in the opposite direction. Why are these
events generated and how can I prevent them?
Thanks,
Suhas
- 6
- Winforms >> Smart Client - IIS errorI'm writing the download stub for a Smart Client, following the QuickStart
samples that come with the Updater Block 2.0.
Tested against my local IIS, the stub works perfectly, but when I deploy it
to a server, I get "The system cannot find the file specified" in my browser.
Local Machine is IIS 6.0, Remote Server is IIS 5.0
Thanks for your help
- 7
- Net Framework >> updating a shared files using Updater Applicatin BlockHi there,
I have about 20 applications.
There are many dll files that these applications share.
I want to avoid having the duplicated dll files.
Therefore, I crate a folder for these dll files.
Now I want to create an updater system using Updater Application Block.
I know that Updater Application Block is used to individually update
applications.
However, can I update an application along with some dll files in a shared
folder?
I would appreciate your feedback!
- 8
- Visual C#.Net >> Help running scriptI am trying to force my machine to run the Cscript engine against a vbs
script file. Why would the two act differently.
When I run the following code it does not execute the vbs script the same
way as the second option.
scriptConsoleProcess = new Process();
scriptConsoleProcess.StartInfo.FileName = "CScript.exe";
scriptConsoleProcess.StartInfo.Arguments = scriptPath;
scriptConsoleProcess.StartInfo.CreateNoWindow = true;
scriptConsoleProcess.Start();
This option works when I have the CScript set as my default engine.
scriptConsoleProcess = new Process();
scriptConsoleProcess.StartInfo.FileName = scriptPath;
scriptConsoleProcess.StartInfo.CreateNoWindow = true;
scriptConsoleProcess.Start();
- 9
- Visual C#.Net >> Need Help urgentdaer all...
i'm a new comer with C#, but i want to build a mobile application. does any body can tell me, where do i can start ?
what software needed ?
where i can find a good references to learn it ?
i have .Net installed on my PC, but when there is no Mobile Web Application template. Is there some thing missed with it ?
please help.....
best regards....
- 10
- Visual C#.Net >> To Mitchell S. Honnerthttp://groups.google.com.pk/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/a28a501a72dce06d?hl=en
Continued from above:
I check out your lib and sample but I was unable to find how to perform
my desired task.:( I would be really thankful to you if you write a
sample code where sound and ID3 tags are synchronized with each other.
Thanks in Advance for ur help.
With best regards
Qumer
- 11
- Visual C#.Net >> Using C# to create a scheduled jobI need to create an executible that will run on a nightly basis.
The executible is a simple command line statement like:
OSQL -Usa -PmyPasword -n -Q "BACKUP DATABASE msdb TO DISK =
'c:\msdb.dat_bak'"
Is it possible to use C# to create an executible that will run this command
line statement on a scheduled basis?
If so, can anyone give me some general ideas on how to go about this?
- 12
- 13
- ADO >> DataSet diffecencesHello,
is there a simple method to get Rows which differ in their values between
two different DataSets?
Ondra.
- 14
- Winforms >> Please help - how to call a web link in a windows form...Dear Experts,
I am asked to develop a Windows Application that calls to a given web link
(e.g. http://localhost/Test.aspx?id=1234) and catches the returned HTML from
this link (returned from web server of course). I really have no idea on how
to accomplish this. Could you please give me some hints on resolving this or
please indicate any resources/references that I can refer to?
Thanks a lot for your help.
Tigger
--
I am Tigger.
- 15
- Microsoft Project >> Percent Work CompleteWhat is the difference between % Complete and % Work
Complete? I have tasks where the two are wildly different
even though there are resources assigned. I have been
updating the % Complete only. Thanks for any advice.
|
|
|