|
You never specified any of this in your original post...
The processes and methodologies behind custom controls can take up entire books. I would start with a little Googling, like for "writing custom controls vb.net"[^]. Or change the language to whatever you're using.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
If you create all your business logic inside of a class which does a bunch of processing. Let's say this class is passed a file name and reads each line of the file to do some processing. If I want to display to the user the progress of reading through the file, what is the best way to update the progress bar?
How do you keep business logic and presentaion layer separate in this case?
Mike
|
|
|
|
|
You make a new event (ReadStautsUpdate for example) and then your class fiers that event everytime it reads a line.
You add a event hanlder on your form which will update the progressbar.
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
If your business logic runs on an other machine than your client you have to use i.e. something like the massage queue server, which provides the notification of your client of server side events.
regards, bernd
|
|
|
|
|
Does anyone know how to match the look of a ToolStripButton's "Checked" state? I've had to replace a couple of ToolStripButtons in my UI with ToolStripSplitButtons, but the SplitButtons don't have a "Checked" property.
So, I made my own ToolStripSplitButton with a Checked Property, but I cannot figure out how to match the way the ToolStripButton randers the "Checked" state. Here's what I've tried:
<br />
public class ToolStripSplitButtonEx : ToolStripSplitButton<br />
{<br />
private bool _Checked = false;<br />
private VisualStyleRenderer renderer = null;<br />
private readonly VisualStyleElement element = VisualStyleElement.ToolBar.Button.Checked;<br />
public ToolStripSplitButtonEx()<br />
{<br />
<br />
<br />
if (Application.RenderWithVisualStyles &&<br />
VisualStyleRenderer.IsElementDefined(element))<br />
{<br />
renderer = new VisualStyleRenderer(element);<br />
} <br />
}<br />
public bool Checked<br />
{<br />
get<br />
{<br />
return _Checked;<br />
}<br />
set<br />
{<br />
_Checked = value;<br />
this.Invalidate();<br />
}<br />
}<br />
<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
base.OnPaint(e);<br />
if (_Checked)<br />
{<br />
renderer.DrawBackground(e.Graphics, this.Bounds);<br />
}<br />
}<br />
}<br />
This doesn't seem to do anything at all. I'd originally been simply drawing a rectangle that was the proper color, but that doesn't work with different XP themes. Does anyone know about how to tackle this?
|
|
|
|
|
I've updated my OnPaint function to the following:
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
if (_Checked)<br />
{<br />
if (renderer != null)<br />
{<br />
System.Drawing.Rectangle cr = base.ContentRectangle;<br />
System.Drawing.Image img = this.Image;<br />
<br />
int centerY = (cr.Height - img.Height) / 2;<br />
<br />
System.Drawing.Rectangle fullRect = new System.Drawing.Rectangle(0, 0, this.Width, this.Height);<br />
<br />
System.Drawing.Rectangle imageRect = new System.Drawing.Rectangle(<br />
base.ContentRectangle.Left,<br />
centerY,<br />
base.Image.Width,<br />
base.Image.Height);<br />
<br />
System.Drawing.Rectangle textRect = new System.Drawing.Rectangle(<br />
imageRect.Width,<br />
base.ContentRectangle.Top,<br />
base.ContentRectangle.Width - (imageRect.Width + 10),<br />
base.ContentRectangle.Height);<br />
<br />
renderer.DrawBackground(e.Graphics, fullRect);<br />
renderer.DrawText(e.Graphics, textRect, this.Text);<br />
renderer.DrawImage(e.Graphics, imageRect, this.Image);<br />
}<br />
else<br />
{<br />
e.Graphics.FillRectangle(System.Drawing.SystemBrushes.Control, 0, 0, this.Width, this.Height);<br />
e.Graphics.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.Highlight), 0, 0, this.Width - 1, this.Height - 1);<br />
base.OnPaint(e);<br />
}<br />
}<br />
else<br />
{<br />
base.OnPaint(e);<br />
}<br />
<br />
}<br />
Now I've got the image and text, but nothing looks right. I thought that setting the renderer to be the same as a checked button would fix this, but the font is wrong and the background appears blank.
Am I going about this the wrong way?
|
|
|
|
|
hey @ all,
does anyone of you have experience by implementing the mvc-pattern? implementing the model should not be the problem, but how should i design the view (respectifly the fassade) when i try to build a app, that serves the model to the client's by remoting. i try to make a client-server-app, where the inelligent part of the app runs on the server an all clients are running just a proxy of the application. does this make sense? or ist there an other, better way to implement the mvc-pattern?
thx, bernd
|
|
|
|
|
As far as I know MVC is used in web applications and not windows applications. Bu please correct me if I am wrong.
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
MVC is used in windows apps as well as web apps.
|
|
|
|
|
My bad then
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
ok, and how do i implement it the correct way? is there anywhere a guide for doing this in any other language? i just know what components are used in mvc and i tryed to implement it by using web-sservices to build something like a fassade for my app, but it seems to be not the right way. in fact i'm not sure if something like a fassade is the right way because it provides just a one way communication.
please give me some hints.
regards, bernd
|
|
|
|
|
It's difficult to answer that question because the number of unknowns is far too high. The only advice I can give is to make sure that using the MVC pattern is actually necessary, so that you don't rip your hair out over it unnecessarily.
This is not a criticism of you, of course, but I find that many developers use design patterns just for the sake of using them. Almost habitually. In my view, patterns should only be used when they help solve a problem. In general design patterns add unnecessary complexity to, what should be, simple solutions.
Josh
|
|
|
|
|
if we r using component in our application, how can we handle exception raised in a component?
|
|
|
|
|
Just like any other exception.
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
If any of your code is in the call stack when the exception is thrown, you can handle the exception at the call site which eventually triggers the exception to be thrown. If your code is not in the call stack, then you should get the component developers to fix the bug asap.
If you are working in WinForms, perhaps hooking the Application.ThreadException event could be useful for you as well. That event fires when an exception on the UI thread is not handled and is about to crash the app.
Josh
|
|
|
|
|
I have a regular expression that I use to find html tags in a string, the expression is similar to the following:
<(?<TagName>[a-zA-Z\d]{1,})(\s[a-zA-Z\d]{1,}="[\s\w]{0,}"){0,}(\s/>|\s?>.*?</\k<TagName>>)
It's designed to detect html tags such as the following:
<strong /> OR <strong>Text</strong> OR <strong ID="supertext">Text</strong>
What I'd like to do is use this expression to split a file into an array of strings but I get odd results when I use the Regex.Split() method.
Lets say I want to split the following line of text:
The <em>quick</em> brown fox jumps over the <strong>lazy</strong> dog.<br />
Regex.Split() produces the following array:
1 - The
2 - <em>quick</em>
3 - >quick</em>
4 - em
5 - brown fox jumps over the
6 - <strong>lazy</strong>
7 - >lazy</strong>
8 - strong
9 - dog.
10 - <br />
11 - />
12 - br
It's obviously splitting on the sub groups as well as the entire tag.
Is there any way I can tell the regex engine to only split 1 group, not them all?
As you can see the solution isn't as simple as just removing the extra groupings because they are needed so that I can detect the close of an open tag, and allow more than one property to be in each html tag.
Thanks in advance for any help
|
|
|
|
|
If you need a non-catching group, use (?:
---
b { font-weight: normal; }
|
|
|
|
|
Thank you for the answer, that helped a LOT.
I've ALMOST eliminated all of the excess data, except for one thing:
The only other drama that I am facing now is that I can't apply the non matching group to the named capture group called "TagName" which I unfortunatley need to recognise the closing tag.
Is there any way that I can use a named capture group ONLY inside the regular expression, just for the purposes of matching the closing tag?
|
|
|
|
|
I think that a "Balancing group definition" could do that. I haven't looked into it enough to grasp how it's used, but I think that it could be worth a look.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I've recently built a smart client which uses 'click once deployment'. The program also uses the Enterprise Library for logging (among other things). Any errors that are encountered get logged to a database through a web service. If the communication with the web service or database fails a second logging policy is used which logs errors to a txt file.
I recently encountered such an error that caused the program to use the second policy, but I don't know where it put the log file... Click once deployment creates a program group in the start menu for the smart client which hold the executable, not a shortcut, but the actual executable. Any idea where it installs the associated DLL's, app.config file, or potential log files?
When I run the program on my development machine (not a click once deployed version) it simply creates the log file in the same directory as the executable.
Thanks in Advance.
|
|
|
|
|
ClickOnce creates a folder for each app in your local settings folder. Mine is here:
C:\Documents and Settings\<myusername>\Local Settings\Apps\2.0\WCMKYTQ4.LLO\WNRQ70YJ.7OX\
Each app gets a funky folder name under there, like:
\app..tion_a3097e953761587e_07d6.0003_47249f0b94b273b7\
Your exe and log files will most likely be under there.
JR
|
|
|
|
|
I'm having the same issue as the original poster and the log files are not there.
I even searched the entire drive including hidden and system folders, it is not on the drive anywhere. I think there may be a compatibility problem between the enterprise library text logging and clickonce. I finally resorted to doing a custom enterprise library handler and writing it out to a file myself.
|
|
|
|
|
New to dot Net.
i have been trying to learn how to use the new datagridview in 2005.
i would like to learn how to remove a row in the dataviewgrid control.
could someone please help me with this. the MS documentation showed no examples.
how do i get the correct row objects to do a row delete.
DataGridViewRowCollection rows = this.dataGridView1.Rows;
foreach (DataGridViewRowCollection Row in rows)
{
//
// Row.remove (?) something go here or are i the wrong track
}
many thanks
Steve
steve
|
|
|
|
|
Hi,
The DataGridView is a visual representation of the data to which it's bound, so the best way to remove a row is to remove it from said bound data source.
Also, be weary of code such as:
foreach (DataGridViewRowCollection Row in rows)
{
//
// Row.remove (?)
}
As you are removing something from a collection you're currently searching through.. that can get messy.
|
|
|
|
|
Simply...
DataGridViewRow row=dataGridView1.Rows[23];
dataGridView1.Rows.Remove(row)
Or
int index=23;
dataGridView1.Rows.RemoveAt(index)
This will physically remove the row, rather than marking it for deletion.
Graham
-- modified at 21:12 Tuesday 25th April, 2006
|
|
|
|