|
At design time or runtime? Resizing isn't a problem. You simply set the Bounds of one control (#1 in your example) to the Bounds of the other control (#2 in your example) and shift the location to the right spot. You could also just set the Size property of control #1 to the Size of control #2, but you'll still probably need to adjust the Location since you'll either ge4t some overlap or space in between the two controls.
As far as dragging, you'll have to implement handlers for the various mouse events and track the mouse position accordingly.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for the reply Stewart,
I want to resize them at runtime.
Could you give me a sample code for setting bounds for controls.
Also the other issue is i would be placing controls in individual containers (panel) and then would be placing them on the form. I am planning on implementing the mouse events on the panel. I was wondering if this was a good approach. any new suggestions are welcome.
Thanks
Udaan2000
|
|
|
|
|
control1.Size = control2.Size;
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have a collection of objects. Lets call these objects resources. Each resource has a System.IO.FileInfo object. I have a method that removes the resource object from the collection then attempts to delete the file from the hard drive. However I get an error telling me the file is in use by another proccess. I am pretty sure this is cause there is still a reference to the file from the System.IO.FileInfo object but I have not been able to find a way to release it before deleting the file.
Any ideas?
|
|
|
|
|
You could set all FileInfo references to null. The GC will clean them up when it wants to, or you could force it with GC.Collect (although this isn't recommend).
A warning / piece of advice: FileInfo doesn't actually open the file, though it has methods that will create certain types of streams for you. What is most likely the problem is that you're not closing the streams elsewhere. Below is a piece of code that is recommend and best to use when possible:
Stream s = null;
try
{
s = new FileStream(...);
}
catch (Exception e)
{
Trace.WriteLine(e.Message);
}
finally
{
if (s != null) s.Close(); (
} The finally block gets called no matter if the stream operations succeed or fail. Closing the stream frees the file system handle (FILE) to the file. Not closing the stream will most commonly lead to the problems you are getting.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is it possible to set the toolbar component buttons to have text only buttons? If there is, what setting needs to be modified? Thanks
|
|
|
|
|
Not unless you override or make your own toolbar. One an image is set for one ToolBarButton , space is allocated for the rest. The ToolBar in the BCL does kind of stink, but there are plenty of alternatives available, including many here on CP and lots of commercial versions, too.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
hi i am asking for the way i can handle a voice event for example if i say
"start" an event will be invoke to open a program and if i say "save"the current file will be saved if you have an answer to this or any referense please send a mail to eafares265@hotmail.com thank you from lebanon to iran .
|
|
|
|
|
I guess in general you should look at the Microsoft Speech Application SDK on MSDN. It does speech both ways (recognition and text to speech). It's currently in Beta 3 I believe.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
please if you get any important referense to the voice event please let me know about it thank you for your time.
|
|
|
|
|
Hey gang,
Ok, I'm stumped on this one... I am using the using statement to wrap a SqlDataAdapter that I am using to fill a DataTable. Now, what I need to know is, just how much block-scope applies to objects created in the using scope.
For example:
<br />
static DataTable getTable()<br />
{<br />
using (SqlDataAdapter sda = new SqlDataAdapter("StoredProcedure", new SqlConnection("ConnectionString")))<br />
{<br />
DataTable dt = new DataTable("table");<br />
sda.Fill(dt);<br />
return dt;<br />
}<br />
}<br />
I know this would return a table with zero rows becuase it is created and destroyed within the scope of the using statement. But...
<br />
static DataTable getTable()<br />
{<br />
DataTable dt = new DataTable("table");<br />
using (SqlDataAdapter sda = new SqlDataAdapter("StoredProcedure", new SqlConnection("ConnectionString")))<br />
{<br />
sda.Fill(dt);<br />
}<br />
return dt;<br />
}<br />
Now, when I call this, I also get back zero rows in my table, yet when I run the query in SQL, it comes back fine. Anyone have any ideas or experience with the using statement?
TIA,
Bill P.
Oakland, CA
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCM/MU/B dpu s--:-- a32 C++++$ ULH+++ P+++ L++ E+ W+++$ N++ o K? w++++$ O-- M V-- PS+ PE+ Y++ PGP++ t++@ 5++@ X++ R+@ tv b++ DI++ D+++>++++ G++ e++ h---- r+++ y++++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
First, in either example, the DataTable is not disposed. Only the SqlDataAdapter is being disposed.
Second, your problem in both cases is that you're passing a stored proc name for the selectCommand parameter - read the documentation: this won't work. It must be a SQL command and only a SQL command. Instead, try this:
public static DataTable GetTable()
{
SqlCommand cmd = myConnection.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "StoredProcedure";
DataTable dt = new DataTable("Table");
SqlDataAdapter sda = new SqlDataAdapter(cmd);
using (sda)
{
sda.Fill(dt);
return dt;
}
} Also, if you're using a strongly-typed DataSet or DataTable , you'll also need to set up the SqlDataAdapter.TableMappings property.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hey Heath,
Thanks for the quick reply... but...
According to the docs:
selectCommandText
A String that is a Transact-SQL SELECT statement or stored procedure to be used by the SelectCommand property of the SqlDataAdapter.
I forgot to put in the fact that I use sda.SelectCommand.CommandType = CommandType.StoredProcedure.
Anyhow... I've tried it a number of different ways, all with the same problem.. the DataTable never has rows in it. I understand what you are saying, but, if the data adapter gets disposed *after* the fill, why would the data table still return no rows?
I did this and had the same results.
<br />
public static DataTable getTable()<br />
{<br />
DataTable dt = new DataTable("table");<br />
using (Config config = new Config())
{<br />
using (SqlConnection conn = new SqlConnection(config.SqlConnectionString))<br />
{<br />
using (SqlDataAdapter sda = new SqlDataAdatper("Select * from table", conn))<br />
{<br />
sda.Fill(dt);<br />
}<br />
}<br />
}<br />
return dt;<br />
}<br />
return dt;<br />
Now, from what I have read about the using statement, this pretty much translates to:
<br />
public static DataTable getTable()<br />
{<br />
DataTable dt = new DataTable("table");<br />
Config config = new Config();<br />
try {<br />
SqlConnection conn = new SqlConnection(config.SqlConnectionString);<br />
try {<br />
SqlDataAdapter sda = new SqlDataAdapter(SqlDataAdatper("Select * from table", conn));<br />
try {<br />
sda.Fill(dt);<br />
}<br />
finally {<br />
if (sda!= null) ((IDisposable)sda).Dispose();<br />
}<br />
}<br />
finally {<br />
if (conn!= null) ((IDisposable)conn).Dispose();<br />
}<br />
}<br />
finally {<br />
if (config != null) ((IDisposable)config).Dispose();<br />
}<br />
return dt;<br />
}<br />
Believe it or not, when I run that code above, as is, it works fine. My table is populated and everyone is happy. Sorry to carry on, I am just trying to figure out the scope usage that MS wrote into the using statement.<br />
<br />
Any ideas? <br />
<br />
TIA,<br />
Bill P.<br />
Oakland, CA<br />
<hr size="2" noshade="" style="color: rgba(70, 130, 180, 1)">-----BEGIN GEEK CODE BLOCK-----<br />
Version: 3.21<br />
GCM/MU/B dpu s--:-- a32 C++++$ ULH+++ P+++ L++ E+ W+++$ N++ o K? w++++$ O-- M V-- PS+ PE+ Y++ PGP++ t++@ 5++@ X++ R+@ tv b++ DI++ D+++>++++ G++ e++ h---- r+++ y++++<br />
-----END GEEK CODE BLOCK-----<br />
<hr size="2" noshade="" style="color: rgba(70, 130, 180, 1)">
|
|
|
|
|
First of all, you don't need to worry about disposing managed objects all the time. The garbage collector will take care of that eventually. Disposing it just cleans it up immediately.
Second, the using statement merely causes the Dispose method to be called on objects that implement IDisposable . The DataTable is not tied to a SqlDataAdapter (i.e., not a field or anything else that gets disposed). Because you're giving the DataTable a name, the result have to match that name to be filled. Use a TableMapping mapping or don't give the DataTable and name and see what you get.
And yes, had you mentioned that you were setting the CommandType , I wouldn't have mentioned that. The default, however, is CommandText so it was worth mentioning from my perspective with the knowledge you provided.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Got it.. thanks for the assist. Unfortunatly, I have to worry about early disposal of my objects because I am running this on a shared server in the company and I need to really, really, REALLY manage my memory usage (***sigh grumble***)...
Thanks Heath...
Bill P.
Oakland, CA
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCM/MU/B dpu s--:-- a32 C++++$ ULH+++ P+++ L++ E+ W+++$ N++ o K? w++++$ O-- M V-- PS+ PE+ Y++ PGP++ t++@ 5++@ X++ R+@ tv b++ DI++ D+++>++++ G++ e++ h---- r+++ y++++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
i'm using the dotnetmagic.com docking component.
i want to develop the content of each dock in a library of its own. ( not using the dotnetmagic component ) the idea is to be able to re-use the same objects if i end up changing things to the application later.
for example, i have a search ( in a group box ) and a datagrid. i want to be able to call them from their own class.
should i attach the search and datagrid each to their own panels in their own library?
i know i'm not doing a very good job explaining this .. espeically if you haven't used the dotnetmagic component.
any advice would be appreciated.
|
|
|
|
|
I guess I don't see what the problem is. .NET Magic doesn't care about where the content comes from. They are simply forms and can be in any assembly. When creating your docking manager and the content, instantiate the control from whatever library (either through Reflection or using assembly dependencies) and add it to the content. If you want to be able to refer to these controls directly instead of enumerating the content in a docking manager, then as you instantiate these various controls in any number of libraries, keep a collection (either local to the form that contains the docking manager, or some static collection that is globally accessible) or hashtable (same advice as for collections). We do something very similar in our application with no problem.
It's no different than creating a basic form with a default Button or DataGrid (for example). They are defined in the System.Windows.Forms assembly and your form isn't. The same is true for almost any language runtime in existence, for that matter.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello All.
I have this error in my application and I have no idea of what I'm doing wrong:
'ALINK: error AL1057: Executables cannot be localized, Culture should always be empty'
MSDN says about this 'An assembly is being created with /target:exe but /culture was specified. Assemblies in the .exe cannot have information in the Culture field'.
I can understand what this means. Anyone can explain to me ??
Thanks.
|
|
|
|
|
It means don't use the /culture switch! The main exes and dlls are always compiled into language neutral assemblies. You can control which language is neutral by using the System.Globalization.NeutralResourcesLanguageAttribute , an assembly-level attribute that you would typically put in your AssemblyInfo.cs file (although it can go anywhere, so long as it is appended with the assembly: prefix, like [assembly:NeutralResourcesLanguage("en-US")] .
The /culture switch is used for satellite assemblies - assemblies that contain localized resources (in source form, these are ResX files). They contain no code. You can also create localized assemblies by using the AssemblyCultureAttribute , but these projects may not contain any code - only .ResX files (which are compiled to .resource files).
You can find out more in MSDN about satellite assemblies at http://msdn.microsoft.com/library/en-us/cpguide/html/cpconsatelliteassembliesside-by-sideexecution.asp[^] and localizing resources at http://msdn.microsoft.com/library/en-us/cpguide/html/cpcondesigningglobalapplications.asp[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for your response, but I'm still lost.
I don't know how to turn off the /culture switch.
The only thing I know about culture is that in the project I have a form in spanish and I want to translate it into English, so I put the Localizable property to true and then I selected into the languaje property English. Then I translated the form into English and after that I get the error.
Is this the cause of the error ? How can I turn off the /Culture swicth ?
Thanks in advance.
Bye.
|
|
|
|
|
Did you read the links I gave you? They discuss localization in great length. First, if you are authoring the original forms in Spanish and it is in that locale that all your code is contained, then use the NeutralResourcesLanguageAttribute and specify the appropriate culture. Second, try going back to the "default" culture (actually the neutral culture) in your form designer and compile again. VS.NET might thing that you're trying to compile the English satellite assembly as the primary assembly.
Second, show hidden files in your project. Look at the ResX files. If you use VS.NET's designers, these will be hidden under forms. If your form source file is named MyForm.cs, then you should have a MyForm.resx (the neutral language) and MyForm.en.resx or MyForm.en-US.resx.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I don't understand the "readOnly" parameter to PerformanceCounter constructor:
public PerformanceCounter(
string categoryName,
string counterName,
bool readOnly //QUESTION: If it's only readOnly, what's the use of the counter if you cannot update/increment it??
);
Thanks!
|
|
|
|
|
CillyMe wrote:
what's the use of the counter if you cannot update/increment it??
If u just wanna read it....
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
for(int i=0; i< ; i++)
{
leppie.Delete( );
}
|
|
|
|
|
U certainly cant modify counters like CPU usage etc....
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|