|
This is what I am trying to do:
Public Class MainForm
Private Split As SplitContainer = Nothing
Public Shadows Property IsMdiContainer() As Boolean
Get
Return (Split IsNot Nothing)
End Get
Set(ByVal value As Boolean)
If value Then
If Split Is Nothing Then
Split = New SplitContainer
Split.Dock = DockStyle.Fill
Split.Panel1.BackColor = Color.Aqua
Split.Panel2.BackColor = Color.Wheat
Me.Controls.Add(Split)
End If
Else
If Split IsNot Nothing Then
Me.Controls.Remove(Split)
Split = Nothing
End If
End If
Me.Invalidate()
End Set
End Property
End Class With this code, I should be adding and removing a SplitContainer to my form instead of an MdiClient control. When I set IsMdiContainer in the Properties panel, however, my code is never run and the framework adds the MdiClient . If I can get this running, I believe I can create a custom Mdi set-up that allows for the parent form to have a sizable sidebar.
What am I doing wrong?
|
|
|
|
|
TechBearSeattle wrote: When I set IsMdiContainer in the Properties panel, however, my code is never run and the framework adds the MdiClient.
That is because the designer knows nothing about your class or your implimentation of IsMdiContainer. It calls the original code as Shaddowing is not the same as Overriding. It is important to know the difference.
I've got a blog post explaining the difference with the examples in C#. All you need to remember is that
* virtual = Overridable
* override = Overrides
* new = Shaddows
Method shaddowing Vs. Overloading[^] (in VB parlons)
|
|
|
|
|
That is not quite the answer I wanted; I was using Shadows because IsMdiContainer is not overridable. But it did point me to a workaround.
Basically, I have to create a base form that has the property IsMyMdiContainer , then set the mdi form to inherit from that. This is the only way I can get the property to show up in the Properties window for some reason; apparently the IDE (in Visual Basic, at least) looks to the parent class and not the class itself. Then I use the new property rather than the old one. Not as drop-in-and-go as I would have liked, but it works.
Thanks for the answer.
Oh, and great examples in your blog entry
|
|
|
|
|
Hello evryone,
When i m build my projcet. that is successfully build but when i m debuging they give me this exception . i dont know why. please help me . i did not solved my problem.
what is the meaning of this Excetion. please help me .
Code......
using System;
using System.Xml.XPath;
using System.Data.SqlClient;
using System.Data;
using System.Xml;
using System.Xml.Xsl;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
namespace DatabaseLayer
{
public class DatabaseLayer
{
private MySqlConnection _connection = null;
private string _connectionString = string.Empty;
public string ConnectionString
{
set { _connectionString = value; }
get { return _connectionString; }
}
public DatabaseLayer()
{
//
// TODO: Add constructor logic here
//
}
public bool OpenConnection()
{
ValidateConnectionString();
_connection = new MySqlConnection();
_connection.ConnectionString = _connectionString;
string exx;
try
{
_connection.Open();
}
catch (Exception ex)
{
exx = ex.Message;
_connection = null;
return false;
}
return true;
}
public bool CloseConnection()
{
bool result = true;
try
{
if (_connection.State == ConnectionState.Open)
{
_connection.Close();
}
}
catch
{
result = false;
}
finally
{
_connection = null;
}
return result;
}
public void ValidateConnectionString()
{
if (0 == _connectionString.Length)
{
throw new Exception("No connection string has been supplied");
}
}
public int ExecuteNonQuery(string storedProcedure, MySqlParameter[] parameterArray, MySqlParameter outputParam)
{
int result;
MySqlCommand comm = null;
string msg;
result = 0;
try
{
//ValidateConnectionString();
//conn = new SqlConnection();
//conn.ConnectionString = _connectionString;
comm = _connection.CreateCommand();
//conn.Open();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
outputParam.Direction = ParameterDirection.Output;
comm.Parameters.Add(parameterArray);
result = comm.ExecuteNonQuery();
result = int.Parse(outputParam.Value.ToString());
}
catch (SqlException ex)
{
msg = ex.Message;
}
finally
{
comm = null;
}
// result = SqlHelper.ExecuteNonQuery(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);
return result;
}
public int ExecuteNonQuery(string storedProcedure, MySqlParameter[] parameterArray)
{
int result;
MySqlCommand comm = null;
string msg;
result = 0;
try
{
//ValidateConnectionString();
//conn = new SqlConnection();
//conn.ConnectionString = _connectionString;
comm = _connection.CreateCommand();
//conn.Open();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
result = comm.ExecuteNonQuery();
}
Eror on this line// catch (Exception ex)
{
and there also erro// msg = ex.Message;
}
finally
{
comm = null;
}
// result = SqlHelper.ExecuteNonQuery(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);
return result;
}
public object ExecuteScalar(string storedProcedure, MySqlParameter[] parameterArray)
{
object result;
MySqlCommand comm = null;
string msg;
try
{
comm = _connection.CreateCommand();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
result = comm.ExecuteScalar();
}
// catch (Exception ex)
// {
// msg = ex.Message;
// }
finally
{
comm = null;
}
//ValidateConnectionString();
//result = SqlHelper.ExecuteScalar(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);
return result;
}
public DataSet ExecuteDataSet(string storedProcedure, MySqlParameter[] parameterArray)
{
DataSet result = new DataSet();
string msg;
MySqlDataAdapter da = null;
da = new MySqlDataAdapter();
MySqlCommand comm = null;
try
{
comm = _connection.CreateCommand();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
da.SelectCommand = comm;
da.Fill(result, "data");
}
// catch (Exception ex)
// {
// msg = ex.Message;
// }
finally
{
da = null;
comm = null;
}
return result;
}
public MySqlDataReader ExecuteReader(string storedProcedure, MySqlParameter[] parameterArray)
{
MySqlDataReader result = null;
MySqlCommand comm = null;
comm = _connection.CreateCommand();
string msg;
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
try
{
result = comm.ExecuteReader();
}
catch (Exception ex)
{
msg = ex.Message;
}
finally
{
comm = null;
}
// ValidateConnectionString();
// result = SqlHelper.ExecuteReader(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);
return result;
}
public DataTable ExecuteDataTable(string storedProcedure, MySqlParameter[] parameterArray)
{
//SqlParameter[] parameter = new SqlParameter[2];
//parameter[0] = new SqlParameter("@userIDN", SqlDbType.Int);
//parameter[1] = new SqlParameter("@activeFlag", SqlDbType.Bit);
//parameter[0].Value = applicationUserIDN;
//parameter[1].Value = activeFlag;
DataTable result = new DataTable();
string msg;
MySqlDataAdapter dataAdapter = null;
dataAdapter = new MySqlDataAdapter();
MySqlCommand comm = null;
//OpenConnection();
comm = _connection.CreateCommand();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
//comm.Parameters.Add(parameter[0]);
//comm.Parameters.Add(parameter[1]);
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
try
{
dataAdapter.SelectCommand = comm;
dataAdapter.Fill(result);
}
// catch (Exception ex)
// {
// msg = ex.Message;
// }
finally
{
CloseConnection();
dataAdapter = null;
comm = null;
}
return result;
}
public MySqlDataReader ExecuteReader(string storedProcedure)
{
MySqlDataReader result;
MySqlCommand comm = null;
string msg;
comm = _connection.CreateCommand();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
// foreach (SqlParameter param in parameterArray)
// {
// comm.Parameters.Add(param);
// }
try
{
result = comm.ExecuteReader();
}
// catch (Exception ex)
// {
// msg = ex.Message;
//}
finally
{
comm = null;
}
// ValidateConnectionString();
// result = SqlHelper.ExecuteReader(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);
return result;
}
}
}
Thanks in Advance
|
|
|
|
|
Someone may be able to answer your question, but I cannot.
Not unless I can see at least a little of your code. Please modify your post to include the relevent part of your code, the part where the error occurs. Point out the line causing the exception.
This will enable those of us without super powers to help you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
That is better, but I won't read through all that, at least in the horrible unformatted state.
Put the code inside <pre> tags like this:
<pre>
code here...
</pre>
and format it properly, you know - proper indenting and so on. (If you do the <pre> tags first, and then paste your code in again, it will retain the proper formatting.
Also make it really clear which line is giving the exception. You may have done this already, but I'm not going to search through that lot for it.
It makes my eyes hurt!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I second that. Except the part about your eyes, that I don't know.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi,
I'm developing a Windows Forms application that will be translated to all kinds of languages, including Simplified Chinese. On Windows Vista it works just fine with the Segoe UI font, but on XP all Chinese chars become boxes due to that it falls back to Tahoma.
Does anyone have a suggestion on an alternative font that I can use? Preferably it should be installed by default on Windows XP, it should not be too different from Tahoma or Sagoe UI and finally it should be possible to use for most languages out there, ie have a full Unicode set of characters.
Best regards
Christian
|
|
|
|
|
I don't understand your question. Are you asking us what default fonts are installed on what OS's?
|
|
|
|
|
Sort of... I'm not located in China myself, so I'm not aware of what fonts support the Chinese character set. I have Googled this issue but I wasn't able to find a suitable answer, because I do not want to use different fonts for Chinese, Japanese etc. which is the usually suggested approach. Segoe UI would be the perfect choice, but it's not always available on XP. So question is if there is a similar font on XP?
This problem should be very common, since my program is not the first to be translated into Chinese. Rather than going through hundreds of fonts, which is what I'm planning to do today I popped the question here.
|
|
|
|
|
Sorry, I lost track of this thread, my fault.
Christian Wikander wrote: Segoe UI would be the perfect choice, but it's not always available on XP. So question is if there is a similar font on XP?
Have you considered making the Segoe font part of your installation?
|
|
|
|
|
Yes, I have considered it.
As I understand it I may not distribute it without a separate license from the author. While not impossible to overcome, it adds some extra hassle with my boss.
Secondly my application is distributed through ClickOnce. It seems like an extra hurdle to distribute and use it given that the application has no rights at all in the client system.
At this point I more or less gave up to be able to move on. I wrote some code that change the font to one of the Sim* fonts if needed.
Nevertheless, thanks for the reply.
|
|
|
|
|
i wish to generate a html or chm help file from a application windows forms ,please give me the source code c# for this application.
thank you
|
|
|
|
|
System.IO.TextWriter tw = new System.IO.StreamWriter("C:\\example.html");
tw.WriteLine("<HTML><BODY>");
tw.WriteLine("<P>Hello World :)</P>");
tw.WriteLine("</BODY></HTML>");
tw.Close(); You just wanted the source, so here it is.
Enjoy
I are troll
|
|
|
|
|
I am working on a winforms project with an MDI Parent and some MDI Children. The Child datasets Fill methods use a parameter set by a combobox on the MDI Parent. I can iterate through the active MDI children, but cannot figure out how to refresh the dataset in the children when the parameter changes, which would then update the data being displayed. I tried invoking .refresh method on the child forms, but it does not refresh the dataset. Any ideas would help.
Thanks Paul
|
|
|
|
|
|
Hello Friends..
I have created setup in vb.net windows appliation.
I want to run another .exe file from command prompt at the time of setup
which has been already created during setup.
.exe file is created in my installation folder.
But problem is
How can i find my installation path during installation.?
Thankx in advance...
|
|
|
|
|
That depends on what you are using to do the installation. Some installers let you start a proces by script, others have it completely integrated (where you only set properties) and some don't provide this functionality at all
I are troll
|
|
|
|
|
Thankx Eddy Vluggen.
I am using wizard to install s/w step by step.
One step will ask user to where to install the s/w.
I want to know this path.
Hope See u again..
|
|
|
|
|
Dear All.
i want to raice Esc key(keybord) Event, without pressing the Esc button.
Regards
Rajeesh MP
|
|
|
|
|
Rajeesh MP wrote: i want to raice Esc key(keybord) Event, without pressing the Esc button.
If the event is in your application then you should abstract the functionality elsewhere so it can be called from where it is needed. If you are initiating it against another application then you might want to look at System.Windows.Forms.SendKeys[^]
|
|
|
|
|
AoA
Thanks in advance for help. Please help me if any one have some info about it.
I have made a solution with three projects a web services project , a client windows application project and a class library project.
I made a class in class library. this class library is added as reference in the client and web services project.
Now from client application, when i call some web methods of the web service they work fine.
I have a web method with an object type attribute. that method just cast it to string using ToString() and return that string. Now i made an object of a class in class library.
When i call that web method and pass this object. An InvalidOperationException generated, with error message There was an error generating the XML document.
I can not solve this, i search it on web but no solution found. I can not know how to upload the code here.
Please help me if any one can.
Will wait for reply.
|
|
|
|
|
Well I think You can see right side your project where you can see all class there will be webreference you must to update everytime you make new funcion to execute .
The error you said should be not adding correctly the reference of your webservice to your applicacion.
If you can execute your program in webservie in xml you will see the result with invoke button .
If you write details or send me your application wish could solve your problem ..
regards
jabbar
|
|
|
|
|
I wonder if anyone else has experienced this, or at least can suggest a resolution.
1) I placed a ReportViewer component on a form in my project and it didn't create the Toolbar or the Report area on the form nor did it create the BindingSource component.
I thought my installation might be broken, so to check this I:
2) I opened a different solution, added a ReportViewer to one of the forms and all worked correctly.
The only real difference between the two solutions, is that the solution in 1) already has several ReportViewer Forms in it.
Anyone got any ideas at all.
Pllzzz note this is not urgentzzzz in any way at all.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: Pllzzz note this is not urgentzzzz in any way at all.
Great. I have to think about this for a couple of weeks anyway...
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|