|
yes it's System.Threading.Thread.Sleep , like posted above.
Vb:
<font color="blue">Public Function</font> TwinsOnWay(<font color="blue">ByVal</font> twins <font color="blue">As String</font>) <font color="blue">As String <br> Select Case</font> twins<br> <font color="blue">Case</font> "Gender" <br> <font color="blue">Return</font> "Two Girls" <br> <font color="blue">End Select <br> End Function</font> <br>
|
|
|
|
|
after i developed my application with C# i find a problem to distribute it, as i have to ask my clients to install the .net frame work
what i want is a tool or a way to make install wizard that install the .net frame work beside the required dll
can anyone help in that?
something like the package and deployment in VB or install shiled
eng.hany
|
|
|
|
|
VS.NET comes with a handy install creation wizard, you can create setup and deployment package using that. It has options to pull in the runtime on demand,it can also take output from other projects on the solution.
- Kannan
|
|
|
|
|
No it doesn't. The CLR merge module it has is only to satisfy dependencies with .NET Framework assemblies. This is clearly outlined in the .NET Framework SDK docs / MSDN. To do this, you need to write a bootstrapper (executable) that checks the necessary registry key and installs the framework before continuing the Windows Installer portion of your application (something I happen to know a lot about and follow closely).
Wise for Windows Installer (www.wisesolutions.com) did it right: the bootstrapper should also see if Windows Installer 2.0 is installed (the MSI runtime). Since it is required for .NET and the .NET installation requires Windows Installer 2.0 (makes sense, right?), your bootstrapper can merely check to see if .NET is installed. If it isn't, you need to install it anyway, which includes the Windows Installer 2.0. If MSI 2.0 is installed but not .NET, no harm done.
If you look in the framework SDK docs (in the TOC), there is a lengthy topic on deploying .NET with your application. The MSM that is meant only to satisfy dependencies (which is why it is marked as Ignore by default) and only includes assemblies - it does not include the CLR, Fusion, or anything else required for .NET to actually run!
Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN
|
|
|
|
|
Thanks for the clarification, I had thought the installer would take care of installing the runtime along with the application. I guess .Net or not installation is always going to be a pain. I will go through the docs. thanks again.
Cheers,
Kannan
|
|
|
|
|
|
I would like to know, if it is possible,or should I say feasible to have remoted window form..in the event I am being ambiguous I will explain..
Can I remote a Window form class so that a client can just connect to the remoted object and activate it, and run it on client side..so that virtually no code for that form is available on client side..other than perhaps an class interface for the remoted forms..I am sure with enough MarshalByRef or Serialization attributes, it is possible, but was not sure if it was possible?
Thanks for your time guys/gals
-Lucas
|
|
|
|
|
How do I make the form show spaces for a string that has spaces following the last character? For example: "ABCDE ". The label never shows the spaces after it. Thanks.
Ripsi
|
|
|
|
|
you wont see the space, because it's just a space , but you can check if there's a space at the end of the label very easily , eg:
VbCode:
<font color="blue">private</font> <font color="blue">void</font> button2_Click(<font color="blue">object</font> sender, System.EventArgs e) <br> { <br> label1.Text="sometext "; <br> } <br> <br> <font color="blue">private</font> <font color="blue">void</font> label1_Click(<font color="blue">object</font> sender, System.EventArgs e) <br> { <br> <font color="#0000FF">if</font>(label1.Text.EndsWith(" ")) <br> { <br> MessageBox.Show("found a space!"); <br> } <br> } <br>
Vb:
<font color="blue">Public Function</font> TwinsOnWay(<font color="blue">ByVal</font> twins <font color="blue">As String</font>) <font color="blue">As String <br> Select Case</font> twins<br> <font color="blue">Case</font> "Gender" <br> <font color="blue">Return</font> "Two Girls" <br> <font color="blue">End Select <br> End Function</font> <br>
|
|
|
|
|
I am trying to send a document (text/plain) to a server (.aspx page). I am always having a time-out (if I specify GET, I get a 404, as I expected).
When I look in the IIS log, I see the following:
2003-07-02 20:17:03 127.0.0.1 - 127.0.0.1 80 POST /Test/WebForm1.aspx - 500 87 -
This appears in the log whether or not the page exists on the server.
The 87 error means "The parameter is incorrect". I suspect that it has something to do with the Content-Length. Here is a code snippet I use to fill the HTTP stream with the document:
protected virtual void FillHttpStream(IDictionary pRequestParams, HttpWebRequest httpRequest)
{
string httpRequestDocument = (string)pRequestParams["RequestString"];
StreamWriter httpStreamWriter;
if ((httpRequestDocument == null) || (httpRequestDocument == String.Empty))
{
throw new Exception("No document to send");
}
httpRequest.Method = "POST";
httpRequest.ContentLength = httpRequestDocument.Length;
httpStreamWriter = new StreamWriter(httpRequest.GetRequestStream());
httpStreamWriter.Write(httpRequestDocument);
}
I should at least receive the 500 error code, but I time-out.
I could also use a tutorial on programmatically send a document via the HTTP POST method, if anyone know of any.
tx
|
|
|
|
|
I had to close the request stream
|
|
|
|
|
HI All,
I am trying to authenticate my username password using Advapi32.dll with function LogonUser. I am passing my Username and Password and domain and all things which need to pass in this function. But I am always getting false from this function. I am using windows 2000 Prof. and i have installed microsoft visual studio .net 2002 on my system.
One strainge thing is this exe is running on XP box very nicely. So any body tell me what could be the problem?
thanks,
Sharad
My code is:
-------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices; // DllImport
using System.Security.Principal; // WindowsImpersonationContext
using System.Security.Permissions; // PermissionSetAttribute
namespace Impersonate
{
// group type enum
public enum SECURITY_IMPERSONATION_LEVEL : int
{
SecurityAnonymous = 0,
SecurityIdentification = 1,
SecurityImpersonation = 2,
SecurityDelegation = 3
}
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
// obtains user token
[DllImport("advapi32.dll", SetLastError=true)]
public static extern bool LogonUser(string pszUsername, string pszDomain, string pszPassword,
int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
// closes open handes returned by LogonUser
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
public extern static bool CloseHandle(IntPtr handle);
// creates duplicate token handle
[DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public extern static bool DuplicateToken(IntPtr ExistingTokenHandle,
int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle);
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lblCurrentUser;
private System.Windows.Forms.TextBox textBoxUsername;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBoxPassword;
private System.Windows.Forms.Button buttonLogon;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBoxDomain;
private System.Security.Principal.WindowsIdentity newwinid;
private System.Security.Principal.WindowsImpersonationContext newUser;
private System.Windows.Forms.Button buttonRevert;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
// set logged on username
lblCurrentUser.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
// populate logon domain name
string sTempUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
if (sTempUser.IndexOf("\\") != -1)
{
string[] aryUser = new String[2];
char[] splitter = {'\\'};
aryUser = sTempUser.Split(splitter);
textBoxDomain.Text = aryUser[0];
}
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.lblCurrentUser = new System.Windows.Forms.Label();
this.textBoxUsername = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.textBoxPassword = new System.Windows.Forms.TextBox();
this.buttonLogon = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.textBoxDomain = new System.Windows.Forms.TextBox();
this.buttonRevert = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Running As:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// lblCurrentUser
//
this.lblCurrentUser.Location = new System.Drawing.Point(112, 24);
this.lblCurrentUser.Name = "lblCurrentUser";
this.lblCurrentUser.Size = new System.Drawing.Size(200, 16);
this.lblCurrentUser.TabIndex = 1;
//
// textBoxUsername
//
this.textBoxUsername.Location = new System.Drawing.Point(112, 80);
this.textBoxUsername.Name = "textBoxUsername";
this.textBoxUsername.Size = new System.Drawing.Size(144, 20);
this.textBoxUsername.TabIndex = 2;
this.textBoxUsername.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 80);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(88, 16);
this.label2.TabIndex = 3;
this.label2.Text = "New Username:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 104);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(88, 16);
this.label3.TabIndex = 5;
this.label3.Text = "New Password:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// textBoxPassword
//
this.textBoxPassword.Location = new System.Drawing.Point(112, 104);
this.textBoxPassword.Name = "textBoxPassword";
this.textBoxPassword.PasswordChar = '*';
this.textBoxPassword.Size = new System.Drawing.Size(144, 20);
this.textBoxPassword.TabIndex = 4;
this.textBoxPassword.Text = "";
//
// buttonLogon
//
this.buttonLogon.Location = new System.Drawing.Point(181, 136);
this.buttonLogon.Name = "buttonLogon";
this.buttonLogon.TabIndex = 6;
this.buttonLogon.Text = "Logon";
this.buttonLogon.Click += new System.EventHandler(this.buttonLogon_Click);
//
// label4
//
this.label4.Location = new System.Drawing.Point(16, 56);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(88, 16);
this.label4.TabIndex = 8;
this.label4.Text = "Logon Domain:";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// textBoxDomain
//
this.textBoxDomain.Location = new System.Drawing.Point(112, 56);
this.textBoxDomain.Name = "textBoxDomain";
this.textBoxDomain.Size = new System.Drawing.Size(144, 20);
this.textBoxDomain.TabIndex = 7;
this.textBoxDomain.Text = "";
//
// buttonRevert
//
this.buttonRevert.Enabled = false;
this.buttonRevert.Location = new System.Drawing.Point(104, 136);
this.buttonRevert.Name = "buttonRevert";
this.buttonRevert.TabIndex = 9;
this.buttonRevert.Text = "Revert";
this.buttonRevert.Click += new System.EventHandler(this.buttonRevert_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(312, 189);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.buttonRevert,
this.label4,
this.textBoxDomain,
this.buttonLogon,
this.label3,
this.textBoxPassword,
this.label2,
this.textBoxUsername,
this.lblCurrentUser,
this.label1});
this.MaximizeBox = false;
this.Name = "Form1";
this.Text = "Impersonation Example";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void buttonLogon_Click(object sender, System.EventArgs e)
{
if (textBoxUsername.Text != "" && textBoxPassword.Text != "")
{
try
{
// attempt to impersonate specified user
newUser = this.ImpersonateUser(textBoxUsername.Text, textBoxDomain.Text, textBoxPassword.Text);
// update the running as name
lblCurrentUser.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
buttonRevert.Enabled = true;
buttonLogon.Enabled = false;
}
catch (Exception ex)
{
// why did it fail?
MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
MessageBox.Show(this, "Complete all the logon credentials", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
///
/// Revert back to previous user
///
private void buttonRevert_Click(object sender, System.EventArgs e)
{
// revert to previous user
newUser.Undo();
buttonRevert.Enabled = false;
buttonLogon.Enabled = true;
// update the running as name
lblCurrentUser.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
}
///
/// Attempts to impersonate a user. If successful, returns
/// a WindowsImpersonationContext of the new users identity.
///
/// <param name="sUsername" />Username you want to impersonate
/// <param name="sDomain" />Logon domain
/// <param name="sPassword" />User's password to logon with
/// <returns>
public WindowsImpersonationContext ImpersonateUser(string sUsername, string sDomain, string sPassword)
{
// initialize tokens
IntPtr pExistingTokenHandle = new IntPtr(0);
IntPtr pDuplicateTokenHandle = new IntPtr(0);
pExistingTokenHandle = IntPtr.Zero;
pDuplicateTokenHandle = IntPtr.Zero;
// if domain name was blank, assume local machine
if (sDomain == "")
sDomain = System.Environment.MachineName;
try
{
string sResult = null;
const int LOGON32_PROVIDER_WINNT50 = 2;
// create token
const int LOGON32_LOGON_NEW_CREDENTIALS = 4;
//const int SecurityImpersonation = 2;
// get handle to token
bool bImpersonated = LogonUser(sUsername, sDomain, sPassword,
LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_WINNT50, ref pExistingTokenHandle);
// did impersonation fail?
if (false == bImpersonated)
{
int nErrorCode = Marshal.GetLastWin32Error();
sResult = "LogonUser() failed with error code: " + nErrorCode + "\r\n";
// show the reason why LogonUser failed
MessageBox.Show(this, sResult, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
// Get identity before impersonation
sResult += "Before impersonation: " + WindowsIdentity.GetCurrent().Name + "\r\n";
bool bRetVal = DuplicateToken(pExistingTokenHandle, (int)SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation, ref pDuplicateTokenHandle);
// did DuplicateToken fail?
if (false == bRetVal)
{
int nErrorCode = Marshal.GetLastWin32Error();
CloseHandle(pExistingTokenHandle); // close existing handle
sResult += "DuplicateToken() failed with error code: " + nErrorCode + "\r\n";
// show the reason why DuplicateToken failed
MessageBox.Show(this, sResult, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
else
{
// create new identity using new primary token
WindowsIdentity newId = new WindowsIdentity(pDuplicateTokenHandle);
WindowsImpersonationContext impersonatedUser = newId.Impersonate();
// check the identity after impersonation
sResult += "After impersonation: " + WindowsIdentity.GetCurrent().Name + "\r\n";
MessageBox.Show(this, sResult, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
return impersonatedUser;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
// close handle(s)
if (pExistingTokenHandle != IntPtr.Zero)
CloseHandle(pExistingTokenHandle);
if (pDuplicateTokenHandle != IntPtr.Zero)
CloseHandle(pDuplicateTokenHandle);
}
}
}
}
|
|
|
|
|
Hi,
Actully I'm facing the same problem you've got! I think the domain paramter must take the name of the PC the file is in, not the name of domain or DC. This has nothing to do with Server! it's about connecting to a file in a PC, I thinks this is it!!
If you found the solution for that please send me it:
rami@raypub.com
|
|
|
|
|
Hi,
did you get a solution for this issue?
Jassim Rahma
|
|
|
|
|
No, not yet...
I'm using know a very stupid way: net.exe!!
|
|
|
|
|
I'm use an OleDbDataReader variable for get data from OLAP cube. I want show this data to DataGrid control, but I don't know a way. Can you help me?
Thanks.
|
|
|
|
|
here's an example of adding data from a database to a datagrid ( using an OleDbConnection )
VbCode:
<font color="blue">Private</font> <font color="blue">Sub</font> Button1_Click(<font color="blue">ByVal</font> sender <font color="blue">As</font> System.Object, <font color="blue">ByVal</font> e <font color="blue">As</font> System.EventArgs) <font color="blue">Handles</font> Button1.Click <br> <font color="blue">Dim</font> strConnection <font color="blue">As</font> <font color="blue">String</font> = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:/bin.mdb" <br> <font color="blue">Dim</font> strCommand <font color="blue">As</font> <font color="blue">String</font> = "SELECT * FROM binFrm" <br> OpenAccess(strConnection, strCommand) <br> <font color="blue">End</font> <font color="blue">Sub</font> <br> <br> <font color="blue">Public</font> <font color="blue">Function</font> OpenAccess(<font color="blue">ByVal</font> strConn <font color="blue">As</font> <font color="blue">String</font>, <font color="blue">ByVal</font> strComm <font color="blue">As</font> <font color="blue">String</font>) <br> <font color="blue">Dim</font> DBCon <font color="blue">As</font> <font color="blue">New</font> OleDbConnection(strConn) <br> DBCon.Open() <br> <font color="blue">Dim</font> DBCommand <font color="blue">As</font> <font color="blue">New</font> OleDbCommand(strComm, DBCon) <br> <font color="blue">Dim</font> DBAdapt <font color="blue">As</font> OleDbDataAdapter <font color="DarkGreen"><br></font> DBAdapt = <font color="blue">New</font> OleDbDataAdapter(DBCommand) <br> <font color="blue">Dim</font> DBset <font color="blue">As</font> <font color="blue">New</font> DataSet() <br> DBAdapt.Fill(DBset, "binFrm") <br> DataGrid1.DataSource = DBset.Tables("binFrm") <font color="DarkGreen">'///add the tabel "binfrm" to the datagrid <br></font> DBCon.Close() <br> DBCommand.Dispose() <br> DBAdapt.Dispose() <br> DBset.Dispose() <br> <font color="blue">End</font> <font color="blue">Function</font> <br>
not sure if that's what your after , but hope it helps
Vb:
<font color="blue">Public Function</font> TwinsOnWay(<font color="blue">ByVal</font> twins <font color="blue">As String</font>) <font color="blue">As String <br> Select Case</font> twins<br> <font color="blue">Case</font> "Gender" <br> <font color="blue">Return</font> "Two Girls" <br> <font color="blue">End Select <br> End Function</font> <br>
|
|
|
|
|
oops that the vb.net version lol , i'll try to bung a C# version together
Vb:
<font color="blue">Public Function</font> TwinsOnWay(<font color="blue">ByVal</font> twins <font color="blue">As String</font>) <font color="blue">As String <br> Select Case</font> twins<br> <font color="blue">Case</font> "Gender" <br> <font color="blue">Return</font> "Two Girls" <br> <font color="blue">End Select <br> End Function</font> <br>
|
|
|
|
|
here ya go , this time in C# lol , hope it helps
VbCode:
<font color="#0000FF">private</font> <font color="blue">void</font> button1_Click(<font color="blue">object</font> sender, System.EventArgs e) <br> { <br> <font color="#0000FF">string</font> strConnection="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "C:/bin.mdb"; <br> <font color="#0000FF">string</font> strCommand = "SELECT * FROM binFrm"; <br> OpenAccess(strConnection, strCommand); <br> } <br> <br> <font color="#0000FF">public</font> <font color="blue">void</font> OpenAccess(<font color="#0000FF">string</font> Connection, <font color="#0000FF">string</font> Command) <br> { <br> OleDbConnection DBCon=<font color="#0000FF">new </font>OleDbConnection(Connection); <br> DBCon.Open(); <br> OleDbCommand DBCommand=<font color="#0000FF">new</font> OleDbCommand(Command, DBCon); <br> OleDbDataAdapter DBAdapt=<font color="#0000FF">new</font> OleDbDataAdapter(DBCommand); <br> DataSet DBset=<font color="#0000FF">new</font> DataSet(); <br> DBAdapt.Fill(DBset, "binFrm"); <br> dataGrid1.DataSource=DBset.Tables["binFrm"]; <br> DBCon.Close(); <br> DBCommand.Dispose(); <br> DBAdapt.Dispose(); <br> DBset.Dispose(); <br> <br> } <br>
Vb:
<font color="blue">Public Function</font> TwinsOnWay(<font color="blue">ByVal</font> twins <font color="blue">As String</font>) <font color="blue">As String <br> Select Case</font> twins<br> <font color="blue">Case</font> "Gender" <br> <font color="blue">Return</font> "Two Girls" <br> <font color="blue">End Select <br> End Function</font> <br>
|
|
|
|
|
Hoang Dung, the following is not the best code on the globe but hope it gives you some ideas.
// construct table for Tasks grid and define columns
m_dtTasks = new DataTable("Tasks");
m_dtTasks.Columns.Add("Task Name", typeof(string));
m_dtTasks.Columns.Add("Frame Maker Location", typeof(string));
m_dtTasks.Columns.Add("Approved", typeof(string));
m_dtTasks.Columns.Add("Approval Cycle", typeof(string));
OleDbCommand cmd = new OleDbCommand(sSelectQuery, conn); // have yr query & connection ready
OleDbDataReader reader = cmd.ExecuteReader(); // DataReader is now loaded with data
while(reader.Read())
{
nNumRowsAffected++;
Console.WriteLine("TaskName = " + reader.GetString(0));
sTaskName = reader.GetString(0); // TaskName
sFrameMakerLoc = reader.GetString(3); // FrameMakerLocation
sApproved = (reader.GetBoolean(11) ? "Y" : "N"); // Status
sApprovalCycle = reader.GetString(12); // Approval_Cycle
// construct a new data row
drTask = dtTasks.NewRow();
drTask["Task Name"] = sTaskName;
drTask["Frame Maker Location"] = sFrameMakerLoc;
drTask["Approved"] = sApproved;
drTask["Approval Cycle"] = sApprovalCycle;
// add new row to table
dtTasks.Rows.Add(drTask);
}
dgdTask.DataSource = dtTasks; // attach data source to grid
Hope it helps
Khang Nguyen
|
|
|
|
|
Class A
{
public event MyEventHandler DataChanged(A myClassA);
....
}
Class B:A
{
...
//Raising the DataChanged event in this child class leads to error saying
//DataChanged can only be on lefthand side of += or -=
DataChanged(this);
}
The problem I am encountering right now is my inability to raise the
DataChanged event within the child class (leads me to believe event
inheritance is not present in c# yet?). I remember reading VB.NET is
capable of event inheritance though.
Is there a nice work around to problem?
Thanks .
|
|
|
|
|
Normally how things are done is:
<font color="#008800">
public delegate void MyEventHandler(object sender, EventArgs e);
<font color="#008800">
Class A
{
<font color="#008800">
public event MyEventHandler DataChanged;
<font color="#008800">
protected void OnDataChanged(EventArgs e)
{
if(ElementMouseUp !=null)
ElementMouseUp(this, e);
}
....
}
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hello,
I want to add Items (string-Variables) to a Combobox.
But running the application, a NullReferenceException is thrown.
"The Object is not set to an instance of an object" (something like this, I've the german SDK, sorry)
I fill the Combobox in the constructor of an selfmade Dialog:
public dlg_clickedOrtAuswahl(string[] liste, int anzahl)
{
for (int i = 0; i < anzahl; i++)
{
//filling the Combobox cb_Auswahl
this.cb_Auswahl.Items.add (liste[i]);
}
InitializeComponent();
}
What could be wrong?
I've tried it with a HashTable, but the same error accours, binding the hashtable to the combobox with cb_Auswahl.DataSource = myHashtable.
Thanks a lot, for your help.
Greetings
Torsch
|
|
|
|
|
The combobox is created in the InitializeComponent method, so you can't use it until after that method has been called.
Also, I assume anzahl is the length of the array; you could also use liste.Length .
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
That there is no such thing as a "BitmapButton" class in .NET? Something that displays a bitmap but acts like a button--up, down, mouse over, has focus, ALT-[x] functionality?
Please, someone tell me I'm wrong.
(And don't point me to Button's Image member, because it doesn't work when using a manifest--no bitmap appears--and it the ImageAlign property does work right--bottom is top, and vice versa, left is right, and center doesn't).
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|