|
You will have to change the control yourself, or either use a different control.
|
|
|
|
|
Hey guys,
I have 5 buttons in my form. During the page load event only 1 will be enabled, rest all i have made it Enabled = false. I have one more button named as "More", when a user clicks on it, the buttons which are disabled should be enabled one by one. Can someone please give me a solution for this.
Thanks,
Vikas
vikas da
|
|
|
|
|
Put this in your button handler:
button5.Enabled = button4.Enabled;
button4.Enabled = button3.Enabled;
button3.Enabled = button2.Enabled;
button2.Enabled = button1.Enabled;
Regards,
Rob Philpott.
|
|
|
|
|
Write a method like this:
private void ToggleButtonGroup(Button button)
{
button1.Enabled = (this.button1 == button);
button2.Enabled = (this.button2 == button);
button3.Enabled = (this.button3 == button);
button4.Enabled = (this.button4 == button);
}
Call this method from each appropriate button handler. If you passed this.button4 to the method, button4 would be enabled, and the rest would be disabled.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Monday, December 14, 2009 8:22 AM
|
|
|
|
|
Thanks guys for your help
vikas da
|
|
|
|
|
I would suggest putting the additional buttons in a Panel , then you can toggle just one Enabled property.
|
|
|
|
|
I have a form with few child controls that are overlapping each other. I need to have one of them to be always displayed above all others. In some special situations the z-order of the child controls is being changed. Is it possible to be notified about z-order change? As a result I will bring my special child control in front of all other child controls.
|
|
|
|
|
When the z-order of the control is changed, its index in the Controls array will also change. AFAIK there is no particular event to track this. Although if you cab track that the item indices in that array has changed, you can set your child control as top most.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
First i had this:
private void pbEdit_OnMouseEnter(object sender, EventArgs e)
{
pbTextEdit.Image = Image.FromFile("C:/data/edit_color.gif"); }
Now I wanna use 1 function for different pictureboxes:
My code i was thinking of but didn't work
this.Image = Image.FromFile("C:/data/edit_color.gif");
Dennis,
|
|
|
|
|
If I understood your question correct, you need to have a single method to change images of multiple picture boxes. And that method should be the MouseEnter event handler. Right?
You can have single event handler for all the picture boxes. This way:
picBox1.MouseEnter += new EventHandler(EventHandlerName);
picBox2.MouseEnter += new EventHandler(EventHandlerName);
Same way you can do this fro others as well.
Now, in order to change the image, use the following:
PictureBox picBox = sender as PictureBox;
picBox.Image = Image.FromFile("Set file path here");
In case all the picture boxes need to show the different images, you can keep the image file path in the Tag property of the PictureBox and then use it like this:
picBox.Image = Image.FromFile(picBox.Tag.ToString());
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Im having 10 picturesboxes that im using as button.
When im mouse over over now it is changed from image.
and when i click on that button its openeing in every 10 buttons a different window.
Have that now
But all 10 picatureboxes must have the same mousenter and mouseleave event.
SO i didnt't want to make 10 the same mouseenter and mouseleave events.
Is it possible in 1?
|
|
|
|
|
Offcourse it is. Did you saw the first code block I have written?
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
I've made this already:
picBox1.MouseEnter += new EventHandler(EventHandlerName);
picBox2.MouseEnter += new EventHandler(EventHandlerName);
But I must declare in the eventhandler that it is changed the only the image the one where the mouse is hovering then, not all images.
1 eventhandler where he only works with the image where it's mouseentering and mouse leaving then.
It's difficult to explain for me.
|
|
|
|
|
Did you read the second and the third code blocks?
The object sender will be the picturebox which fires the event. This means, that if you do a mouse enter on picturebox1, the sender will be picturebox1. If you do mouse enter on picturebox2, sender will be picturebox2. Now, if you cast sender to a picturebox, and change its image, it will change image of only the concerned picturebox.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
d@nish wrote: Did you read ... ?
I like rhetorical questions.
|
|
|
|
|
Fixed the problem now. Thaks for the reply's!!
|
|
|
|
|
Hi all
I use SQLEXPRESS and this is my connectionstring:
@"Data Source=.\SQLEXPRESS;AttachDbFilename=" + Application.StartupPath + "\\Data\\mydatabase.mdf;" + "Integrated Security=True;User Instance=True";
and i use sqlconnection to connect to my database.
and i execute my backup command like below:
string backup = string.Format("backup database mydatabase TO DISK= '{0}'", addr);
backup.ExecuteNonQuery();
but errormessage is :
Could not locate entry in sysdatabases for database 'mydatabase'. No entry found with that name. Make sure that the name is entered correctly.
BACKUP DATABASE is terminating abnormally.
Changed database context to 'master'.
please somebody help me.
modified on Monday, December 14, 2009 4:15 AM
|
|
|
|
|
To backup and restore restore sql server, I would say make use of classes under SQLDMO namespace. Take a look at SQLServerClass class and the BackupClass class in that namespace. They offer required methods and properties.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
thx.
I want to know what is the required command for backup and restore?
I want to add a utility to my application that when user need a backup from database or restore to one of his backup databases , my application enable to do it.
|
|
|
|
|
There were previously a lot of Questions ask about this
http://www.codeproject.com/Messages/3119251/Re-back-up-sql-data-programmetically.aspx[^]
There are more just search the Forum for messages posted
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I use SQLEXPRESS and this is my connectionstring:
@"Data Source=.\SQLEXPRESS;AttachDbFilename=" + Application.StartupPath + "\\Data\\mydatabase.mdf;" + "Integrated Security=True;User Instance=True";
and i use sqlconnection to connect to my database.
and i execute my backup command like below:
string backup = string.Format("backup database mydatabase TO DISK= '{0}'", addr);
backup.ExecuteNonQuery();
but errormessage is :
Could not locate entry in sysdatabases for database 'mydatabase'. No entry found with that name. Make sure that the name is entered correctly.
BACKUP DATABASE is terminating abnormally.
Changed database context to 'master'.
please somebody help me.
|
|
|
|
|
Repeating the same question as if you did not hear the response will not get you further response.
except this one, of course!
|
|
|
|
|
If you pay more attention i modified my question !
I want to know that can i backup from mydatabase in SQLEXPRESS by the code that i notice?
|
|
|
|
|
Because there is no database with the name 'mydatabase' the syntax of the backup database is incorrect. Here are two Sp's use them
For Backup
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- backup a database
ALTER PROCEDURE [dbo].[sp_BackupDatabase]
@databasename varchar(32),
@path varchar(256),
@filename varchar(64)
AS
set nocount on
declare @sql varchar(4000)
select @sql = 'BACKUP DATABASE ' + ltrim(rtrim( @databasename ))
select @sql = @sql + ' TO DISK = ''' + ltrim(rtrim(@path)) + ltrim(rtrim(@filename)) + ''' '
select @sql = @sql + ' WITH INIT'
--print @sql
execute ( @sql )
select 'Database successfully backed up!' [Result]
and later you might want to Restore and you can use this
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[sp_RestoreDatabase]
@dbname char(32), -- the database name to restore as
@filename char(64), @path char(256) -- the location of the backuped up database file (on the SQL Server)
AS
set nocount on
declare @sql nvarchar(3000)
-- Restore the database
select @sql = ' RESTORE DATABASE ' + ltrim(rtrim( @dbname )) + ' FROM DISK = ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @filename )) + ''' '
select @sql = ltrim(rtrim(@sql)) + ' WITH '
select @sql = ltrim(rtrim(@sql)) + ' MOVE ''' + 'TNGoedit_Data' + ''' TO ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @dbname )) + '.mdf' + ''' , ' -- logical file name to physical name
select @sql = ltrim(rtrim(@sql)) + ' MOVE ''' + 'TNGoedit_Log' + ''' TO ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @dbname )) + '_log.ldf' + ''' ' -- logical file name to physical name
select @sql = ltrim(rtrim(@sql)) + ' ,REPLACE,RECOVERY;'
--select @sql = ltrim(rtrim(@sql)) + ' MOVE ''' + ltrim(rtrim(@dbname)) + '_Data' + ''' TO ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @dbname )) + '.mdf' + ''' , ' -- logical file name to physical name
--select @sql = ltrim(rtrim(@sql)) + ' MOVE ''' + ltrim(rtrim(@dbname)) + '_Log' + ''' TO ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @dbname )) + '_log.ldf' + ''' ' -- logical file name to physical name
print @sql
execute ( @sql )
-- Was the command successful or was there a problem
if ( (select @@Error) = 0 ) begin
-- Put an entry into oDirect.dbo.tbl_dbRef
-- execute ( 'sp_DataSet_Save ''' + @xml + ''' ' )
-- TODO: restore the users
select 'Restore Successful' [Result]
end
else begin
select 'Restore Unsuccessful' [Result]
end
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
what is the diffrennce between String & string
|
|
|
|