|
Reminds me of the Kip Addotta song, Wet Dream:
...but she said things I just couldn't fathom. She was too deep. Seemed to be under a lot of pressure... I said "let's get tanked." She said "Not tonight, I got a haddock." And she wasn't kidding either, beacuse in came the biggest meanest looking haddock I'd ever seen come down the pike. He was covered with mussels. He came over to me, he said "listen shrimp, don't you come trollin' around here." What a crab. This guy was steamed...
Matt Gerrans
|
|
|
|
|
I tried to set the label control property "visble" to true on a form. This i did from networkoperation.cs class which contains a field referring to form object in Form1.cs .
I called a function Matrixdisplay of form
as form.Matrixdisplay(row,col);
This function contains
public void Matrixdisplay(int row,int col)
{
for (i=0;i
|
|
|
|
|
Is the method Matrixdisplay executed in the same thread that created the label controls?
|
|
|
|
|
There are two classes. One is networkoperation.cs and Form1.cs
Networkoperation.cs class contains a reference variable form to Form1 class in Form1.cs
I am calling the function of Form1.cs Matrixdisplay() from one of the thread of networkoperation.cs class. like this
form.Matrixdisplay();
In this function i implemented the visibility setting code.
|
|
|
|
|
try this instead of 'form.Matrixdisplay();':
delegate void displayMethod();
form.Invoke(new displayMethod(form.Matrixdisplay),null);
When interacting with controls from a thread that is not the 'owner' of the controls (thread where they have been created) you ALWAYS have to use the Invoke method.
If in some cases you are not really sure if u need to invoke, u can always check the InvokeRequired property of the control (in this case form).
P.D: this might not be the issue at all, but without more details of your code, its the best shot I can think of.
|
|
|
|
|
Could anyone tell me how can I set the values in my list? or there are better way to do this?
public class MyList
{
private string first;
private string second;
public string[] GetArray()
{
return new string[]{first, second };
}
public string[] SetArray()
{
How to do here?
}
}
|
|
|
|
|
The code below assumes u only need two strings in the array.
If u need a string array, then u can use StringCollection in System.Collections.Specialized
First u need to declare a string[] attribute.
Then put an index in the SetMethod:
public class MyList
{
private string first;
private string second;
private string[] arr = new string[2];
//constructor
public MyList(string first, string second)
{
this.first = first;
this.second = second;
arr[0]=first;
arr[1]=second;
}
public string[] GetArray()
{
return arr;
}
public string[] SetArray(int index, string value)
{
arr[index] = value;
}
}
Hope it helps;)
|
|
|
|
|
|
I want to load data from a file into a RichTextBox Windows control. While loading itself, if the file data is larger than the text box height, I don't want scroll bars to apper, but the text should be autofit in the textbox. (Even if the text in such small size is not readable).
How to Achive this?
Any workarounds please?
Hi ! I'm Av. Happy to be a member of Code Project. Your Views are aprreciated
|
|
|
|
|
Hi, I myself is posting the reply. Try this. I hope it works. Please give suggetions if there are any changes in this code or any other workarounds
// To autofit text in a richtextbox while loading from a file.
Assume that already the file is loaded into the RichTextBox. But before the user can view the textbox,the following should take place.
// Find the Last character of the text in the textbox
string lastchr=txtRich.Text.Substring(txtRich.Text.Length-2,1);
// Find the Last index of it
int lstind=txtRich.Text.LastIndexOf(lastchr);
// Get the Position of the last character ( X and Y Coordinates)
System.Drawing.Point p=txtRich.GetPositionFromCharIndex(lstind);
// Check whether the height of the textbox is less than the y coordinate
// of the last character. If yes, it means Text overflows the textbox.
// So, Reduce the ZoomFactor by 0.01 and check again whether text overflows.
// Repeat this process until text fits in the textbox.
while(txtRich.Height
|
|
|
|
|
hi there,
I have a collection of record in a data table which is populated from a dataset.
I would like to replace some field values in that data table. This replacement is
temporary (I am not going to update it back to database or dataset).
Eg:
EmpID EmpName
1101 My Name
1102 Your Name
What I need to do is, I need to replace all "Emp ID" values to it's corresponding encrypted value.
Answer will be
EmpID EmpName
xabc My Name
ssbc Your Name
Now I am iterating through individual records of my data table and updating with my required value. The iteration took little more time, when I deal with lot of records.
Is there any better way to achieve my result.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Iteration is slow because many lookups are required (especially when you refer to a DataTable or DataRow by its string name, like dataSet1.Tables["Supplies"].Rows[0]["supplier_id"] . Either use enumeration or use a single look-up to get the right DataTable and then use that over and over again. For rows, get the current DataRow once and use that variable over and over for a single iteration (this is always a good idea for anything, anyway*). For rows, however, you'll gain more by using enumeration.
If you need faster speeds than that, then use a database. A DataSet is a poor, poor replacement for a database and is far too often used in lieu of a database.
* Other non-DataSet related bad examples I see are something like this:
foreach (SomeObject so in myObjectCollection)
{
so.Property1.Property1 = "asdf";
so.Property1.Property2 = 1234;
so.Property1.Property3 = someRef;
} Property1 would return an object, so assign that to a local variable and reuse it. That will use far less instructions when you compile and, since it's a reference (if it were a reference, and not a value type) will use no additional memory beyond space for the pointer (32- or 64-bits - hardly measureable)
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I want in my application ie a desktop application to open up an html file from a site specified and get the properties of the form fields on it. Actually the application has to read in the data from the computer in to the appropriate fields in the web page and submit each record one at a time. Is that possible?
|
|
|
|
|
Embed the WebBrowser control (the browsing control that is actually Internet Explorer) in a Form . You can do this by customing your toolbox in VS.NET (where you find all the controls and components) and clicking the COM tab. Find the Microsoft WebBrowser Control and add it. Drag that to a form and two interop assemblies are created - one for the ActiveX control and one for the type library (describes COM types). Then right-click on your Project, select Add References, and find the Microsoft.mshtml.dll assembly that should be installed with VS.NET.
Now in your code cast the AxWebBrowser.Document property to IHTMLDocument2 (be sure to add using Microsoft.mshtml to your source code plus any other namespaces you need, otherwise you'll need to fully-qualify every Type name). From there it's just a matter of walking the Document Object Model (DOM). If you have any experience with DHTML that should be easy. If not, go to the Web Development[^] forum.
There's lots of examples on this site, too. Use the search bar under the logo at the top of the page and try searching for "WebBrowser", for example.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi there, I'm using the FileSystemWatcher class to catch the events when the files I have at a certain directory changes.
In my case, the files in this directory is changed by replacing the files with a new one. The problem I have is that the events of the FileSystemWatcher class triggers even before the copying/replacing process finishes. How can I prevent this from happening?
Thanks,
Rafferty
|
|
|
|
|
You can't change when the events fire. What you can do is try and open the file that your working with as exclusive, FileShare.None. If the file is already open by another process, such as in your case the file is still being written, the open attempt will fail until the copy process closes the file. You must repeatedly try and open the file until it works. When that happens, you'll know that the file copy is done and you can then do whatever your want with it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi! I´ve been trying to use a flash animation in my windows forms application. So far I have managed to show the animation and play it, but I can't find a way to know when the animation finishes. I have looked everywhere but it seems that there is no "OnStop" or "OnFinish" event. Can anyone help me? I would really appreciate it.
Thanks in advance,
Matias
|
|
|
|
|
Your question actually has nothing to do with C# or even .NET. When you include an ActiveX control on your Windows Forms the VS.NET designer actually creates two interoperability assemblies - one for the ActiveX control(s) and one for their type library (typelib). Whatever interfaces, coclasses, enums, etc. that are exposed to automation get exposed to .NET through an RCW, or Runtime Callable Wrapper.
Basically what I'm saying is that what is exposed to managed code is what is defined for the object. In this case, that object is the Flash player. You'd be better off looking in the developer documentation for Flash or asking in a Flash developer forum. You may find some at http://www.macromedia.com/flash[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
No event of the sort you are looking for is raised by the flash player itself, your best bet is to use an fscommand on the final frame to communicate back to the container (your form) when the animation is complete.
|
|
|
|
|
Hello,
i have 2 tables "products" and "suppliers"
the table products and suppliers has the following columns:
Table "products":
product_id, name, price, product_code, supplier (id of the table suppliers column supplier_id)
data:
product_id name price product_code supplier
151432 Summer Tire 56,33 tire00111 3
151476 Winter Tire 31,63 tire00421 4
Table "suppliers"
supplier_id, name
data:
supplier_id name
3 Michelin
4 Bridgestone
Well my problem is how do i solve this problem: Products is the main table when insert a new product from a new supplier, i need first insert the new supplier into the table suppliers after that i need to retrieve the id from the new supplier for the insertion of the new product in the products table. Can somebody give me a example for this?
thanx!
greetings
Sander
|
|
|
|
|
Use DataTable.NewRow on your Suppliers DataTabe to create a new DataRow . Add the right data to the DataRow 's columns like so:
DataRow row = dataSet1.Tables["Suppliers"].NewRow();
row["supplier_id"] = 1;
row["name"] = "Goodyear";
dataSet1.Tables["Suppliers"].Rows.Add(row); You now already have your supplier ID from above, so repeat the process in a similar fashion to add a record to your "Products" DataTable .
Note that the DataSet is not a replacement for a database, however. If this data is data you need to store, you should keep it in a database and use that database to fill a DataSet using a DataAdapter derivative like the SqlDataAdapter (for SQL Server 2000) via DataAdapter.Fill , and update your database using the DataAdapter.Update method, which contains documentation and examples about how to configure a DataAdapter and use the method in the .NET Framework SDK that is installed with VS.NET by default, can be installed stand-alone, and is available online at http://msdn.microsoft.com/library[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
The supplier_id is auto increment so that is a problem how can i solve this problem?
greetings
Sander
|
|
|
|
|
Don't assign it, then. Once you've added the DataRow to dataSet1.Tables["Suppliers"].Rows then access the row["supplier_id"] and you have your auto-generated number.
You really should read the documentation for the ADO.NET classes. A good place to start and get a high-level overview is Accessing Data with ADO.NET[^] in the .NET Framework SDK. This is installed by default with VS.NET and is available online at http://msdn.microsoft.com/library/[^]. It has many examples and discusses all the classes, methods, properties, and events you need to create your solution.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
i understand but you need also to update the database right? because maybe the id that is generated (by the database) is not corresponding with the ID that the dataset created, because between the insertion and updating the database a new record was inserted by the another application.
And how does the Adapter look like because you can have only one InsertCommand per OleDbDataAdapter
greetings
Sander
|
|
|
|
|
Yes, but you never mentioned you were updating a database as well.
If you use the designer to set up a DataAdapter derivative in VS.NET (or any design designer) or use a command builder (like SqlCommandBuilder you'll notice that the InsertCommand property is comprised of an INSERT statement followed by a SELECT statement. This is to make sure that any auto-generated fields are selected into the DataTable correctly. This is not necessary for UPDATEs because the fields already existed.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|