|
I would add one more comment:
Make myVariable a property - that way you can refactor the call to ValueUpdated() in the property's set() method.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Yes, abosolutely!
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
|
|
|
|
|
Is there a terribly convincing reason for the Framework rule to declare event delegates as (object sender, EventArgs e) ?
We say "get a life" to each other, disappointed or jokingly. What we forget, though, is that this is possibly the most destructive advice you can give to a geek.
boost your code || Fold With Us! || sighist
|
|
|
|
|
peterchen wrote: Is there a terribly convincing reason for the Framework rule to declare event delegates as (object sender, EventArgs e) ?
I believe that the reason is this:
Most framework controls store their events on an array-like structure when they are used, to decrease their memory size. Since those controls have *lots* of events, and tipically, only a few are actually used by an application, the framework can reduce the memory use by a few KB and even a few MB in a large application by not declaring fields for storing all of them.
Since the events are to be added/removed on an array for *each* event, someone probably needed to code some kind of generic code for dealing with this management.
This probably lead to creating a single delegate to ease things.
Not a pretty solution, but very efficient.
I don't see dead pixels anymore...
Yes, even I am blogging now!
|
|
|
|
|
Hey all, I have a custom collection of controls that I have built that do data validation and all that stuff internally and I want to use an ErrorProvider to alert the user to any validation errors. Now, instead of creating and using one ErrorProvider per control I put on a form, I would rather use just the one ErrorProvider put on the form.
At runtime, I was hoping to be able to search through the form's components or something to that effect and find the ErrorProvider myself. This way, any control I put on a form would automatically 'discover' the ErrorProvider on the form if it is present. I can't seem to find a way to do this however. In the control, properties such as "this.Container" or "this.FindForm().Container" or "this.FindForm().Site" are all null, and they seem to me to be the only paths to the components collection i'm looking for.
I don't know if this is possible. Any help or insight would be greatly appreciated.
|
|
|
|
|
Hello,
I need to read the contents of the .pdf file thru my application in C# and get the contents of the file.
I'm getting lots of links for creating .pdf files thru C#.
Also, I need to know about how difficult it is build the pdf parser for reading the contents???
Regards
Abhishek
|
|
|
|
|
I'm currently in the middle of a pdf project, and have found that this http://itextsharp.sourceforge.net/ does everything that I could possibly need, including reading/filling out form fields forms and whatnot. Not very tricky at all, as the clever blokes who wrote it have already figured it out. Hope that helps...
|
|
|
|
|
Hello,
I have a C# program I'm working on, and I finally got over a large hurdle, only to encounter the next. I finally am able to display an image in my form (Working on a PocketPC), as well as other info that is located in an XML file.
The problem is, is that I think the SelectedItem Property isn't syncing with the rest of the items....
Could someone tell me where i'm going wrong? I'd really appreciate input.
Here it goes:
<br />
xmlFileName = "\\Program Files\\SmartDeviceApplication1\\fragenkatalog.xml";<br />
xsdFileName = "\\Program Files\\SmartDeviceApplication1\\fragenkatalog.xsd";<br />
FileStream FsXML = new FileStream(xmlFileName,FileMode.Open);<br />
FileStream FsXSD = new FileStream(xsdFileName,FileMode.Open);<br />
<br />
<br />
XmlTextReader xtrXSD = new XmlTextReader(FsXSD);<br />
fragenkatalogDS.ReadXmlSchema(xtrXSD);<br />
xtrXSD.Close();<br />
FsXSD.Close();<br />
<br />
XmlTextReader xtrXML = new XmlTextReader(FsXML);<br />
fragenkatalogDS.ReadXml(xtrXML);<br />
xtrXML.Close();<br />
FsXML.Close();<br />
<br />
DataTable dt = fragenkatalogDS.Tables["fragenkatalog"];<br />
<br />
ca_id.DataSource = dt;<br />
ca_id.DisplayMember = "ca_titel";<br />
string root = "\\Program Files\\SmartDeviceApplication1\\";<br />
DataRowView drv = (DataRowView)ca_id.SelectedItem;<br />
<br />
ca_bildurl.Image = new Bitmap(System.IO.Path.Combine(root,drv.Row["ca_bildurl1"].ToString()));<br />
ca_titel.DataBindings.Add("Text",dt,"ca_titel");<br />
ca_alter.DataBindings.Add("Text",dt,"ca_alter");<br />
ca_sex.DataBindings.Add("Text",dt,"ca_sex");<br />
burl.DataBindings.Add("Text",dt,"ca_bildurl1");<br />
<br />
}
The problem I've been having (I think) is with this line:
DataRowView drv = (DataRowView)ca_id.SelectedItem;
It seems as though it's not displaying any other image other than the first one in the database. Any ideas?
Thanks a million!
Martina
|
|
|
|
|
need more code...
if your seeing the same result without a crash your probably acessing the parent object in your heirarchy. what control is ca_id ?
|
|
|
|
|
Here's my XML code:
<fragenkatalog>
<ca_id >4</ ca_id>
<ca_titel>head ap</ca_titel>
<ca_bildurl1>kopf_ap.jpg</ca_bildurl1>
<ca_disabled>0</ca_disabled>
<ca_alter>999</ca_alter>
<ca_sex>n</ca_sex>
</fragenkatalog>
And the cs code
public ADONETDataBinding()
{
InitializeComponent();
fragenkatalogDS = new DataSet();
fragenkatalogDS.Locale = CultureInfo.CurrentCulture;string xmlFileName;
xmlFileName = "\\Program Files\\SmartDeviceApplication1\\fragenkatalog.xml";
xsdFileName = "\\Program Files\\SmartDeviceApplication1\\fragenkatalog.xsd";
FileStream FsXML = new FileStream(xmlFileName,FileMode.Open);
FileStream FsXSD = new FileStream(xsdFileName,FileMode.Open);
XmlTextReader xtrXSD = new XmlTextReader(FsXSD);
fragenkatalogDS.ReadXmlSchema(xtrXSD);
xtrXSD.Close();
FsXSD.Close();
XmlTextReader xtrXML = new XmlTextReader(FsXML);
fragenkatalogDS.ReadXml(xtrXML);
xtrXML.Close();
FsXML.Close();
DataTable dt = fragenkatalogDS.Tables["fragenkatalog"];
ca_id.DataSource = dt;
ca_id.DisplayMember = "ca_titel";
string root = "\\Program Files\\SmartDeviceApplication1\\";
DataRowView drv = (DataRowView)ca_id.SelectedItem;
ca_bildurl.Image = new Bitmap(System.IO.Path.Combine(root,drv.Row["ca_bildurl1"].ToString()));
ca_titel.DataBindings.Add("Text",dt,"ca_titel");
ca_alter.DataBindings.Add("Text",dt,"ca_alter");
ca_sex.DataBindings.Add("Text",dt,"ca_sex");
burl.DataBindings.Add("Text",dt,"ca_bildurl1");
}
/// <summary>
///
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
Thanks again!
|
|
|
|
|
As a side note, (for what it's worth)
If I remove the 1st image listed (kopf.jpg) from the directory (i.e. I delete the jpg file), the whole program doesn't work. :S
|
|
|
|
|
I'm thinking about writing a simple alarm clock for myself so I've just been doing some research looking at how some other ones have been desinged and most programs I've looked at use a timer to check if an alarm time has been hit. I'm just wondering if this is the best way to do it or if there is another way that would accomplish the same thing.
Thanks for the information.
- Aaron
|
|
|
|
|
monrobot13 wrote: use a timer to check if an alarm time has been hit
That seems about right. You could get by with a single (reasonably high resolution - eg: < 1 Sec.) timer or one timer per alarm (assuming you can have multiple alarms). A single timer is of course less resource intensive.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Thanks very much for the info.
- Aaron
|
|
|
|
|
I have large child panel control Im using for a direct3D render engine. I want to use the balloon tooltip when they mouse over XY locations on the child panel. I want to use the popup event already in the ToolTip control to check whether their over an acutual item or not.. if not.. bail out...
my problem is.. the ToolTip only shows up once... popup only gets called once.. im not surprised because its one big control and Im still within its bounds.. but is there anyway around this?
|
|
|
|
|
I need create in code file, some code for read text file, that contain a string of connection of my database like that
Data Source=(local);Initial Catalog=IUSA;Integrated Security=True
and put that string in a public variable for use in all the project, but i need some idea about that, because in vb.net, i used that, how can do that in C#
Module CONECTA
Public cadenaconexion As String
Public pcodpro As String
Public pcodcli As String
Public pnomcli As String
Public pprecio As String
Public pexipro As String
Public tb As New TabControl
Public P2 As New Collection
Public tcodpro As TextBox
Public cndb As New SqlClient.SqlConnection
Public cndb1 As New SqlClient.SqlConnection
Public cndb2 As New SqlClient.SqlConnection
Public usuario As String
Public fechafactura As String
Public tdoc As String
Public PrmPathExcelFile As String
Public consultaclientes As INQCUSTOMER
Public consulta As PRODIQ1
Public factura As MTTOFAC
Public fmtfecha As FMTDATE
Sub main()
Dim myStreamReader As System.IO.StreamReader
Dim myInputString As String
Try
myStreamReader = System.IO.File.OpenText("C:\SQLCONECTA.TXT")
myInputString = myStreamReader.ReadLine()
Catch exc As Exception
MsgBox("Archivo de Conexion no se Puede Abrir o no Existe." + vbCrLf + _
"Por favor Verifique Que el Archivo Este Bien, " + _
vbCrLf + "Exception: " + exc.Message)
Finally
If Not myStreamReader Is Nothing Then
myStreamReader.Close()
End If
End Try
cadenaconexion = myInputString
cndb.ConnectionString = cadenaconexion
cndb1.ConnectionString = cadenaconexion
cndb2.ConnectionString = cadenaconexion
Dim ACCESO1 As New ACCESO
ACCESO1.ShowDialog()
End Sub
End Module
|
|
|
|
|
Just do it the same way. The framework is still the same, so the System.IO namespace still works exactly the same.
---
b { font-weight: normal; }
|
|
|
|
|
Out of curiosity, why are you using a module in the first place? For an object that you only want one instance of, check out the singleton design pattern. It is much more elegant than global variables or global functions (like what this module is doing essentially).
Check out singleton pattern on this site or on Google.
Another good option that most enterprise applications use is storing database connection information in a config file. .NET comes with app.config which can be used through the System.Configuration classes. You can also wrap your own with an XmlReader.
Andrew Peters, MCSD
Fabrefactum Software
|
|
|
|
|
You have, some example for that ???
|
|
|
|
|
this seems easy but I just got stuck
I just wanna display an error message if the textBox is left empty, and display another error Message if the entry is not an integer.
I used the if statement (if var=="")
MessageBox.Show(" you must enter anumber")
but it gives me an error message everytime I try to compile ...Help please
aPerfectTool
|
|
|
|
|
int nFoo = 0;
string strFoo = myTextBox.Text.Trim();
if (strFoo.Equals (String.Empty)) {
<code>
...
} else {
try {
nFoo = int.Parse (strFoo);
} catch (Exception) {
<code>
...
}
}
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
hey ravi thanks for your quick response,
I'm still having the same problem, when i run the code, it always do the try and catch first with leaves me with only one error message<invalid data="" entered="">
if I leave the textBox empty the program just bomb on me !!!!???
aPerfectTool
|
|
|
|
|
aPerfectCircle wrote: the program just bomb on me
I'm not sure I understand. Please post your button's click handler code.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
hey Ravi I just got it working thanks for your help
aPerfectTool
|
|
|
|
|