|
Well, if you don't want to handle that in your main OnClick, I guess you can derive something from Control that draws a rectangle. I guess it's nice from an OO POV, but it seems to me like a lot of work to know when someone clicks on a rectangle.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
How do I hide a DataColumn in a Datagrid?
TIA
------------------
I'm naked under my clothes...
|
|
|
|
|
Hi TIA,
You can hide the colum by setting the width to 0.
DataGridTableStyle tblstyle = new DataGridTableStyle();
tblstyle.MappingName = dataGrid1.DataMember; //table name
dataGrid1.TableStyles.Add(tblstyle );
dataGrid1.TableStyles[0].GridColumnStyles["XX"].Width = 0;
where XX is your colum number.
Guess this will help you.
Thanks and Regards
SGS
|
|
|
|
|
The other reply suggested using table dataatyles. If I remember correctly, if you don't have a table style, all columns in the data table are shown.
If you add a table style to the data grid, you have to create a table column style for every column you want to display. So if you have a data table with 7 columns, and only add 5 table column styles, you only get 5 columns in the grid.
But as the other reply suggested, add a table column style for the hidden cell and set its width to 0, but that might allow the user to resize if he clicks at the right place.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I've created a C# windows service and I am able to install the service with no problems. However, the way that my service works is that it listens and responds to the client on a particular port. The port that the service listens on is configurable through a properties file so that the service port is configured at run time.
What I would like to do is be able to install my web service on to the same server more than once. For example, I'd like to have the windows service executable exist in two separate directories but with the same name. For example:
InstallUtil c:\FolderA\MyWinService.exe
InstallUtil c:\FolderB\MyWinService.exe
where FolderA win service is configured to listen on one port and FolderB win service configured to listen on a different port. However, you have to set the service name in code as follows:
this.serviceInstaller1.ServiceName = "My Win Service";
My question is this. Is there a way to expose the ServiceName as an option that may be set during the InstallUtil call so that I may do what I wish or must I create a second MyWinService2.exe with a different service name?
Thank you,
Jim
Jim
|
|
|
|
|
Hi there,
I am using overlapped IO to communicate with COM port.
I defined the OVERLAPPED structure and use it in the WriteFile() function.
The OVERLAPPED.hevent handle is created successfully,but when i used WriteFile() function,the GetLastWin32Error() returns 6 (The handle is invalid) instead of ERROE_TO_PENDING.
I appriciate any reply about this.
Thanks in advance.
the code example:
{
OVERLAPPED osWrite;
osWrite.hEvent=(System.IntPtr)CreateEvent((System.IntPtr)null, true, false, null)
success=CWinAPI.WriteFile(m_PortHandle, p, numBytesToWrite, out BytesWritten, &osWrite);
}
|
|
|
|
|
In VB I was able to create and run DTS packages. Howerver, I can't seem to convert the code I have over to C#. Here is a sample of the VB code that is generated from SQL, can someone please explain to me how I can convert my existing VB code to C#. DTS is a plays a pretty big role in the way we move data and I need to be able to create and run DTS packages at run time.
<br />
Public goPackageOld As New DTS.Package<br />
Public goPackage As DTS.Package2<br />
Private Sub Main()<br />
Set goPackage = goPackageOld <---here is where the troubles begin<br />
I am also having troubles with the properties giving errors as well. They are generally cannot implicitly convert errors. Anyone here have any experience with DTS that can help me find a solution?
<br />
'****************************************************************<br />
'Microsoft SQL Server 2000<br />
'Visual Basic file generated for DTS Package<br />
'File Name: C:\BCPTest\SamplteDTSPackage.bas<br />
'Package Name: SamplteDTSPackage<br />
'Package Description: DTS package description<br />
'Generated Date: 4/6/2005<br />
'Generated Time: 11:53:19 AM<br />
'****************************************************************<br />
<br />
Option Explicit<br />
Public goPackageOld As New DTS.Package<br />
Public goPackage As DTS.Package2<br />
Private Sub Main()<br />
Set goPackage = goPackageOld<br />
<br />
goPackage.Name = "SamplteDTSPackage"<br />
goPackage.Description = "DTS package description"<br />
goPackage.WriteCompletionStatusToNTEventLog = False<br />
goPackage.FailOnError = False<br />
goPackage.PackagePriorityClass = 2<br />
goPackage.MaxConcurrentSteps = 4<br />
goPackage.LineageOptions = 0<br />
goPackage.UseTransaction = True<br />
goPackage.TransactionIsolationLevel = 4096<br />
goPackage.AutoCommitTransaction = True<br />
goPackage.RepositoryMetadataOptions = 0<br />
goPackage.UseOLEDBServiceComponents = True<br />
goPackage.LogToSQLServer = False<br />
goPackage.LogServerFlags = 0<br />
goPackage.FailPackageOnLogFailure = False<br />
goPackage.ExplicitGlobalVariables = False<br />
goPackage.PackageType = 0<br />
<br />
<br />
Dim oConnProperty As DTS.OleDBProperty<br />
<br />
'---------------------------------------------------------------------------<br />
' create package connection information<br />
'---------------------------------------------------------------------------<br />
<br />
Dim oConnection As DTS.Connection2<br />
<br />
'------------- a new connection defined below.<br />
'For security purposes, the password is never scripted<br />
<br />
Set oConnection = goPackage.Connections.New("Microsoft.Jet.OLEDB.4.0")<br />
<br />
oConnection.ConnectionProperties("Data Source") = "C:\DTSTEST\myDB.MDB"<br />
oConnection.ConnectionProperties("Mode") = 1<br />
<br />
oConnection.Name = "Connection 1"<br />
oConnection.ID = 1<br />
oConnection.Reusable = True<br />
oConnection.ConnectImmediate = False<br />
oConnection.DataSource = "C:\DTSTEST\myDB.MDB"<br />
oConnection.ConnectionTimeout = 60<br />
oConnection.UseTrustedConnection = False<br />
oConnection.UseDSL = False<br />
<br />
'If you have a password for this connection, please uncomment and add your password below.<br />
'oConnection.Password = "<put the password here>"<br />
<br />
goPackage.Connections.Add oConnection<br />
Set oConnection = Nothing<br />
<br />
'------------- a new connection defined below.<br />
'For security purposes, the password is never scripted<br />
<br />
Set oConnection = goPackage.Connections.New("SQLOLEDB")<br />
<br />
oConnection.ConnectionProperties("Integrated Security") = "SSPI"<br />
oConnection.ConnectionProperties("Persist Security Info") = True<br />
oConnection.ConnectionProperties("Initial Catalog") = "BMS"<br />
oConnection.ConnectionProperties("Data Source") = "DEVServer\DEVServer"<br />
oConnection.ConnectionProperties("Application Name") = "DTS Import/Export Wizard"<br />
<br />
oConnection.Name = "Connection 2"<br />
oConnection.ID = 2<br />
oConnection.Reusable = True<br />
oConnection.ConnectImmediate = False<br />
oConnection.DataSource = "DEVServer\DEVServer"<br />
oConnection.ConnectionTimeout = 60<br />
oConnection.Catalog = "BMS"<br />
oConnection.UseTrustedConnection = True<br />
oConnection.UseDSL = False<br />
<br />
'If you have a password for this connection, please uncomment and add your password below.<br />
'oConnection.Password = "<put the password here>"<br />
<br />
goPackage.Connections.Add oConnection<br />
Set oConnection = Nothing<br />
<br />
'------------- a new connection defined below.<br />
'For security purposes, the password is never scripted<br />
<br />
Set oConnection = goPackage.Connections.New("Microsoft.Jet.OLEDB.4.0")<br />
<br />
oConnection.ConnectionProperties("Data Source") = "C:\DTSTEST\myDB.MDB"<br />
oConnection.ConnectionProperties("Mode") = 1<br />
<br />
oConnection.Name = "Connection 3"<br />
oConnection.ID = 3<br />
oConnection.Reusable = True<br />
oConnection.ConnectImmediate = False<br />
oConnection.DataSource = "C:\DTSTEST\myDB.MDB"<br />
oConnection.ConnectionTimeout = 60<br />
oConnection.UseTrustedConnection = False<br />
oConnection.UseDSL = False<br />
<br />
'If you have a password for this connection, please uncomment and add your password below.<br />
'oConnection.Password = "<put the password here>"<br />
<br />
goPackage.Connections.Add oConnection<br />
Set oConnection = Nothing<br />
<br />
'------------- a new connection defined below.<br />
'For security purposes, the password is never scripted<br />
<br />
Set oConnection = goPackage.Connections.New("SQLOLEDB")<br />
<br />
oConnection.ConnectionProperties("Integrated Security") = "SSPI"<br />
oConnection.ConnectionProperties("Persist Security Info") = True<br />
oConnection.ConnectionProperties("Initial Catalog") = "MyTestDB"<br />
oConnection.ConnectionProperties("Data Source") = "DEVServer\DEVServer"<br />
oConnection.ConnectionProperties("Application Name") = "DTS Import/Export Wizard"<br />
<br />
oConnection.Name = "Connection 4"<br />
oConnection.ID = 4<br />
oConnection.Reusable = True<br />
oConnection.ConnectImmediate = False<br />
oConnection.DataSource = "DEVServer\DEVServer"<br />
oConnection.ConnectionTimeout = 60<br />
oConnection.Catalog = "BMS"<br />
oConnection.UseTrustedConnection = True<br />
oConnection.UseDSL = False<br />
<br />
'If you have a password for this connection, please uncomment and add your password below.<br />
'oConnection.Password = "<put the password here>"<br />
<br />
goPackage.Connections.Add oConnection<br />
Set oConnection = Nothing<br />
<br />
'---------------------------------------------------------------------------<br />
' create package steps information<br />
'---------------------------------------------------------------------------<br />
<br />
Dim oStep As DTS.Step2<br />
Dim oPrecConstraint As DTS.PrecedenceConstraint<br />
<br />
'------------- a new step defined below<br />
<br />
Set oStep = goPackage.Steps.New<br />
<br />
oStep.Name = "Copy Data from tablename to [BMS].[dbo].[idxBillingNumber] Step"<br />
oStep.Description = "Copy Data from tablename to [BMS].[dbo].[idxBillingNumber] Step"<br />
oStep.ExecutionStatus = 1<br />
oStep.TaskName = "Copy Data from tablename to [BMS].[dbo].[idxBillingNumber] Task"<br />
oStep.CommitSuccess = False<br />
oStep.RollbackFailure = False<br />
oStep.ScriptLanguage = "VBScript"<br />
oStep.AddGlobalVariables = True<br />
oStep.RelativePriority = 3<br />
oStep.CloseConnection = False<br />
oStep.ExecuteInMainThread = True<br />
oStep.IsPackageDSORowset = False<br />
oStep.JoinTransactionIfPresent = False<br />
oStep.DisableStep = False<br />
oStep.FailPackageOnError = False<br />
<br />
goPackage.Steps.Add oStep<br />
Set oStep = Nothing<br />
<br />
'---------------------------------------------------------------------------<br />
' create package tasks information<br />
'---------------------------------------------------------------------------<br />
<br />
Call Task_Sub1(goPackage)<br />
<br />
'---------------------------------------------------------------------------<br />
' Save or execute package<br />
'---------------------------------------------------------------------------<br />
<br />
'goPackage.SaveToSQLServer "(local)", "sa", ""<br />
goPackage.Execute<br />
tracePackageError goPackage<br />
goPackage.Uninitialize<br />
'to save a package instead of executing it, comment out the executing package line above and uncomment the saving package line<br />
Set goPackage = Nothing<br />
<br />
Set goPackageOld = Nothing<br />
<br />
End Sub<br />
<br />
|
|
|
|
|
Sorry, I've never worked with it before, but perhaps this[^] will be of some assistance.
|
|
|
|
|
Add a (COM) reference to Microsoft DTSPackage Library in VS.
DTS.Package becomes DTS.Package2Class when you add the above reference. Other than that the code will only need the usual VB6-->C# changes.
VB6 was not strongly typed, so you may need to remember to cast objects appropriately when converting the above code to C#
I have done plenty of this so when you get specific problems post them back here and ill do my best to help.
|
|
|
|
|
I am finally getting back to working on this. I have completed the conversion of the VB6 to the C#. However, I am getting the following error:
System.InvalidCastException
and it is happening at this line of code
DTS.DataPumpTask DT = (DTS.DataPumpTask)package.Tasks.New("DTSDataPumpTask");
From what I have been able to find is that sp3 is need for SQL and I have that already.
I am just working on some test code right now and I can send you a copy of it if it helps.
|
|
|
|
|
Hey!
I have two classes: PortHandler and StreamForm.
StreamForm contains a RichTextBox and a button.
PortHandler is used to open a stream from a cellphone connected on COM1(seriallport).
When information is coming in PortHandler uses a delegate to write to the RichTextBox in StreamForm.
Here is how it looks like
StreamForm:
<br />
public delegate void IncomingPortData(object sender, string data);<br />
public IncomingPortData Incoming;<br />
<br />
private PortHandler PHandler;<br />
<br />
public StreamForm()<br />
{<br />
InitializeComponent();<br />
Incoming = new IncomingPortData(AddDataToLogg);<br />
}<br />
<br />
private void btConnectPhone_Click(object sender, EventArgs e)<br />
{<br />
connectPort();<br />
}<br />
<br />
public bool connectPort()<br />
{<br />
try<br />
{<br />
if (PHandler != null)<br />
{<br />
closePort();<br />
}<br />
<br />
PHandler = new PortHandler();<br />
PHandler.IncomingPortData = new PortHandler.PassPortData(IncomingData);<br />
<br />
if (PHandler.connectPort(new PortSettings("COM1", 19200, 8, Parity.None, StopBits.One)))<br />
{
return true;<br />
}<br />
return false;<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error in PhoneConnector - StreamForm - connectPort : " + ex.Message);<br />
return false;<br />
}<br />
}<br />
<br />
<br />
private void IncomingData(object sender, string data)<br />
{<br />
try<br />
{<br />
if (rtIncomeLogg.IsHandleCreated == false)<br />
MessageBox.Show("error here");<br />
<br />
rtIncomeLogg.Invoke(Incoming);<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error in PhoneConnector - StreamForm - IncomingData : " + ex.Message);<br />
}<br />
}<br />
private void AddDataToLogg(object sender, string data)<br />
{<br />
try<br />
{<br />
rtIncomeLogg.AppendText(data);<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error in PhoneConnector - StreamForm - AddDataToLogg : " + ex.Message);<br />
}<br />
}<br />
And the PortHandler
<br />
public delegate void PassPortData(object sender, string data);<br />
public PassPortData IncomingPortData;<br />
<br />
private SerialPort serialPort = null;<br />
private bool RUNNING = false;<br />
<br />
public bool connectPort(PortSettings settings)<br />
{<br />
try<br />
{<br />
if (serialPort == null)<br />
{<br />
PortConnection PCon = new PortConnection();<br />
serialPort = PCon.connectPort(settings);<br />
Thread IncomeThread = new Thread(new ThreadStart(IncomingData));<br />
IncomeThread.Priority = ThreadPriority.AboveNormal;<br />
RUNNING = true;<br />
IncomeThread.Start();<br />
return true;<br />
}<br />
return false;<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error in PhoneConnector - PortHandler - connectPort : " + ex.Message);<br />
return false;<br />
}<br />
}<br />
<br />
<br />
public void IncomingData()<br />
{<br />
try<br />
{<br />
string tmpString;<br />
<br />
while (RUNNING)<br />
{<br />
tmpString = ((char)serialPort.ReadChar()).ToString();<br />
<br />
if (tmpString.Length > 0)<br />
{<br />
IncomingPortData(this, tmpString);<br />
}<br />
tmpString = "";<br />
serialPort.ReadTimeout = 1000;<br />
}<br />
}<br />
<br />
Why is this dont working?
I get: Cannot call Invoke on a control until the window handler has been created?
This is a Windows Control Library(own made control.
I adds this Control to a simple Windows application project with a regular form with no extra code in.
But i get another error here?
<br />
namespace PortTest<br />
{<br />
static class Program<br />
{<br />
[STAThread]<br />
static void Main()<br />
{<br />
Application.EnableVisualStyles();<br />
Application.EnableRTLMirroring();<br />
Application.Run(new MainForm());
}<br />
}<br />
}<br />
The error i get here i : Parameter count mismatch!
This error do not appare at the start, but when i am trying to write to the rich text box
Pleas help
|
|
|
|
|
As for the Invoke problem, it stems from the control's handle not being created at the time you use Invoke.
I cannot see where rtIncomeLog is instantiated and added to a form, but the form in which it is a child has probably not had enough time to load. Invoke uses the control's handle to dispatch the delegates. To fix this there are a few things you can do: Wait to receive your incoming data until the control has been properly loaded by listening to the Load event, or you can create a model for your textbox. With the model you can append text to it, then dispatch an event that the text has changed. If the log control has been created then you can append the text to it, if not just hold onto the text until the model changes again. It wont matter if you build up a buffer of text if the rtIncomeLogg hasn't been created, because you won't be able to see the text anyways.
I can't immediately help for the 'Parameter count mismatch' because you didnt provide a line number. If you could provide the line number and the surrounding code that produces this error, I might be able to assist you.
-
Drew
|
|
|
|
|
I am working on an application in C#.Net which will be displaying images which will have color spaces defined (sRGB, Adobe RGB, etc). How do I go about making use of the defined color space to display the image correctly?
|
|
|
|
|
I want to connect to a pc using my modem for some FTP. plzz tell me what to do on both ends?
Thnxx in advance, Be Safe
Rizwan
Rizwan Ahmed
|
|
|
|
|
Hi! I've got this event in a gradient class:
public event EventHandler GradientChanged;
which is called by this method when a member of the gradient class is changed:
protected virtual void OnGradientChanged(EventArgs args)
{
if (this.GradientChanged != null)
this.GradientChanged((object)this, args);
}
But when I try to subscribe to this event, I get the following error:
"Events cannot be set on the object passed to the event binding service because a site associated with the object could not be located."
Any suggestions on how to fix it?
|
|
|
|
|
Could you post the line in which you attempt to assign a delegate?
You should be able to do something like the following:
<code>
{
theClass.GradientChanged += new EventHandler (OnGradientChanged);
}
public void OnGradientChanged (Object sender, EventArgs e)
{
}
</code>
-
Drew
|
|
|
|
|
Well.. I suspect that posting this doesn't help... I think the error might be somewhere else in my code, or in the .NET framework..
here's the code in three different versions that compiles perfect:
[no1]
public GradientControl()
{
this.colorGradient = new ColorGradient();
this.colorGradient.GradientChanged += new EventHandler(colorGradient_GradientChanged);
}
[no2]
public GradientControl()
{
this.colorGradient = new ColorGradient();
this.colorGradient.GradientChanged += colorGradient_GradientChanged;
}
[no3]
public GradientControl()
{
this.colorGradient = new ColorGradient();
this.colorGradient.GradientChanged += delegate(object sender, EventArgs e) { /*code*/ }
}
|
|
|
|
|
_eulogy_ wrote:
[no1]
public GradientControl()
{
this.colorGradient = new ColorGradient();
this.colorGradient.GradientChanged += new EventHandler(colorGradient_GradientChanged);
}
Is ColorGradient a class you have declared? If so, did you mark the event with the 'event' keyword?
What is the event type for GradientChanged? It could be something wrong somewhere else like you stated.
_eulogy_ wrote:
no2]
public GradientControl()
{
this.colorGradient = new ColorGradient();
this.colorGradient.GradientChanged += colorGradient_GradientChanged;
}
This is definately not going to work
_eulogy_ wrote:
[no3]
public GradientControl()
{
this.colorGradient = new ColorGradient();
this.colorGradient.GradientChanged += delegate(object sender, EventArgs e) { /*code*/ }
}
This might only work in C# 2.0, but I dont think you put the parameters for anonymous delegates in C# 2.0
-
Drew
|
|
|
|
|
The ColorGradient is a class I've made.. If I didn't mark GradientChanged with the event keyword I would get a compile time error. The gradient changed is an EventHandler (as you can see in no1)..
this.colorGradient.GradientChanged += colorGradient_GradientChanged;
works as hell... It's a new syntax..
this.colorGradient.GradientChanged += delegate(object sender, EventArgs e) { /*code*/ }
this also works as hell.. You have to put the parameters there, or else you can't access them!
I've found the problem though... It seems like it was caused by an inconsistency in how whidbey stores the gui objects created with the visual editor...
|
|
|
|
|
i got this Error when adding a component in my progect
"Failed to import the activeX control"
how can i solve this ?
|
|
|
|
|
I want to insert a hugh data table to oracle database. currently i use for loop to go throuh each row of table and use insert sql statement to insert row to oracle database.
Any one has ohter easy way to do this?
Thanks for help.
|
|
|
|
|
I have a string
str = "145.35" and want to convert it into a float value.
Float.Parse(str)
and the result is 14535.0
I tried some ways already but there must be a way to convert it correctly. Does anybody know a way out ?
|
|
|
|
|
You can always try Convert.ToSingle("145.35") ...
|
|
|
|
|
str is filled with an unknown value. 145.35 is an example only.
|
|
|
|
|
I was using "145.35" as an example as well. BTW, what is your locale? This does play a part into how the conversion routines try to to parse things. Is "." the decimal delimiter or the thousand delimiter for you?
ps. This does bring up an quirky point: Is Convert.ToSingle meant to be the IEEE supported float conversion while Single.Parse is the locale specific one?
|
|
|
|