|
I actually tried that exact method with no luck, don't know why. Thanks for the idea though...
|
|
|
|
|
Hello everyone,
I want to implement a Font Bar(not FontDialog) like this,
______
B I U S
-------
Is there any ready-made control class in .net FCL? If not, how to realize it?
welspring
hope for help
|
|
|
|
|
There is no such ready-made control class in .NET base classes. However, you can use a toolbar in your project alongwith an ImageList control(in which I suppose that you might be implementing the RichTextBox control for showing bold, italics characters, etc.). After adding the imageList and toolbar, add different images in the Images property of the ImageList in its properties window in the designer. As a part of these images, you can supply your own images for "Bold", "Italics", etc. Now, select the toolbar in designer and go to its property window. Select the "ImageList" property of the toolbar and assign the value of the instance of the ImageList control added to your project. Now go to 'Buttons' property of toolbar and click on the Collection "..." button to add your buttons. While adding buttons, select the appropriate ImageIndex (which will link a particular image from the aforesaid ImageList to a particular button). Now you can add an event-handler for the "ButtonClick" event of the toolbar wherein you can provide code for linking these buttons with the formatting of the RichTextBox, such as italics, etc.
|
|
|
|
|
Why is the windows datagrid SO uncooperative (not my real question, I just couldn't resist). I need to create a datagrid column containing a pair of radiobuttons per cell. I can find plenty of examples that create a column that shows ONE control that shows up only when the cell is selected, but I want mine to show all the time (two radiobuttons visible in EACH row in the column).
If anyone could give me a clue about this I would really appreciate it.
thanks!
Deanna
|
|
|
|
|
Hi Deanna,
For displaying 2 radio buttons you can create a custom user control that has 2 radio buttons and use it in the data grid.
DataGridTextBoxColumn column1 =(DataGridTextBoxColumn)dataGrid1.TableStyles[0].GridColumnStyles[0];
column1.TextBox.Controls.Add(new WindowsControlLibrary1.UserControl1());
Thanks and Regards
SGS
|
|
|
|
|
I could, but normally doesn't that code go in the 'Edit' method of the column and only display the control when someone clicks the cell? I want them to display all the time.
If there's somewhere else I can put the code for my desired effect, please let me know.
thanks,
Deanna
|
|
|
|
|
Is there a way to define maximum length of value for specific column directly in DataSet (*.xsd file)? I would use this for setting value of MaxLength property of TextBox for example...
Any ideas?
|
|
|
|
|
I've been working hard trying to get a remoted version of the Windows MediaPlayer to work with C#. I've seen some references to other projects that have succeeded in part:
http://blogs.msdn.com/ericgu/archive/2004/09/01/224147.aspx
I've tried using the project referenced there, and it sort of almost works. I get strange assertion errors at startup and at shutdown. Also, if I then deploy my application along with the remote player libraries onto another machine, it won't run at all. I have to actually install VS C++ *and* build on the target machine for it to work. It seems as if this project is set up more for WMP 9 than 10.
The assertion I've seen at startup says:
ATLASSERT(!InlineIsEqualGUID(*m_plibid,GUID_NULL) && "Did you forget to pass the LIBID to CComModule::Init?");
I've seen the following reference to this general problem, which has to do with ATL incompatibilities:
http://userpages.umbc.edu/~bcorfm1/wtl.html
So, although I can modify the VS C++ project to link dynamically to the ATL library, I still have the problem that I can't deploy my application on other machines (it just crashes, and complains about the wmppia.dll file and/or throws the same assertions). Even after changing the ATL linking, I get an assertion when I close my application. It says "Debug Assertion Failed! File: wincore.cpp, Line: 1002."
I'm definitely a C++ novice, so I don't really know how to create a true interop solution for my C# project, so that I can have the full remoted Windows MediaPlayer object. We actually want to use it in docked mode constantly, so that the full Windows MediaPlayer application is not running visibly.
I've also seen this reference:
http://blogs.msdn.com/ericgu/archive/2004/08/13/214434.aspx
So, I know that there are people out there who have succeeded in getting this to work, apparently in something as simple as 100 lines of C++ code in a header file.
Any pointers?
dk
|
|
|
|
|
Hi All,
I hope that this isn't a terribly obvious question, but here goes. I've created a typed dataset using the dataset tool in Visual Studio .NET. I'm pretty mpressed with the results, but I'd like to be able to stick the picture of the dataset into a word document. Short of printscreen, I don't see how to do this.
Anyone have any ideas? Are there any tools to create a metafile, or something similar from the .xsd and .xsx files?
Thanks
|
|
|
|
|
I understand that we need to draw hotspots around a control and then check to see if the spots are clicked... then we can resize the control accordingly.
now my concern here is what to use as a hotspot? because if I just use the Graphics.DrawRectangle, then I cant assign handle-events to the rectangles I draw.
Thank you so much for your help.
Elapid For The Win
|
|
|
|
|
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?
|
|
|
|
|