|
Hi Christian, thank you for your input, I can't load the control during the load method of the control because the control on the 4th tab page loads immediately after deleting the 5th tab page, because the tab control automatically sets the selected index to the index of the control...not sure how to explain this, but if you delete tab page 5, then the tab control within visual studio will set the selected index to tab 4 upon loading the tab control. when that happens tab 4's load method will execute causing the loading of the form to be an extra 3 seconds slower than it needs to be. Not too sure if that answers your question/answer. or if I am way off base could you explain your solution a little more please? thank you.
eatwork
|
|
|
|
|
No, I meant during the visible changed event. When it becomes visible.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thank you Christian for your reply, sorry it took me so long to reply. I will give your suggestion a try.
eatwork
|
|
|
|
|
does any1 know how to shutdown, restart, standby, hibernate, or logoff the Windows XP system?
i know its to do with:
shutdown(*)
* = number corresponding to shutdown type...
i dont know how to perform these tasks... can any1 help me?
thanks...
Adam Forbes
|
|
|
|
|
I would think that you can not do this from an application.It seems to me that it would be too much of a security risk, but if you find out how let me know.
"People who never make mistakes, never do anything."
My Blog
|
|
|
|
|
It is possible - but you have to PInvoke native functions in Windows to achieve it.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
You'll have to pInvoke the ExitWindowsEx[^] function in the Win32 API.
Here in an example[^].
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
It's not a security risk. If the logged in user doesn't have the rights to shutdown Windows, it won't happen.
Declare Function ExitWindowsEx Lib "user32" ( _
ByVal uFlags As EWX_UFLAGS, _
ByVal dwReason As EWX_REASON) As Boolean
Public Enum EWX_UFLAGS As Integer
LogOff = &H0
Shutdown = &H1
Reboot = &H2
Force = &H4
PowerOff = &H8
ForceIfHung = &H10
End Enum
Public Enum EWX_REASON As Integer
MajorApplication = 0x00040000
MajorHardware = 0x00010000
MajorLegacyApi = 0x00070000
MajorOperatingSystem = 0x00020000
MajorOther = 0x00000000
MajorPower = 0x00060000
MajorSoftware = 0x00030000
MajorSystem = 0x00050000
MinorBlueScreen = 0x0000000F
MinorCordUnplugged = 0x0000000b
MinorDisk = 0x00000007
MinorEnvironment = 0x0000000c
MinorHardwareDriver = 0x0000000d
MinorHotfix = 0x00000011
MinorHung = 0x00000005
MinorInstallation = 0x00000002
MinorMaintenance = 0x00000001
MinorMMC = 0x00000019
MinorNetworkConnectivity = 0x00000014
MinorNetworkCard = 0x00000009
MinorOther = 0x00000000
MinorOtherDriver = 0x0000000e
MinorPowerSupply = 0x0000000a
MinorProcessor = 0x00000008
MinorReconfig = 0x00000004
MinorSecurity = 0x00000013
MinorSecurityFix = 0x00000012
MinorSecurityFixUninstall = 0x00000018
MinorServicePack = 0x00000010
MinorServicePackUninstall = 0x00000016
MinorTermSrv = 0x00000020
MinorUnstable = 0x00000006
MinorUpgrade = 0x00000003
MinorWMI = 0x00000015
FlagUserDefined = 0x40000000
FlagPlanned = 0x80000000
End Enum
I haven't tested this particular code because it was written from memory and pieces copied from PInvoke.net. To call this:
ExitWindowsEx( EWX_UFLAGS.PowerOff, EWX_REASON.MajorSystem Or EWX.MinorOther)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm creating a small room reservation program in which the user can reserve a room number for a certain amount of time on a certain date.
Let's say room 2 is reserved on 3-3-2006 between 7:00 and 11:00. How can I prevent users from placing a reservation with a starting time, or an ending time, between 7 and 11? They shouldn't be allowed to make a reservation from 8:00 till 9:00, neither should they from 10:00 till 12:00.
I've tried everything, but I have no clue. The only thing I have so far is code that checks whether an exact record exists. So if someone already reserved room 2 on 3-3-2006 at 7:00 till 11:00, an error will show.
I've tried something like this:
SELECT StartTime, EndTime, Date, Comment, Room, PersonID, ID<br />
FROM tblReserveringen<br />
WHERE (StartTime BETWEEN '13:00' AND '14:00') AND (Room= ?) AND (Date= ?)<br />
OR (EndTime BETWEEN '13:00' AND '14:00') AND (Room= ?) AND (Date= ?)<br />
As you can see, I tried to work with parameters. When a record matching the conditions is found, the submission is cancelled. Now if only I could make those time cells variable with parameters, like the rest of -em! Something like:
SELECT StartTime, EndTime, Date, Comment, Room, PersonID, ID<br />
FROM tblReserveringen<br />
WHERE (StartTime BETWEEN (StartTime= ?) AND (EndTime= ?)) AND (Room= ?) AND (Date= ?)<br />
OR (EndTime BETWEEN (StartTime= ?) AND (EndTime= ?)) AND (Room= ?) AND (Date= ?)<br />
Unfortuately, above code does not work (the first example does). Is it even possible what I want?
Any help is greatly appreciated.
--Erwin
|
|
|
|
|
Hi!
Can you loop enum elements?
Ex:
<br />
public enum eSize<br />
Small<br />
Medium<br />
Large<br />
end enum<br />
<br />
For each vSize as eSize in eSize.Elements<br />
DoStuff(vSize)<br />
next<br />
<br />
-- modified at 8:40 Monday 9th January, 2006
|
|
|
|
|
You could use the Enum class' .GetValues shared function..
<br />
For each vSize as eSize in Enum.GetValues(GetType(eSize))<br />
DoStuff(vSize)<br />
Next<br />
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Thanks!
Had to put the brackets in there but now it works like a charm!
<br />
For each vSize as eSize in [Enum].GetValues(GetType(eSize))<br />
DoStuff(vSize)<br />
Next<br />
|
|
|
|
|
Yes, you use the static methods defined in the <code>Enum</code> class
Heres some test code for you. The button on my test for was button3
enum MyEnum
{
Foo,
Bar,
Laa,
Noe
}
private void button3_Click(object sender, System.EventArgs e)
{
string [] names = Enum.GetNames(typeof(MyEnum));
MyEnum[] enums = (MyEnum[])Enum.GetValues(typeof(MyEnum));
for(int i=0;i<names.Length;i++)
{
MessageBox.Show( String.Format("DoSomething({0})",names[i]));
DoSomething(enums[i]);
}
}
private void DoSomething(MyEnum e)
{
MessageBox.Show(e.ToString());
}
|
|
|
|
|
Hello
I want to set the width of each columns in datagrid separately but not able to do that. I am using datagrid and datatable in my project the codes are as follows.
Dim Mytable as new datatable
Mytable.columns.add(“srno”, gettype, string))
Mytable.columns.add(“name”, gettype,( string))
Mytable.columns.add(“designation”, gettype,( string))
Mytable.columns.add(“remarks”, gettype,( string))
Datagrid1.datasourse = mytable
datagrid1.preferredcoloumswidth = 74
Now my problem is all the coloumns are OF the same width, as I wanted different width of different column. As of now all the columns have the same width whereas I don’t need so much width for the SRNO and need more wider colums in REMARKS. Please suggest how can I solve this problem.
Thanks alot
|
|
|
|
|
You have to modify the DataGrids TableStyles collection to get at the column widths.
Dim ts As DataGridTableStyle = DataGrid1.TableStyles("columnName")
ts.Width = someValue
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I tried the one you suggested
Dim ts as datagridtablestyle = datagrid1.tablestyles(“REMARKS”)
Ts.preferredcoloumns = 100
I HAD THIS ERRORS
“Object reference not set to an instance of an object”
Kindly check pls.
Thanks alot for your time.
|
|
|
|
|
Sorry, I had rectal-cranial inversion...
DataGrid1.DataSource = ds.Tables("MyTable")
Dim ts As New DataGridTableStyle
ts.MappingName = "MyTable"
DataGrid1.TableStyles.Add(ts)
ts.GridColumnStyles(0).Width = 15
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Sorry but it still has erros
I tried you codes but still I have one more error sending you my declarations
DECLARATION
Dim mytable As New DataTable
Dim ds As New DataSet
ON FORM LOAD
mytable.Columns.Add(New DataColumn("ContactPerson", GetType(String)))
mytable.Columns.Add(New DataColumn("DESIGNATION", GetType(String)))
mytable.Columns.Add(New DataColumn("PHONENO", GetType(String)))
mytable.Columns.Add(New DataColumn("EXTN", GetType(String)))
mytable.Columns.Add(New DataColumn("CELLNO", GetType(String)))
mytable.Columns.Add(New DataColumn("SALESMAN", GetType(String)))
mytable.Columns.Add(New DataColumn("REMARKS", GetType(String)))
Me.DataGrid1.DataSource = ds.Tables("mytable")
Dim ts As New DataGridTableStyle
ts.MappingName = "mytable"
DataGrid1.TableStyles.Add(ts)
Me.DataGrid1.DataSource = mytable
ts.GridColumnStyles(0).Width = 100
ERROS IS HERE (index is out of range: MUST BE NEGATIVE AND LESS THAN THE SIZE OF THE COLLECTIONS)
Thanks again for you help and you Suggestionss
Thanks again
Regards
|
|
|
|
|
It doesn't work because you reset the DataSource of the DataGrid, wiping out all the changes made to the TableStyles. Why are you adding all the Columns? You really don't need to unless your going to customize the look of them, which you're not doing in your code.
' I hope your DataSet actuall yhas a table in it called mytable.
' If not, this won't work. Change this to reflect the name of YOUR
' table in your DataSet.
DataGrid1.DataSource = ds.Tables("mytable")
Dim ts As New DataGridTableStyle
ts.MappingName = "mytable" ' Change this to match the name of the table in your DataSet
DataGrid1.TableStyles.Add(ts)
ts.GridColumnStyles(0).Width = 100
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Finally I was able to resize it, Thanks for your Help and Support
The codes are as Under for reference
Dim mytable As DataTable
mytable = New DataTable("MAIN")
mytable.Columns.Add(New DataColumn("ContactPerson",GetType(String)))
mytable.Columns.Add(New DataColumn("DESIGNATION",GetType(String)))
mytable.Columns.Add(New DataColumn("PHONENO",GetType(String)))
DataGrid1.DataSource = mytable
Dim TS As New DataGridTableStyle
TS.MappingName = "MAIN"
DataGrid1.TableStyles.Add(TS)
TS.GridColumnStyles.Item(1).Width = 100
TS.GridColumnStyles.Item(0).Width = 100
Thanks Again for your time
|
|
|
|
|
Pravin Hegde wrote: The codes are as Under for reference
Precisely why you keep it in the forums!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
So that if anyone has the same problem he can get an idea to how to do it !!! Just a helping hand like you which you always do.
Thanks
|
|
|
|
|
When I add a new addin to microsoft excel, where does this store this information in the registry? for eg, i have an addin say MyAddin.xla and I add manually from excel. Then it gets displayed in list of macros, which I can then disable or enable as I want. Where is this information stored in the registry?
Thanks
Aljechin Alexander
|
|
|
|
|
XLAs get stored in HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Options and Excel opens them, in order, first with the template pointed to by OPEN, then OPEN1, then OPEN2, and so on.
This article talks about COM and Automation Add-Ins[^].
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Thank you so much for your help. I will check the same and get back to you.
Aljechin Alexander
|
|
|
|