|
Set the new Form's TopLevel property to false before you make it Visible or Show() it.
|
|
|
|
|
Thanks! That worked.
However, the window is created with the WS_CHILD style, which makes it be "inside" the main window. This I do not want. How can I make it not use the WS_CHILD style, but still have the main window as its parent? I don't see any place to specify the window styles manually...
|
|
|
|
|
Hmm, also try
TopMost = true;
in addition to
TopLevel = false;
|
|
|
|
|
Hello,
I'm experiencing a problem with DataSets. If I use a DataSet as a parameter of a method in a Serviced Component, I always receive an InvalidCastException because something is trying to convert __ComObject to DataSet. When a method only returns a DataSet (no DataSet as parameter) there's no problem.
I'm running my application with framework 1.1, the serviced component is in Server mode.
Is this some bug in the .Net framework? Has anyone a solution or a workaround for this problem?
best regards,
Pieter
|
|
|
|
|
I don't know the answer but does the dataset serialize. You might have to implement the serializable interface. or just shoot it as an xml stream through. Com passes it as a stream anyhow.
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Thanks for replying. I'm not sure if a dataset is serializable, I'll check it out.
Running the component in Library mode doesn't have this problem, although there's a problem with my database connection. But that's some security issue I think.
|
|
|
|
|
it might be easier to parse it as xml "WriteXML() method" then send it through
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
I think that the dataset-to-xml and xml-to-dataset coversion will cause a significant performance drop.
|
|
|
|
|
I ran into this problem working with C# based queued components.
Datasets are serializable, they support ISerializable however alot of things with COM+ (especially with Queued Components) is that they need the components to support IPersist.
They have no idea how to serialize using the ISerializable interface therefore you either go the route of dataset--> XML, XML--> dataset or implement IPersist within your component.
|
|
|
|
|
Jarrod,
Thanks, I'll take a look at how to implement the IPersist interface.
Pieter
|
|
|
|
|
Well its relatively fast and uses a buffered stream. I mean really when your marshalling your Dataset you serialize the object to text then back again. And its basically the same thing. WriteXML is the fastest firehose method of the class. But yeah it would be better to do a dataset. You might try createing an object, clone the dataset to that object then marshalling it over the boundary. That might work. Or use the serializable attribute above a custom class that inherits the dataset.
Personally, With DataSets I use reflection to populate classes then update them with COM+ life cycles. Much more elegant and easier to load balance. That and business rules on forms and behind the scenes are simple to implement.
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Nick,
Thanks for your input! I'm really new to Serviced Components and COM+. Can you explain your way of working a bit more? I don't understand what you mean with:
Ista wrote:
With DataSets I use reflection to populate classes then update them with COM+ life cycles
Yeah, I know what reflection is, but the combination with datasets and populate classes is unclear to me.
Pieter
|
|
|
|
|
Well simply put I create a class
LastName
FirstName
SSN
if table looks like
EmployeeID
LastName
FirstName
SocialSecurityNumber
then my select would look like:
SELECT EmployeeID = ID, LastName, FirstName, SSN = SocialSecurityNumber
then I would use a DataReader becuase its much faster
For each row I would create the class based on the primaryID ( EmployeeID )
Then I would iterate through the GetValues array returned by the datareader
using reflection I use the PropertyType and propertyInfo classes to populate the fields. I haven't taken on the method part but thats next month on my development cycle
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
hi,
i used the serial port class in msdn to do serial communication in C#.
in the receiver thread, i try to send notice message to richtext box create in another thread. sometimes, i will got NullReferenceException. it come mainly i switch windows or do other time consumption task in windows.
i think it related to using diff. thread to access GUI resource.
do you think so? and, any method to do inter-threading commu. in C#? just raise some keywords for me to search is enough.
thanks,
jim
|
|
|
|
|
zecodela wrote:
i think it related to using diff. thread to access GUI resource
You think correctly - you must only access form controls from the originating thread. Here's the keyword thast will solve all your problems: Invoke
There's a couple of articles here on CP that deal with multi-threading issues in Windows Forms - both are useful, especially the one by James T Johnson, look them up.
|
|
|
|
|
Dear members,
I'm making a listview that allows user to drag (row)items to different index recently. However, I can't find a good example for doing that.
Does anyone knows how to use drag-drop event on ListView? Or anyone knows where has good example?
In my ListView, suppose each item has 6 subitems, when I drag an item (e.g.) index 5 to index 1, then all data of item 5 are inserted into row 1.
I know this is not hard, and many of our members knows that. Please teach me
Please help me..... Thanks a lot~
I've tried to make the code, but it looks a bit strange.
e.g. I have items 1,2,3,....10.
if I selected 2,4,5,6 and drag to the position of item 3. Suppose, item 2,4,5,6 will move under item3 .. like 1,3,2,4,5,6...
but how can I prevent some selected items not to do anything if I move to there position? e.g. 4,5,6,7 are selected, if I move to 5 or 6, the program won't do anything.
Could you help me to see how to implement this code? Or do you know what is the best way to do this?
Here is the codes inside my listview drag drop function:
<br />
if(OList.SelectedItems.Count==0)<br />
return;<br />
Point cp = OList.PointToClient(new Point(e.X, e.Y));<br />
ListViewItem ToItem = OList.GetItemAt(cp.X, cp.Y); <br />
<br />
if(ToItem==null)<br />
return;<br />
<br />
int num = ODS_List.SelectedItems.Count;<br />
int locationIndex = ToItem.Index-1;<br />
for(int i=0; i { <br />
ListViewItem dragItem = OList.SelectedItems[i];<br />
if(locationIndex!=dragItem.Index) <br />
return;<br />
<br />
ListViewItem insertItem = (ListViewItem)dragItem.Clone();<br />
OList.Items.Insert(locationIndex, insertItem);<br />
locationIndex++;<br />
}<br />
<br />
foreach(ListViewItem olditem in OList.SelectedItems)<br />
{<br />
OList.Items.Remove(olditem); <br />
}<br />
Thank you very very much.
|
|
|
|
|
Hi,
Do a search for something like "ListView" and "Drag Drop" from this forum, there is a chance that you will find some examples. Here is one:
http://www.codeproject.com/cs/miscctrl/dragdroplistviewreorder1.asp?target=listview%7Cdrag%7Cdrop
Hope you get more tips
Khang
|
|
|
|
|
I have an ArrayList bound to a datagrid. I've developed a method of validating the data entered in the TextBoxes, and forcing the user to re-enter invalid data. Unfortunately, I use the CurrentCellChanged event to test if it's necessary to move the selection back to the cell with the invalid data in it. It works fine with one exception. If you're at the end of a row of data, and press the TAB key (return is fine), you get an extra CurrentCellChanged event. The first one takes you to the beginning of the same row, and the next one takes you to the next row! This messes with my logic that determines if it's necessary to move the selection back to the cell with the error in it.
Is there some way to inhibit the handling of the TAB key once you've determined that you want to select another cell?
|
|
|
|
|
Yeah but you gotta override the PreviewKeyMessage function. Also you need to creat a custom table style
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
i want to make an oledbCommand with a variable as in sql @variable..SELECT *Table From Table WHERE Column=(thatvariable),how can i declare this to use in my code, am using Microsoft Access
|
|
|
|
|
OleDbConnection oleConn = new OleDbConnection(<myconnectionstring>);
oleCOnn.Open();
OleDbDataAdpater oleAdapter = new OleDbDataAdapter("my select statemnent", oleConn);
DataSet ds = new DataSet("Access");
oleAdapter.Fill(ds, "MyTable");
now I would check the parameters because its been 2 weeks since I connected but it should work fine
ohh yeah to test
DataGrid1.DataSource = ds.Tables["MyTable"];
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
thx Ista for replying , but that wasnt my question i was just asking about how to declare an oledb parameter as in SELECT *Table From Table WHERE Column=(parameter),as declared in sql we use "@" b4 the parameter i was just asking wat i ll declare in ole instead of that "@".
|
|
|
|
|
doh
its just like the sql
myOleCommand.Parameters.Add("@Param1", OleDbType.SmallInt);
refer to it as
myOleCommand.Parameters["@Param1"].Value = 1;
i use a short way when assigning many
OleDbParameterCollection olePar = myOldCommand.Parameters;
olePar.Parameters.Add("@Param2", OleDbType.VarChar, 10);
olePar["@Param2"].Value = "Hey dude";
I think that answers it. Sorry for the confusion.
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
thx Ista really for replying again
but i still ve the problem!
this is my debug error :
@PostionIndex error: managed EE does not understand expression's syntax
the code :
OleDbCommand cmd = new OleDbCommand("SELECT * FROM Phones WHERE Contact = @PostionIndex");
cmd.Parameters.Add("@PostionIndex", OleDbType.SmallInt);
cmd.Parameters["@PostionIndex"].Value = int.Parse(this.editID.Text);
|
|
|
|
|
change it for a question mark
check this link out
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataOleDbOleDbCommandClassParametersTopic.asp
and for info and parameter arrays
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoledboledbparameterclasstopic.asp
its like OleDbParameter[] oleParam;
but I would just stack them on. like in your code, just replace the parameters with ? and make sure you add them in order.
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|