|
How can I select a part of an image and copy/paste it? Something like Paint and other image editors do.
Mazy
No sig. available now.
|
|
|
|
|
Mazdak wrote:
How can I select a part of an image and copy/paste it? Something like Paint and other image editors do.
Mazy, take a look at Nish's article: Clipboard handling with .NET[^]. He discusses how to do this with the Clipboard.SetDataObject() and Clipboard.GetDataObject() methods.
-Nick Parker
|
|
|
|
|
My message didn't show up on this board because of a bug or something so I'm posting again:
If you put a WebBrowser control in a Form, and then put that Form inside another Form (set it's Parent to the other form and set TopLevel to false, which is perfectly legal according to the docs), then when you quit your application (close the outer Form), it will stay resident in memory and eat up 100% of CPU time. (You can see it doing this in the Task Manager). This is probably caused by that OLEinPlace stuff somehow but I don't know OLE so that's totally a guess.
This is a HUGE problem for me!!
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
nevermind.
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Sounds like something that should be simple enough, but I can't find anything on the topic. I have noticed a few references, but they're not encouraging... Words to the effect that it can't be done.
Thanks.
|
|
|
|
|
If you want to set them at design time, use the properties of the data grid...
Click on the data Grid; in the Properties panel, you should find a row for "TableStyles" with value "(Collection)" and a "..." button. Click on that, and you access the dialog through which you can set up the table style...
you can add a new table style (or modify one that you already have), and in the right-hand side of this dialog you should find the Misc > GridColumnStyles property (with value "(Collection)" and the "..." button). Click on the "..." button to access the dialog to set up the column styles for the given table style.
You can add a new column style or modify a pre-existing one.
Each such column style has a HeaderText property you can set as needed.
If you wish to do all this at run-time, I suggest doing it once at design time and taking a look at the code generated by the Studio for you...
HTH,
FOR
|
|
|
|
|
I don't have a problem with column headers, and I am creating them at run-time.
I can't figure out how to label the rows!
|
|
|
|
|
[quote]
I don't have a problem with column headers, and I am creating them at run-time.
[/quote]
Ooops ! My bad... sorry.
I don't know if/how you could set the row headers...
ALl I can think of is the RowHeaderWidth property of the data grid to set the width,
and the RowHeaderVisible property of the TableStyles to determine whether they are visible or not,
but I've never seen a place where you can set a row header label (or such...)...
I wouldn't be surprised if this is not allowed, since the DataGrid uses the row header (if they are
visible) to place the + symbol for a record leading to child records in another table...
Wish I could be more helpfull,
FOR
|
|
|
|
|
Thanks... I'm new to C#, and the datagrid control. I may have selected the wrong control for the task. I was looking for the following functionality...
Row and column labels (datagrid has column labels, but not row labels)
User editable fields within the table (datagrid supports this)
bi-directional linkage to a datasource (datagrid supports this)
cut and paste cells between tables (don't think so)
The datagrid looked like a good choice, but I keep running into hurdles as if it was really meant for another application.
|
|
|
|
|
From what you describe, I would use the DataGrid.
As far as the row headers...
..depending on why/how you need them, it may be that you could use
the first column as "row header"... it's a work-around, and
it might not suite your application, but that's all I can suggest right now...
..after all the dataGrid seems to fit all of your other requirements, except for the
"cut-n-paste" across tables (hmmm... sounds like fun!).
Is the data grid's data source going to link you to a DB?
Are you looking for row headers because you know that you will always
display a given number of rows, and that each row represents something
specific? (in this case you might use simple labels, and separate
text controls to display the data instead of the data grid..)
FOR
|
|
|
|
|
I was considering using the first row as the label, and I might end up doing that if all else fails. Right now I'm taking another look at the ListView control, but I'm starting the learning curve all over again! I want to learn C#, but it's becoming difficult to resist the temptation to jump back to C++.
Thanks again for your time.
|
|
|
|
|
Use the ItemCreated event to add whatever text you want to the datagrid row.
|
|
|
|
|
Sounds interesting, but I don't see the ItemCreated Event in the datagrid class... Like I said earlier, I'm new to C# and the property soup for the various controls. I'm probably missing something obvious!
|
|
|
|
|
I have a fileSystemWatcher object to watch for file changes under some directory and display a message for each file change. However, enven though I change the file only once, the message get displayed twice. The file is a .txt file. Anybody knows why this happens and how to fix it?
Thanks a lot
|
|
|
|
|
Greetings,
I have created a custom collection class that I would like to return from a function (i.e. return customcollection;). However, a runtime error is generated when I call the function that's suppose to return the custom collection class. The error states that I should be returning the object type that's contained in the custom collection. (i.e. if my custom collection holds customer objects, then I should be returning a customer object, not the customcollection object.) The problem is that I need the collection returned with all the customer objects that it contains. (I want to bind this collection to a datagrid) Can anyone help me out with this. I know it's something simple that I'm missing.
Thanks in advance,
Andrew
|
|
|
|
|
[quote]
The error states that I should be returning the object type that's contained in the custom collection
[/quote]
My $0.02:
Sounds to me like a case of mis-match between the function signature and the function code.
What is your function's signature?
For instance, if it is
public myObject myFunction()
You should return an object of type myObject, but if it is
public myCollection myFunction()
you should be able to return an object of type myCollection, and I don't think anyone
-let alone the compiler- would look at what the myCollection object is holding...
Maybe you could post a snipplet?
HTH,
Frank
|
|
|
|
|
Frank,
It looks like I'm on the right track, this is basically what I've got:
public IndividualCustomerCollection findCustomer()
{
IndividualCustomerCollection search_results = new IndividualCustomerCollection();
search_results.Add(new IndividualCustomer("John", "Smith", "(905) 428-1122"));
return search_results;
}
Your help is much appreciated,
Andrew
|
|
|
|
|
hmmm...
...so, search_result is an instance of the IndividualCustomerCollection class...
which looks right...
So, what exactly is the error message you get?
..is it a compile-time error or run-time error?
...also, does the erro rpoint you to a line in that snipplet,
or does it point you to the line where you are calling this function?
FOR
|
|
|
|
|
The program compiles successfully, I get the run-time error when I try to call this function. The error points to the calling function. Here's a bigger snippet:
The following code is located in the cmdSearch_click event handler of the Customer Search Form:
If customer_type = "Individual" Then
Dim search_results As IndividualCustomerCollection = CustomerFacade.processCustomerSearch(customer_type)
lstViewResults.DataSource = search_results
End If
The following code is located on the client, within the business facade layer:
public static IndividualCustomerCollection processCustomerSearch(string customer_type)
{
IndividualCustomerCollection search_results;
string _customer_type = customer_type;
ICustomerFactory CustomerFactory = (ICustomerFactory) Activator.GetObject(typeof (ICustomerFactory, "http://localhost:1234/customerfactory.soap");
//This is where the runtime error occurs
search_results = CustomerFactory.findCustomer(customer_type);
return search_results;
}
The following code is located on the server, within the business rules layer:
public IndividualCustomerCollection findCustomer(string customer_type_
{
string _customer_type;
_customer_type = customer_type;
IndividualCustomerCollection search_results = new IndividualCustomerCollection();
search_results.Add(new IndividualCustomer("John", "Smith", "(905) 428-1122"));
return search_results;
}
NOTE: .NET Remoting is used to pass the collection from the server to the client. I know the remoting works because I've got debug messages that output the status of the server-side code execution. (For example, a message is displayed on the console window when an IndividualCustomer is added to the collection.
I'm truly stumped on this one, and it's something that should be so simple to do. I must be missing something, but what???
Your help is appreciated.
Andrew
|
|
|
|
|
Andrew,
I have no experience of .NET remoting, nor actually of mizing languages...
At first sight I don't spot any red flag...
If the run-time error points to the line
search_results = CustomerFactory.findCustomer(customer_type);
in processCustomerSearch, and has to deal with the data types involved, I would try
and step through the code, to see exactly where the problem arises...
For instance, if you use the debugger and step into the call to findCustomer,
when you reach the last statement in that function (return search_result; ) is
everything in order?
If so, when you execute that last statement, and return control to processCustomerSearch, is everything still in order?
I would add a dummy statement between
ICustomerFactory CustomerFactory = (ICustomerFactory) Activator.GetObject(typeof (ICustomerFactory, "http://localhost:1234/customerfactory.soap");
and
search_results = CustomerFactory.findCustomer(customer_type);
and another one between
search_results = CustomerFactory.findCustomer(customer_type);
and
return search_results;
to set up a break point and check if everything is as it should...
I wish I could point you to the problem, but I don't see what could be the issue...
...if you want, post the error message, which might provide some hints...
but if I were in you, I'd be playing with the debugger over and over to see exactly *where* something goes out of synch... (for instance, does the call to Activator.GetObject in processCustomerSearch act as expected?)
As I said, I haven't played with this kind of stuff, so I might be a poor help on this one (sorry
FOR
|
|
|
|
|
Frank,
Thanks for the debugging suggestions. I haven't tried that yet. I'll let you know when I discover the solution to this issue. I really appreciate you taking the time to help me solve this problem.
Thanks again,
Andrew
|
|
|
|
|
No problem...
..let us know what you find out stepping through the code !
I must admit I am curious...
Frank
|
|
|
|
|
Frank,
I finally solved the problem. The issue was with the following code located in the IndividualCustomerCollection:
#region CollectionBase Overridable Properties
/*Implementation of CollectionBase Property
*Performs additional custom processes before
*inserting a new element into the CollectionBase instance.*/
protected override void OnInsert(int index, Object value)
{
if (value.GetType() != Type.GetType("IndividualCustomer"))
{
throw new ArgumentException("value must be of type IndividualCustomer.", "value");
}
}
/*Implementation of CollectionBase Property
*Performs additional custom processes when
*removing an element from the CollectionBase instance.*/
protected override void OnRemove(int index, Object value)
{
if (value.GetType() != Type.GetType("IndividualCustomer"))
{
throw new ArgumentException("value must be of type IndividualCustomer.", "value");
}
}
/*Implementation of CollectionBase Property
*Performs additional custom processes before
*setting a value in the CollectionBase instance.*/
protected override void OnSet(int index, Object oldValue, Object newValue)
{
if (newValue.GetType() != Type.GetType("IndividualCustomer"))
{
throw new ArgumentException("newValue must be of type IndividualCustomer.", "newValue");
}
}
/*Implementation of CollectionBase Property
*Performs additional custom processes when
*validating a value.*/
protected override void OnValidate(Object value)
{
if (value.GetType() != Type.GetType("IndividualCustomer"))
{
throw new ArgumentException("value must be of type IndividualCustomer.", "value");
}
}
#endregion
I found the error by implementing a try, catch block. I caught the error and displayed the details in a messagebox. The details pointed me directly to the problem.
I'm guessing that I should change Object to IndividualCustomer in all the above method signatures, does this sound correct?
Thanks for steering me in the right direction,
Andrew
|
|
|
|
|
RS2003 wrote:
I found the error by implementing a try, catch block. I caught the error and displayed the details in a messagebox. The details pointed me directly to the problem.
I'm guessing that I should change Object to IndividualCustomer in all the above method signatures, does this sound correct?
Andrew,
glad to hear you found the problem !
As far as using try and catches, my personal experience is that they are a *great tool*, especially during development. While coding (especially in .NET since I rely upon so many .NET classes), I found that my instinct is now to "first of all wrap everything that might throw an exception in a try/catch", and moreover, I try to have a different catch for every different thing that might throw an exception (so that I can quickly find out where the problem is). This might sound an overkill, but a) the VisualStudio documentation (with the Dynamic help) helps a lot in checking what exception (if any) might be thrown by the various .NET classes, and b) I admit I am not that throughfull... There are cases where I know I will never hit a specific error condition because of the way my code is structured, so in some cases I skip the try/catch...
In any case,
as far as changing Object to IndividualCustomer, it sounds like a good idea, especially if this collection should and will always contain only IndividualCustomer objects.
Hope you'll solve this out now,
Frank
|
|
|
|
|
OK, I've got it now. The method below validates the new object by getting its type and making sure its of type IndividualCustomer. The runtime error I was seeing in the beginning (the cause of this whole thread) was the error message contained in the exception arguments (throw new ArgumentException("value must be of type IndividualCustomer.", "value");". According to Microsoft this method is used to:
"OnValidate can be used to impose restrictions on the type of objects that are accepted into the collection. The default implementation prevents a null reference (Nothing) from being added to or removed from the underlying System.Collections.ArrayList."
The question is why is the value null after I perform the IndividualCustomerCollection.Add function?? When I remove the code, the IndividualCustomer is added to the constructor without any problems. According to Microsoft :
"The On* methods are invoked only on the instance returned by the List property, but not on the instance returned by the InnerList property."
**Definition**
The CollectionBase.List Property - Gets an IList containing the list of elements (objects) in the CollectionBase instance.
By this definition, the onValidate method should execute after the the List property returns the list of objects in my instance of the IndividualCustomerCollection. I don't recall overriding the CollectionBase.List property in my IndividualCustomerCollection class. I'll have to check this when I get home and make the appropriate changes.
/*Implementation of CollectionBase Property
*Performs additional custom processes when
*validating a value.*/
protected override void OnValidate(Object value)
{
if (value.GetType() != Type.GetType("IndividualCustomer"))
{
throw new ArgumentException("value must be of type IndividualCustomer.", "value");
}
}
You'll have to excuse me, I'm knew to creating data binding collections and I want to make sure I understand this inside and out. It's nice to use examples from MSDN, but if you don't take the time to understand everything your implementing you'll run into these kinds of problems. I have definitely learned my lesson Does anyone have any suggestions as to why my value is null?
Thanks,
Andrew
|
|
|
|
|