|
I have this test code where I can see the same behavior. Can someone point what am I doing wrong here?
static void Main(string[] args)
{
DataTable table = new DataTable();
DataColumn col = new DataColumn("ID", System.Type.GetType("System.Int32"));
table.Columns.Add(col);
for (int i = 0; i < 10; i++)
{
DataRow row = table.NewRow();
row["ID"] = i;
table.Rows.Add(row);
}
Console.WriteLine(table.Rows.Count);
for (int i = 0; i < table.Rows.Count;i++ )
{
if (Convert.ToInt32(table.Rows[i]["ID"]) == 4)
{
table.Rows[i].Delete();
break;
}
}
Console.WriteLine(table.Rows.Count);
DataTable deletedRows = table.GetChanges(DataRowState.Deleted); // This returns NULL, shouldn't it have one row here???
for (int i = 0; i < deletedRows.Rows.Count; i++)
{
Console.WriteLine("Deleted: " + deletedRows.Rows[i]["ID",DataRowVersion.Original].ToString());
}
}
|
|
|
|
|
Got it, was missing AcceptChanges()
|
|
|
|
|
When you delete rows using DataRow.Delete() method, they're immediately deleted from the DataTable. What DataTable.AcceptChanges() does is to propagate back the changes to the original data source of the DataTable (e.g., an SQL Server database)
|
|
|
|
|
ajaykulkarnir wrote: on selecting Comp-2 i want who is logged on to Comp-2 machine present in LAN
One option would be using the PowerShell[^]. You could also query WMI[^] for Win32_LoggedOnUser . You could also opt to write a small daemon that sends a small message containing the Environment.UserName to the server.
I are Troll
|
|
|
|
|
Hi Everybody!
I have need a help! How i can get source code of a popup window via webbrowser? i navigate a url and get webbrowser document elements. But when i open a popup window i dont get source codes and document elemens of popup window.
Some Idea?
|
|
|
|
|
Hello All,
When internet explorer open and have it maximized on the screen, and if then goback to my application and then click on menuitem. Which popups a child form. Upon closing child form, parent form loosing its focus and IE show uop on Top of my application.
How i can i activate my Application when any child form closed.
Thanks In Advance.
Sri
|
|
|
|
|
How do you show the childform? Did you set the owner in the .Show() statement?
I are Troll
|
|
|
|
|
Hello Eddy,
Yes, i set the parent form as property. And before closing childform i called prentform.activate() method.
Regards,
Sri
|
|
|
|
|
sri_0099 wrote: Yes, i set the parent form as property. And before closing childform i called prentform.activate() method.
The parent isn't always the owner.
There's an overloaded version of the .Show and .ShowDialog method that takes an Owner-handle. The OS will reset the focus to this "owner" if the window gets closed. Something like this;
new MyForm.Show(this); If all is well, then you should be able to remove the ParentForm.Activate(), just closing the child should be enough.
I are Troll
|
|
|
|
|
I have a Forms Application which I have just added the MothCalendar control too and I am ubale to change any of the properties, such as BackGroundColor, Size, etc.
I have tried using the designer and in code but the interface does not change!
Is there a trick to using this control?
Thanks
|
|
|
|
|
Probably because there is no control called as MothCalendar
On serious note, MonthCalendar cannot be modified while you are using Visual Styles for the control. You need to disable the visual styles and Month Calendar will respond to your modifications.
If you do not want to switch off visual styles for the complete application, extend the MonthCalendar class and then disable the visual styles for a that class. Then you can use this new control on your forms.
|
|
|
|
|
Okay call me dumb!!!! dahhh....
Thansk for the suggestion. I do have one other question for you... Where do I turn on/off "Visual Styles" for the MoNthCalendar? It is not in the controls properties where else should I be looking?
|
|
|
|
|
Squire Dude wrote: Okay call me dumb!!!! dahhh....
Its ok buddy... it just brought a good smile on both our faces. So fine.
There are two things that you can do.
1. As mentioned above, you can extend the class. Here is a class that does the job:
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace EZ
{
public class EZMonthCalendarControl : MonthCalendar
{
[DllImportAttribute("uxtheme.dll")]
private static extern int SetWindowTheme(IntPtr hWnd, string appname, string idlist);
protected override void OnHandleCreated(EventArgs e)
{
SetWindowTheme(this.Handle, "", "");
base.OnHandleCreated(e);
}
private void InitializeComponent()
{
this.SuspendLayout();
this.ResumeLayout(false);
}
}
}
2. You can disable the theme in the Main funtion in Program.cs. Just remove the line EnableVisualStyles(). But this will cause the visual style to be disabled for the whole of the application.
Cheers.
|
|
|
|
|
Thanks for the ideas and suggestion and code...
First I tried your second suggestion... turing off VisualStyles... and id does kind of mess things up on other forms. Then I looked at your code and it looed simple enough!
I have never put a wrapper around a class before as in you first suggestion. How do I apply the code?
|
|
|
|
|
Squire Dude wrote: How do I apply the code?
1. Add a new class into your project, replace content with the code i provided.
2. compile the project once
3. instead of dropping the month calendar. drop this new control on your form.
|
|
|
|
|
Now I am feeling really dumb!!!!
I got through parts 1 & 2 but how do I "Drop" the new control on the form?
I tried makeing a User Control & a Class with your code replacing the generic code. I ran Build... But if I try to drag & drop the file onto the form it will not stick.
What am I missing???
|
|
|
|
|
google: how to use custom user controls on c# forms.
this is the first link: click here
|
|
|
|
|
Thanks for the pointer. I could not get any of the links to work but did start reading the text further down the page... I am not sure how it realates to what I was asking? Maybe I am just having very dumb day as I could not see how it related what I am trying to accomplish. But thanks anyway for your time and assistance.
|
|
|
|
|
well, since you are creating your custom control within your project, it should be available in the toolbar at the very top. Above "All Windows Controls".
|
|
|
|
|
Okay my bad.... I had a big case of Brain Fade yesterday now I hope that it is behind me and I can move forward today.... so far so good!
I appologise for not getting it... You are correct of course the new Control is on the Left (Controls) pane and can be dragged onto a form etc.
Thank you for your patience and sticking with me I really do appreaciate the effort.
Thanks
SquireDude
|
|
|
|
|
Happens... Everyone has day like that
|
|
|
|
|
I have just tested the MothCalendar control after seeing your question.
I am able to change most of the properties (haven't checked them all) except for the Size, by normal means anyway, although BackColor and most others are OK. To overcome this size limitation I have found a work around:
1) Change the Font size. Not exactly precise but it works.
MonthCalendars' size is controlled because it would look really silly with an enormous control and all the data squashed up in one corner.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I have a simple list box that contains some string values. This list box is initially populated by binding to a collection (via DataSource field). However later user will be able to add some values into it also. When I just do a listbox.Items.Add(mystring), this new values never show up in the listbox itself. Any ideas what I am doing wrong? Or may be there are standard patterns for dealing with this type of situation?
|
|
|
|
|
When bindigng to a collenction, you have to add the
item to the collection not the listbox.Items.
Watch out for Exceptions!!!
listBox1.DataSource = yourListOrCollection;
listBox1.DataSource=null;
yourListOrCollection.Add("Something");
listBox.DataSource = yourListOrCollection;
|
|
|
|
|
Thanks for the reply. Problem is that my collection is actually an entity collection that is returning bunch of columns from table and I am just using one of the column to populate this listbox. I therefore not sure if I can add this item into the collection.
|
|
|
|