|
I have Form1 with the connection, dataadapter and dataset components.
On Form2 I want to use the dataset from the Form1. I want to have the possibility to use the visual designer when I configurate the DataGrid from the Form2.
What is the best way to do this? I tried to use a typed dataset but I don’t understand how to fill the dataset from the second form. Shell I use an additional set of connection and dataadpter componets? I think it has to be a better solution.
|
|
|
|
|
hi,
No need to create additional set of data adapater to pull the data which is already populated. What you can do is write a parametrised constructor which will accept a dataset as parameter. When ever your are trying to call the second form, try to call that parameterised constructor of that fom and pass your dataset which is in the first form.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I ran into a problem when handling drag and drop events. I'm dragging (copying) an item from a treeview to a listbox. The first drop works fine. After that I lose all DragOver events in my listbox!!!! Anyone have an idea?
Code:
private void commands_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
Point here = commands.PointToClient(new Point(e.X, e.Y));
string command = e.Data.GetData(DataFormats.Text).ToString();
int location = commands.IndexFromPoint(here.X, here.Y);
dragDropInProgress = false;
dataNeedsSaving = true;
commands.Items.Insert(location, FormatedOutput(command, here));
commands.SelectedIndex = -1;
commands.SelectionMode = SelectionMode.MultiExtended;
commands.SetSelected(location, true);
Trace.WriteLine("Dropped "+command, "NavImport");
e.Effect=DragDropEffects.Copy;
}
private void commands_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
Trace.WriteLine(e.Data.GetDataPresent(DataFormats.Text).ToString() + ":" + commands.Items.Count, "NavImport");
if (e.Data.GetDataPresent(DataFormats.Text) == false || commands.Items.Count == 0)
{
e.Effect = DragDropEffects.None;
return;
}
e.Effect = DragDropEffects.Copy;
dragDropInProgress = true;
Point location = commands.PointToClient(new Point(e.X, e.Y));
commands.SelectedIndex = -1;
commands.SelectedIndex = commands.IndexFromPoint(location);
}
private void objectView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
Point here = new Point(e.X, e.Y);
TreeNode drag = objectView.GetNodeAt(here);
if (drag.Text.StartsWith(ParentNodeName))
return;
string command = "<" + drag.Parent.Text + ":" + drag.Text;
objectView.DoDragDrop(command, DragDropEffects.Copy);
Trace.WriteLine("Dragging "+command, "NavImport");
commands.SelectedIndex = -1;
commands.SelectionMode = SelectionMode.One;
Trace.WriteLine("Current control state :"+commands.AllowDrop.ToString(), "NavImport");
}
This signature left intentionally blank
|
|
|
|
|
I found the problem!!!!!
theRealCondor wrote:
commands.SetSelected(location, true);
This seems to put the control off the deep end. Once I changed this to just work with SelectedIndex all worked well, drag and drop functioned very well, and the control never 'winked out' or stopped responding to drag events.
This signature left intentionally blank
|
|
|
|
|
The form I am dealing with pops up in the middle of the application only half time time. The other half the time it goes into the upper-left corner.
If I set a break point inside the form to check what the parent is - it's always null.
But it's null for all the forms in our app, yet this is the only form that is acting funky.
I was wondering if anyone else ran into problems with setting StartPosition to CenterParent.
Thanks,
Elena
|
|
|
|
|
I have seen this. However I have not taken the time to determine what I'm doing when it works and what I'm doing when it does not work. (ie. form.Show() vs. form.ShowDialog())
This signature left intentionally blank
|
|
|
|
|
elena12345 wrote:
I was wondering if anyone else ran into problems with setting StartPosition to CenterParent
You need to make sure your child form instance sets the it's Parent property before you display your form, that is assuming you are setting you StartPosition to CenterParent . If you don't have a parent, just set the StartPosition to CenterScreen to get the form centered on the screen.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Exactly. If you set the CenterParent property before the parent is known, it will have no effect.
For instance If you set the CenterParent in the designer, it will be set when the constructor calls the designer generated code, at which point the parent is still unknown. The way to go here is either:
Create a constructor that takes the parent form as a parameter, and then set the Parent property before calling the designer generated code
Or:
When you create the child form in the parent form, first set the Parent Property, then the StartPosition property and then call the Show(Dialog) method.
|
|
|
|
|
Hie,
I found this syntax error.
If (Persist.Checked = (true)) {
setPasswordCookies(UserPass.Text, UserEmail.Text);
}
What is the issue?
Thanks.
|
|
|
|
|
|
One = sign is assignment while two == is equality. You can just say the following if you want:
if(Persist.Checked)
{
setPasswordCookies(UserPass.Text, UserEmail.Text);
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
What type of connection does the SqlClient use? Like ado or ole db or something??
/\ |_ E X E GG
|
|
|
|
|
ADO and OLEDB are not connection types. SQL Client uses a direct network connection to the SQL Server and communicates using a proprietary optimized dialect.
ADO and OLEDB are programming interfaces that abstract the database and expose a consitent, generalized API that works on any database with an ADO or OLEDB data provider.
What are you looking into? Why the question?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Somebody asked me the question about if I was using ado or ole db in my C# program. I had no clue....
/\ |_ E X E GG
|
|
|
|
|
I have a dataview with two fields I want to sort by. One is a Text field and the other is a date field. ie:
Status(Text), DateSubmitted
Active , 6/8/2004
Closed , 6/8/2004
Active , 6/9/2004
Active , 6/23/2004
I've used the following code to sort it:
dv = ds;
dv.sort = "Status ASC, DateSubmitted DESC";
so my problem is that same ol' problem where the Date field is being sorted as a text field so that the active items would get sorted by date in the following Desc order:
6/9/2004
6/8/2004
6/23/2004
Obviously I need to get the 6/23/2004 up to the top of the list. How do I do this?
|
|
|
|
|
Adam Wimsatt wrote:
so my problem is that same ol' problem where the Date field is being sorted as a text field so that the active items would get sorted by date in the following Desc order:
Just a quick question, what is the data type of your DataSubmitted field in the database?
- Nick Parker My Blog | My Articles
|
|
|
|
|
It's coming from an xml file that is loaded into a DataSet. So I guess its starting datatype is String. Is there someway to define the datatype in the DataSet or DataView?
|
|
|
|
|
Adam Wimsatt wrote:
Is there someway to define the datatype in the DataSet or DataView?
You should be working with Typed DataSet, this will allow you to use the XML Schema Date type. This[^] will provide some background information in using Typed DataSets. This[^] shows the relationship between XML Schema (XSD) Types and .NET Framework Types. Another useful link is this[^] explain the process to create a Typed DataSet.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thanks Nick! Yet again you have come through with a good solid solution.
|
|
|
|
|
How can I detect whether the account of a user is enabled/disabled using Active Directory?
The user can be of any Win Server i.e. Win2K/WinXP/Win2K3
I am able to retrieve the other properties using Active Directory.
I need to enumerate thru all the users present on the server ..... and hence I don't know their passwords and hence cannot check whether their account is enabled/disabled by authenticating using the username and the password.
Any suggestion/comment is welcomed ...............
|
|
|
|
|
Suvadip De wrote:
How can I detect whether the account of a user is enabled/disabled using Active Directory?
Have you looked at the DirectoryEntry [^] class? There are serveral articles on CP and MSDN that cover this material.
- Nick Parker My Blog | My Articles
|
|
|
|
|
This 'flag' is actually part of a MS defined enumeration that is the value of the userAccountControl attribute. More documentation is available at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-s/adschema/adschema/a_useraccountcontrol.asp
Try this and see if it helps.
- Bruce
BRCKCC
|
|
|
|
|
You might try replying to Suvadip so he gets the reply, it only went to me.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Nick Parker wrote:
Have you looked at the DirectoryEntry [^] class?
Nick,
I am using the Directory Entry class to get the usernames and their details on the Active Directory and also to authenticate a user for their login. But among the property lists their isn't any option for checking whether the user's account has been disabled or enabled. Though when trying to authenticate the user provided username and password, even if correct username and password is given and if the account is disabled, I am getting error and hence authentication is failing. But thats only possible if I know both the username and password. But here, I only know the domain path, and enumerating that I am able to get the usernames only and not the passwords. So, I think, I need to get the enabled/disabled property of an user account in some different way, which I suppose is possible.
And to add to that, the link provided by Bruce does not exist anymore ....
Suvadip.
|
|
|
|
|
This 'flag' is actually part of a MS defined enumeration that is the value of the userAccountControl attribute. More documentation is available at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-s/adschema/adschema/a_useraccountcontrol.asp
Try this and see if it helps.
- Bruce
BRCKCC
|
|
|
|