|
|
This is not the right forum for posting anything else other than a question on Window Forms.
(definitely not for advertising)
|
|
|
|
|
Hi,
I am using WeifenLuo.WinformsUI.Docking suite in m in my Winforms App for Docking Multiple forms in a MDI Form.
Now the isssue is when i am making a Forms as Auto Hide.
When i am trying to click View --> Window , then the window on the toggling.
I tried:
private void ShowForm_Click(object sender, EventArgs e)
{
Explorer.Show(dockPanel);
Explorer.Select();
}
I am using WeifenLuo.WinformsUI.Docking.dll Version 2.7.0.0
Any suggestion plz Help.
|
|
|
|
|
|
I make three form one admin and second user and mainform if admin login then my main form all the menu item is enable but when user login then also all menustrip item button is enable how to disable this menu item. Please help to solve this problem.
|
|
|
|
|
Please show the actual code that is not working and explain in detail. No one can guess what your code does.
Veni, vidi, abiit domum
|
|
|
|
|
ANKIT KUMAR SINHA wrote: if admin login then my main form all the menu item is enable but when user login then also all menustrip item button is enable how to disable this menu item Instead of disabling the menu-item, I'd recommend not creating it in the first place.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Try creating a variable in the login form, when any of them logs in assign a value to that variable. Note: the value assigned should be different depending on who logged in. E.g (variable_name = 1..when admin logs in, variable_name = 2..when user logs in ). On the load event of the main form use an if statement to check the value of that variable. Depending on the value of the variable disable the menustrip item using the its name. Example when a normal user logs in
If(variable_name=1)
{
Menustripitem_name.enable=false;
}
Remember to declare the variables for validation as static variables in the login form so as to access it in the mainform.
Hope that works
|
|
|
|
|
Thanks.
I also solve this problem but my procedure is different first i MDI Parent form menustrip itme property change the modifier it declared public and then i access this menu strip in other form like login form.
step:1
menustripitem property = public
step:2
creating an object the login form
step:3
object.menustripitem.Enabled = false;
it working properly
|
|
|
|
|
you also realise that you can merge menu's from the child forms into the parent container?
Google : MDI Parent form merge menustrip[^]
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
check it userwise
if(user =="admin"){
menu.IsEnable=true;
}
else {menu.IsEnable=false;}
something like this
Sankarsan Parida
|
|
|
|
|
Try making a Boolean variable.
On login, the app must determine if the logged in user is admin or not.
Then, set the appropriate values.
On login:
If user is admin: adminbool = true
else
adminbool = false
On form_load
If(adminbool=false)
{
Menustripitem_name.enable=false;
}
else
{
Menustripitem_name.enable=true;
}
You get the idea, right?
|
|
|
|
|
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.IO.Ports
Imports System.Threading
Imports System.Text.RegularExpressions
Public Class clsSMS
#Region "Open and Close Ports"
'Open Port
Public Function OpenPort(p_strPortName As String, p_uBaudRate As Integer, p_uDataBits As Integer, p_uReadTimeout As Integer, p_uWriteTimeout As Integer) As SerialPort
receiveNow = New AutoResetEvent(False)
Dim port As New SerialPort()
Try
port.PortName = p_strPortName
'COM1
port.BaudRate = p_uBaudRate
'9600
port.DataBits = p_uDataBits
'8
port.StopBits = StopBits.One
'1
port.Parity = Parity.None
'None
port.ReadTimeout = p_uReadTimeout
'300
port.WriteTimeout = p_uWriteTimeout
'300
port.Encoding = Encoding.GetEncoding("iso-8859-1")
AddHandler port.DataReceived, New SerialDataReceivedEventHandler(AddressOf port_DataReceived)
port.Open()
port.DtrEnable = True
port.RtsEnable = True
Catch ex As Exception
Throw ex
End Try
Return port
End Function
'Close Port
Public Sub ClosePort(port As SerialPort)
Try
port.Close()
RemoveHandler port.DataReceived, New SerialDataReceivedEventHandler(AddressOf port_DataReceived)
port = Nothing
Catch ex As Exception
Throw ex
End Try
End Sub
#End Region
'Execute AT Command
Public Function ExecCommand(port As SerialPort, command As String, responseTimeout As Integer, errorMessage As String) As String
Try
port.DiscardOutBuffer()
port.DiscardInBuffer()
receiveNow.Reset()
port.Write(command & vbCr)
Dim input As String = ReadResponse(port, responseTimeout)
If (input.Length = 0) OrElse ((Not input.EndsWith(vbCr & vbLf & "> ")) AndAlso (Not input.EndsWith(vbCr & vbLf & "OK" & vbCr & vbLf))) Then
Throw New ApplicationException("No success message was received.")
End If
Return input
Catch ex As Exception
Throw ex
End Try
End Function
'Receive data from port
Public Sub port_DataReceived(sender As Object, e As SerialDataReceivedEventArgs)
Try
If e.EventType = SerialData.Chars Then
receiveNow.[Set]()
End If
Catch ex As Exception
Throw ex
End Try
End Sub
Public Function ReadResponse(port As SerialPort, timeout As Integer) As String
Dim buffer As String = String.Empty
Try
Do
If receiveNow.WaitOne(timeout, False) Then
Dim t As String = port.ReadExisting()
buffer += t
Else
If buffer.Length > 0 Then
Throw New ApplicationException("Response received is incomplete.")
Else
Throw New ApplicationException("No data received from phone.")
End If
End If
Loop While Not buffer.EndsWith(vbCr & vbLf & "OK" & vbCr & vbLf) AndAlso Not buffer.EndsWith(vbCr & vbLf & "> ") AndAlso Not buffer.EndsWith(vbCr & vbLf & "ERROR" & vbCr & vbLf)
Catch ex As Exception
Throw ex
End Try
Return buffer
End Function
#Region "Count SMS"
Public Function CountSMSmessages(port As SerialPort) As Integer
Dim CountTotalMessages As Integer = 0
Try
'#Region "Execute Command"
Dim recievedData As String = ExecCommand(port, "AT", 300, "No phone connected at ")
recievedData = ExecCommand(port, "AT+CMGF=1", 300, "Failed to set message format.")
Dim command As [String] = "AT+CPMS?"
recievedData = ExecCommand(port, command, 1000, "Failed to count SMS message")
Dim uReceivedDataLength As Integer = recievedData.Length
'#End Region
'#Region "If command is executed successfully"
If (recievedData.Length >= 45) AndAlso (recievedData.StartsWith("AT+CPMS?")) Then
'#Region "Parsing SMS"
Dim strSplit As String() = recievedData.Split(","c)
Dim strMessageStorageArea1 As String = strSplit(0)
'SM
Dim strMessageExist1 As String = strSplit(1)
'Msgs exist in SM
'#End Region
'#Region "Count Total Number of SMS In SIM"
'#End Region
CountTotalMessages = Convert.ToInt32(strMessageExist1)
'#End Region
'#Region "If command is not executed successfully"
ElseIf recievedData.Contains("ERROR") Then
'#Region "Error in Counting total number of SMS"
Dim recievedError As String = recievedData
recievedError = recievedError.Trim()
'#End Region
recievedData = "Following error occured while counting the message" & recievedError
End If
'#End Region
Return CountTotalMessages
Catch ex As Exception
Throw ex
End Try
End Function
#End Region
#Region "Read SMS"
Public receiveNow As AutoResetEvent
Public Function ReadSMS(port As SerialPort, p_strCommand As String) As ShortMessageCollection
' Set up the phone and read the messages
Dim messages As ShortMessageCollection = Nothing
Try
'#Region "Execute Command"
' Check connection
ExecCommand(port, "AT", 300, "No phone connected")
' Use message format "Text mode"
ExecCommand(port, "AT+CMGF=1", 300, "Failed to set message format.")
' Use character set "PCCP437"
ExecCommand(port, "AT+CSCS=""PCCP437""", 300, "Failed to set character set.")
' Select SIM storage
ExecCommand(port, "AT+CPMS=""SM""", 300, "Failed to select message storage.")
' Read the messages
Dim input As String = ExecCommand(port, p_strCommand, 5000, "Failed to read the messages.")
'#End Region
'#Region "Parse messages"
'#End Region
messages = ParseMessages(input)
Catch ex As Exception
Throw ex
End Try
If messages IsNot Nothing Then
Return messages
Else
Return Nothing
End If
End Function
Public Function ParseMessages(input As String) As ShortMessageCollection
Dim messages As New ShortMessageCollection()
Try
Dim r As New Regex("\+CMGL: (\d+),""(.+)"",""(.+)"",(.*),""(.+)""\r\n(.+)\r\n")
Dim m As Match = r.Match(input)
While m.Success
Dim msg As New ShortMessage()
'msg.Index = int.Parse(m.Groups[1].Value);
msg.Index = m.Groups(1).Value
msg.Status = m.Groups(2).Value
msg.Sender = m.Groups(3).Value
msg.Alphabet = m.Groups(4).Value
msg.Sent = m.Groups(5).Value
msg.Message = m.Groups(6).Value
messages.Add(msg)
m = m.NextMatch()
End While
Catch ex As Exception
Throw ex
End Try
Return messages
End Function
#End Region
#Region "Send SMS"
Shared readNow As New AutoResetEvent(False)
Public Function sendMsg(port As SerialPort, PhoneNo As String, Message As String) As Boolean
Dim isSend As Boolean = False
Try
Dim recievedData As String = ExecCommand(port, "AT", 300, "No phone connected")
recievedData = ExecCommand(port, "AT+CMGF=1", 300, "Failed to set message format.")
Dim command As [String] = "AT+CMGS=""" & PhoneNo & """"
recievedData = ExecCommand(port, command, 300, "Failed to accept phoneNo")
command = Message & Char.ConvertFromUtf32(26) & vbCr
recievedData = ExecCommand(port, command, 3000, "Failed to send message")
'3 seconds
If recievedData.EndsWith(vbCr & vbLf & "OK" & vbCr & vbLf) Then
isSend = True
ElseIf recievedData.Contains("ERROR") Then
isSend = False
End If
Return isSend
Catch ex As Exception
Throw ex
End Try
End Function
Private Shared Sub DataReceived(sender As Object, e As SerialDataReceivedEventArgs)
Try
If e.EventType = SerialData.Chars Then
readNow.[Set]()
End If
Catch ex As Exception
Throw ex
End Try
End Sub
#End Region
#Region "Delete SMS"
Public Function DeleteMsg(port As SerialPort, p_strCommand As String) As Boolean
Dim isDeleted As Boolean = False
Try
'#Region "Execute Command"
Dim recievedData As String = ExecCommand(port, "AT", 300, "No phone connected")
recievedData = ExecCommand(port, "AT+CMGF=1", 300, "Failed to set message format.")
Dim command As [String] = p_strCommand
recievedData = ExecCommand(port, command, 300, "Failed to delete message")
'#End Region
If recievedData.EndsWith(vbCr & vbLf & "OK" & vbCr & vbLf) Then
isDeleted = True
End If
If recievedData.Contains("ERROR") Then
isDeleted = False
End If
Return isDeleted
Catch ex As Exception
Throw ex
End Try
End Function
#End Region
End Class
' MORE
' Request by Email....
CAO
|
|
|
|
|
? A big code dump. So what? What's the problem?
|
|
|
|
|
Hi,
We have a Windows Forms project with quite a few flatstyle buttons.
When we disable the buttons, the colors of the buttons are changed automatically
Is it possible to override this somehow, so we can control the colors ourselves?
Thanks,
Karl
|
|
|
|
|
You could create your own buttons, the simplest way is to inherit from Button and override some functions:
public class BernieButton : Button
{
protected override void OnEnabledChanged(EventArgs e)
{
base.OnEnabledChanged(e);
....
}
}
|
|
|
|
|
Yeah, that's the expected behavior. It's the standard notification to the user that the button will no longer work in the current situation.
Why would you want to change this?? If you don't change the color, the user will wonder what's wrong with your app because they think they're clicking on an active button and nothing is happening!
|
|
|
|
|
In fact the BackColor of control doesn't change and only ForeColor and BorderColor change.
Set FlatStyle to Flat, Set a non system BorderColor in FlatAppearance, Set a non system BackColor and you will see background and border will not change.
Only ForeColor changes to show difference of enabled and disabled button.
|
|
|
|
|
i create control and this control derived from gridview control.then i add 2 column in constructor like this :
InitializeComponent();
this.AutoGenerateColumns = false;
DataGridViewCheckBoxColumn cb = new DataGridViewCheckBoxColumn();
cb.HeaderText = "";
cb.Name = "dgvcSelect";
this.Columns.Add(cb);
DataGridViewTextBoxColumn tb = new DataGridViewTextBoxColumn();
tb.Name = "dgvcRowNumber";
tb.HeaderText = "ردیف";
but when i run my program 4 column generate for me.where is the problem?
please help me
|
|
|
|
|
Don't cross post in multiple forums.
Pick one forum best suited to your question and post your question once!
|
|
|
|
|
Need a bit more of the code the way this code looks is that you have created two columns but can't see enough to know what is happening.
Please post the entire scope of the problem so we can help.
Thanks
JD
http://www.seitmc.com/seitmcWP
|
|
|
|
|
You realize that this post is over 6 months old, right? Chances are good we'll never hear from his again.
|
|
|
|
|
HA! Well no I didn't look at the date. Doh! Just looking to do some give back.
Thanks
JD
http://www.seitmc.com/seitmcWP
|
|
|
|
|
Hi everybody,
I'm trying to bind a class variable to a textbox.
the data class looks like:
<pre lang="c#">
public class route
{
public string name { get; set; }
public int adress { get; set; }
public route()
{
name = "";
adress = 0;
}
}
public class adr
{
public int index { get; set; }
public route r1 { get; set; }
public route r2 { get; set; }
public adr()
{
index = 0;
r1 = new route();
r2 = new route();
}
}
public class para
{
public int i1 { get; set; }
public int i2 { get; set; }
}
public class adrData
{
public string label { get; set; }
public adr ad { get; set; }
public para pa { get; set; }
}
When I try to bind f.e. ad.r1.name to a textbox text via designer, it offers only label, ad and pa for binding.
What am I missing here?
Thnx adv for your answers.
modified 21-Jul-13 10:42am.
|
|
|
|
|
What type is "ad.r1.name"? As far as I can see from your code, there's only one "name" property, and that's a string, whereas the bindin-options imply that "name" contains an adrData ?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|