|
My code is a bit like this: Writing your Custom Control: step by step
And the button is visible when I use only frmBase. Compile and run frmInherited that inherits from frmBase. I can't see the button I placed on frmBase.
I will try the designer. But in my opinion a designer is only needed when I want to see the control in VS.NET.
My problem is that I can't see it when I compile and run.
Jochen
|
|
|
|
|
I'm sorry I missed what you said about runtime.
I would use the debug to step through the code and try to find the bug. I have no ideas.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Where can I find WMI Programming????
Jijo kuruvila
software developer
trivandrum
|
|
|
|
|
|
Hello all,
I need to search through a pile of source code and pick out certain "help IDs" based on context and output them to a file, GUI, etc. Now, I can think of many many ways to do this, but what I want to know his, what is the BEST way to do this in your opinion?
I could make my program read through every line of every file and use String.substring; I could use Regex.Match on every line, I could use Regex.Match on entire files dumped into strings, etc. I would like to use a regex, but I'm basically not sure if it is more efficient to do it line-by-line or file-by-file?
I actually started looking at perl to do this but that meant figuring out how scope/namespaces work with recursion in yet another language so...
Thanks for any help.
|
|
|
|
|
Hi,
A while back I wrote an application that searched our webapp logs using .NET RegExs for any token the user specified. These logs were on an average day around 40 mbs and on heavier days, around 80-90 mbs spread across 10 servers. Before then, I had a Perl script that did the same thing. From an 'searching' perspective, both apps did their job well. However, from a design perspective, I liked the .NET one better cause I could compile the regex that the user used and use it (making a bit more efficient). In Perl, it compiles the RegEx everytime you run the script as compared to loading it from an assembly.
Just my two cents.
~javier lozano
(blog)
|
|
|
|
|
McClamm wrote:
I need to search through a pile of source code and pick out certain "help IDs" based on context and output them to a file, GUI, etc.
Depending on what you need, just a simple grep will solve. Some solutions may need a full blown C# parser. It's hard to say, without knowing what you mean by "context".
Yes, even I am blogging now!
|
|
|
|
|
I am abeginner in C# and I try to access a variable defined in the main class (frmMain) witch is declared like in the following code:
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
<br />
namespace Test<br />
{<br />
<br />
public class frmMain : System.Windows.Forms.Form<br />
{<br />
<big>public string testString;</big><br />
<br />
public frmMain()<br />
{<br />
<br />
InitializeComponent();<br />
<br />
}<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new frmMain());<br />
}<br />
<br />
private void mnuMenu_Click(object sender, System.EventArgs e)<br />
{<br />
frmChild newMDIChild = new frmChild();<br />
newMDIChild.MdiParent = this;<br />
newMDIChild.Show();<br />
}<br />
}<br />
}
Now i try to access the variable testString in the child window frmChild:
<br />
testString= "Why does this not work???";
Even frmMain.testString= "Why does this not work???";
and won't work.
Can somebody help a stupid beginner? I know it must be easy.
Thanks
The german stupid
|
|
|
|
|
1. You need to get at the parent of the child form
2. You need to cast to the correct type to get at the testString
so you could have the following code in your child form
<br />
((frmMain) this.MdiParent).testString = "";<br />
This code will only work for the example you gave.
Gary
While you're waiting, read the free novel we sent you. It's a Spanish story about a guy named 'Manual.'
- Dilbert
|
|
|
|
|
Thanks Gary, works fine!!!!
The german stupid
|
|
|
|
|
I am making a Secure FTP program and I am in need of an anonymous Secure FTP site to test on. Does anyone know of any site I could test AUTH TLS on or have a list of sites (which would be even better)?
thanks
|
|
|
|
|
|
Hi all,
i need to divid a Sqlmoney on a float type but it gives me an error " Operator '/' cannot be applied to operands of type 'System.Data.SqlTypes.SqlMoney' and 'float'"
thanks
|
|
|
|
|
Hi gurus,
I'd like to know what is the equivalent of the MFC's CString::CompareNoCase in C#?
Thanks
Best regards.
There is no spoon.
|
|
|
|
|
|
Hi everyone,
I have a C# based COM DLL that uses an old ocx. The ocx is placed within a panel inside a form that the C# COM DLL displays as a dialog.
In the InitializeComponent call, I get the "Call is rejected by callee" exception with the EndInit call on the ocx wrapper.
Here are the relevant portions of the code:
namespace KVXUI
{
public class KVXUIForm : System.Windows.Forms.Form
{
...
private AxKVXLib.AxKVX m_kvx;
...
public KVXUIForm()
{
InitializeComponent();
...
}
private void InitializeComponent()
{
...
this.m_kvx = new AxKVXLib.AxKVX();
...
((System.ComponentModel.ISupportInitialize)(this.m_kvx)).BeginInit();
...
m_MainPanel.Controls.Add(this.m_kvx);
...
//
// m_kvx
//
... m_kvx initialization code here
...
((System.ComponentModel.ISupportInitialize)(this.m_kvx)).EndInit();
...
}
...
}
}
The exception occurs when the EndInit shown above is called. However, this does not happen always. Here are a couple of scenarios showing how the DLL is invoked:
The following scenario works fine.
MFC app --> some other ocx --> ATL COM object --> my C# COM DLL
The scenario below results in an exception.
Adobe Acrobat 5.0 -> some other dll -> ATL COM object -> my C# COM DLL
There were some posts on the net that indicated that this may be a timing related problem. I sprinkled some sleep calls but that didn't help.
Any help will be greatly appreciated.
Thanks.
Hari
|
|
|
|
|
Hi
I need to implement a synchoronous operation through sockets.I need to send data from my client to the server,have the server read that data,process it,generate a response,and then send it back to me.I need to wait for this response on my client end.Im trying to use tcpclient and tcplistener.However the problem is when i have sent the data from the client side,how do i wait for the server response before i proceed?How can i know when the server has done with its processing and is pushing data back on my stream?
How are synchoronous operations done??
Please help.
Thanks
Jay sai
|
|
|
|
|
I'm trying to use an ocx written in VB6 in my C# app and
when i try to show a form ("click a button") i get an error message
"run-time error 406 Non Modal Forms cannot be displayed ... "
what can be done if i need these forms Non Modal?
thanks
sharon
|
|
|
|
|
Hi,
I want to overload the == and != operators on my custom class, and my trusty "C# and the .NET platform, second edition" suggests that I overload the System.Object.Equals and does something like this:
public override bool Equals(object obj)
{
try
{
Row r = (Row)obj;
if (obj == null)
return false;
bool retval = (this.m_style == r.m_style) &&
(this.m_text == r.m_text) &&
(this.m_sortOrder == r.m_sortOrder) &&
(this.m_parentId == r.m_parentId);
return retval;
}
catch
{
return false;
}
}
public override int GetHashCode()
{
return m_id.GetHashCode();
}
public static bool operator ==(Row r1, Row r2)
{
return r1.Equals(r2);
}
public static bool operator !=(Row r1, Row r2)
{
return !r1.Equals(r2);
}
This will let the .Equals() method take care of any needed comparison, and looks good. My problem is now when I write code like
Row row = null;
if (blaha blaha)
row = some_row
if (row != null)
- if the "if (blaha blaha)"-statement isn't true, we'll end up comparing null and null with the == operator. This will call "return r1.Equals(r2);" where r1 is null and we have a crash.
Could someone please help me with an example of a correct implementation of overloading the == and != operators, that handles checking for member variable equalness as well as null-values correctly. I seem to keep running into problems that must have been solved a million times before - but I can't find any useful examples on google - nor here on CP.
Thanks in advance, guys 'n' gals !
/Jan
Do you know why it's important to make fast decisions? Because you give yourself more time to correct your mistakes, when you find out that you made the wrong one. Chris Meech on deciding whether to go to his daughters graduation or a Neil Young concert
|
|
|
|
|
Add the following lines to your operator== method:
if (Object.ReferenceEquals(r1, null) || Object.ReferenceEquals(r2, null))
{
return Object.ReferenceEquals(r1, 2);
}
The operator!= is left as an exercise to the reader
Yes, even I am blogging now!
|
|
|
|
|
HAH !!
Thanks a LOT !!!
I tried that... well, almost.. I just used the == operator like "if (r1 == null)" and of course it just called itself and gave me a stack overflow (great.. ). But that's it - use the Object.ReferenceEquals.
Once again, thanks.
This is why I CP
/Jan
Do you know why it's important to make fast decisions? Because you give yourself more time to correct your mistakes, when you find out that you made the wrong one. Chris Meech on deciding whether to go to his daughters graduation or a Neil Young concert
|
|
|
|
|
I would implement it the following way:
public static bool operator ==(Row r1, Row r2)
{
try
{
if (r1 == null || r2 == null)
return false;
bool retval = (r1.m_style == r2.m_style) &&
(r1.m_text == r2.m_text) &&
(r1.m_sortOrder == r2.m_sortOrder) &&
(r1.m_parentId == r2.m_parentId);
return retval;
}
catch
{
return false;
}
}
public static bool operator !=(Row r1, Row r2)
{
return !(r1 == r2);
}
public override bool Equals(object obj)
{
Row row = obj as Row;
return this == row;
}
public override int GetHashCode()
{
return m_id.GetHashCode();
}
NOTE: Your GetHashCode method is inconsistent with your equality criteria. Ur basing the hash code generation on 'm_id' when in ur == operator ur stating that the two objects are equal only when 'Style', 'Text', 'SortOrder' and 'ParentId' are the same.
This will lead to having two Row objects with the same HashCode (Same 'm_id') not being equal, which should never happen. If, on the other hand, 'm_id' is a unique identifier of your row, then maybe you should consider using it also as your equality criteria.
Always keep in mind that two objects with the same hashchode should be equal.
|
|
|
|
|
I am trying to use a datagrid with columns of different width. I have found several methods posted on various sites, but unfortunately am unable to make any of them work. The following code seems to be the most straightforward, but none of the formatting is actually applied to the datagrid.
What am I missin?
private void FormView_Load(object sender, System.EventArgs e)
{
string connection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=reminder.mdb";
//string query ="SELECT Date,Time,Message,TicklerDate,TicklerTime FROM Ticklers";
string query ="SELECT * FROM Ticklers";
// Initialize the connection using the connection string
conn = new OleDbConnection(connection);
// Open the db connection
conn.Open();
//Initiate the OleDbDataAdapter using the SQL select commmand on the db connection
adapter=new OleDbDataAdapter(query,conn);
// Initiate and fill the dataset
ds = new DataSet();
//initiate the datatable
adapter.Fill(ds,"Customers");
dt = ds.Tables[0];
// Get the database schema
adapter.FillSchema(dt, SchemaType.Source);
conn.Close();
// Format the data grid
DataGridTableStyle ts = new DataGridTableStyle();
this.dataGrid1.TableStyles.Clear();
//ts.MappingName="Ticklers";
ts.MappingName=dataGrid1.DataMember;
DataGridTextBoxColumn column1 = new DataGridTextBoxColumn();
column1.MappingName="Index";
column1.HeaderText="Index";
column1.Width = 0;
ts.GridColumnStyles.Add(column1);
DataGridTextBoxColumn column2 = new DataGridTextBoxColumn();
column2.MappingName="Date";
column2.HeaderText="Event Date";
column2.Width = 75;
ts.GridColumnStyles.Add(column2);
DataGridTextBoxColumn column3 = new DataGridTextBoxColumn();
column3.MappingName="Time";
column3.HeaderText="Event Time";
column3.Width = 75;
ts.GridColumnStyles.Add(column3);
DataGridTextBoxColumn column4 = new DataGridTextBoxColumn();
column4.MappingName="Message";
column4.HeaderText="Description";
column4.Width = 150;
ts.GridColumnStyles.Add(column4);
DataGridTextBoxColumn column5 = new DataGridTextBoxColumn();
column5.MappingName="TicklerTime";
column5.HeaderText="Tickler Time";
column5.Width = 75;
ts.GridColumnStyles.Add(column5);
DataGridTextBoxColumn column6 = new DataGridTextBoxColumn();
column6.MappingName="TicklerDate";
column6.HeaderText="Tickler Date";
column6.Width = 75;
ts.GridColumnStyles.Add(column6);
dataGrid1.TableStyles.Add(ts);
// Bind the datatable to the datagrid control
this.dataGrid1.DataSource=dt;
// Show the datagrid
this.dataGrid1.Visible=true;
}
ngb
|
|
|
|
|
I'm making a graphical display, but the image refresh is very jerky. I added a tick counter to the behaviour thread, and it takes 0ms, so the issue was not there.
On adding it to the graphical thread however, I discovered that rendering tends to jump a lot, on average a few small objects take 16ms, but jump to 35-40 once or twice a second. When I add a large image to the rendered scene, (640x480 or higher), the rendering time increases to 70, and jumps to over 100 a couple of times a second.
I'm using the following threaded loop:
<br />
int start = Environment.TickCount;<br />
g.DrawImage(Background,0,0);<br />
r.Draw(g, new Point(0,0));<br />
s.Draw(g, new Point(0,0));<br />
t.Draw(g, new Point(0,0));<br />
pb_Display.Refresh();<br />
tb_Text.Text = (Environment.TickCount - start).ToString();<br />
Note: I'm rendering this image to a picturebox Image, and redrawing the image on every itteration. I'm still looking for a better way to do this.
I have two questions about this, why does this jump occur?
And are there any techniques to increase the speed at which rendering occurs?
CHeers
Tris
|
|
|
|
|
The Catalyst wrote:
And are there any techniques to increase the speed at which rendering occurs?
If you care about speed, use GDI or DirectX (in extreme cases) for drawing.
GDI calls should provide enough speed for most uses.
The Catalyst wrote:
Note: I'm rendering this image to a picturebox Image, and redrawing the image on every itteration. I'm still looking for a better way to do this.
Actually, you should only call Invalidate/Update on the control and let it redraw itself when needed (on the Paint event or an overrided OnPaint method). This will keep you from drawing faster than the video card/driver can handle. You'll need only to draw 60 times per second, as the video does not refresh more than this. This means that times you have around 160ms to draw, and flip the buffer when the monitor's vertical retrace happen. What do I mean about "flip the buffer"? Do a bit of search and read about double-buffering, and you'll understand better how to achieve high frame rates, even with a slow drawing.
The .NET framework offers suport for double-buffering, but I suggest you to read more about how it works before using it.
Yes, even I am blogging now!
|
|
|
|
|