|
Create a collection of some type (like an ArrayList ), then enumerate the rows in your DataGrid . You can do this using the BindingContext of the DataGrid to get the CurrencyManager which associates rows in the DataSource to their displayed rows (since sorting or filtering may change index mapping).
For each row index, you can call DataGrid.IsSelected , passing the row index. If true , add to the collection of selected rows.
The only real question is whether or not multiple rows are truly selected (i.e., they make look it but their state is a matter of the DataGrid 's implementation).
I don't know why there isn't a much easier way (like with the ListView ). Perhaps MS thought it wouldn't be oft-used enough to warrant the resources. Of course, this could be said about a lot of things in the .NET 1.x BCL!
-----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've noticed that sometimes the order of my tab pages during runtime differs from the order I have at design time. Is this a bug? If not how do I stop it from happening?
|
|
|
|
|
I've consumed COM component from .NET applications using tblimp.exe to create a RCW. But sometimes, you can just "Add Reference"... When do I need "tblimp.exe" and when will I be able to just "Add Reference"?
Thanks.
|
|
|
|
|
The only difference is that using "Add Reference..." and the COM tab is that the typelib must be registered. When you add a COM reference this way, it uses either tlbimp.exe or the same code as tlbimp.exe would use. You may get a little more control using tlbimp.exe, however, but don't forget that if you want strongly-named assembly (i.e., they have to be signed) you can still do that in VS.NET. Just open the project properties of the project to which you'll add an RCW (before it's added) and specify the key file or key container at the bottom of the "General" page.
One other tip: to import ActiveX controls, you can also use aximp.exe or customize your toolbox which also creates an RCW (actually 2, one for the ActiveX control which will be derived from System.Windows.Forms.AxHost and the interop assembly for the typelib). The rules of signing still apply since the two interop assemblies are created when you add the ActiveX control to your project. One major difference about aximp.exe over VS.NET is, however, that aximp.exe can generate the source code for the AxHost derivitive class. This is sometimes handy when you want to change some things first.
-----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 yall,
I am new to customizing controls. I have windows form with controls from edge to edge (form is filled with controls). I want to implement resizing of the controls in the following way.
- if i drag an edge of a control (#1) over the other control (#2) then the first control should be resized to the size of (#1+#2) control.
for this requirement i am not able to drag a control's edge over the other control.
all controls' sizes are multiples of a predefined height and width.
Any help would be greatly appreciated.
Thanks in advance
Udaan
|
|
|
|
|
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.
|
|
|
|