|
hi all,
i am using a check box which gets checked whn the battery is low. but instead of tht i want to place a bitmap(of say a bulb)so that i could display a red signal when the battery is low and a green signal whn the battery is high.
how do i do ths??? i dont know first how to place a bitmap picture instead of that small rectangle whic gets checked each time in a check box. Second im not sure how to change the bitmap(red to green and vice versa) during run time. orelse is there any other way to do ths???
can anyone help me plz.......thanx!!
ramya.
|
|
|
|
|
Use a PictureBox and a Label instead of the CheckBox.
The PictureBox has a property "Image" - change it, whenever you want to change the image at runtime.
|
|
|
|
|
hi i tried using picture box as u said but at run time to change i used SetBitmap to set to new bitmap image. but it didnt work. nothing got diplayed.
i cudnt find any property called "Image"....can u plz help me.
|
|
|
|
|
It's PictureBox.Image . It's there. The other thing is make sure the Bitmap is found. If you read it from a file, make sure the file actually exists and is resolved correctly. Since this file is necessary for your app, you could also embed it as an embedded resource and get a Bitmap easily by using the Bitmap(Type, string) constructor (read the docs for details). Assign that bitmap to the PixtureBox.Image property.
Using an embedded resource ensures that your image is always available and found, and that you don't have to worry about distributing it separately (either as a separate file or as a separate copy command), which could lead to file resolution (finding the file) problems.
-----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-----
|
|
|
|
|
What C# control can i post on web that needn't install in user computer? .
This control can interact with my web service .
Thanks for your help!
|
|
|
|
|
None, at least from a client-side perspective. Just like a Java applet - if the user doesn't have a JRE installed, they aren't going to see the applet. If you use ASP.NET, though, you can use a server-side control but these actually render HTML. Not really a big deal, though. Your ASP.NET control (.ascx files or pre-compiled classes that derive from WebControl ) can talk to the Web Service. If you need a client-side control, see my article at http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=388[^] - but it'll still require the .NET Framework. There's no way around it.
-----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-----
|
|
|
|
|
The DataGrid support multi-selection operations. But when I have multi-selected some rows, How can I determine which rows have been selected?
|
|
|
|
|
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)">
|
|
|
|