|
The thing I want to do is validate the textbox. I created a ValidTaxtbox method that always returns true. The idea is that when you use the textbox, you write a new method for that textbox with the actual valid code.
|
|
|
|
|
Unless by "use" you mean you want to derive different types of ValidTextBox, then you really need to set up an event and handle the event in your form.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Can you please explain that a bit?
I am very new at this and I just want to put the control on my form and write a validtextbox method each time I use it.
|
|
|
|
|
In your ValidTextBox class create an event, e.g.
public event EventHandler ValidateTextBox;
Then when you need to trigger the event you can write
this.ValidateTextBox(this, new EventArgs());
On your form you can then add a handler for the event, just like a handler for any other event with something like
myValidTextBox.ValidateTextBox+=new EventHandler(ObjectName_EventName); Normally, after the += I just usually let intellisense take over and I just hit tab twice, the first time to complete this statement, the second time to create a method stub for the event handler.
Now, I would guess that you don't want the default EventHandler because it doesn't allow you to pass much information - just the sender (the object that triggered the event), so you might want to set up a delegate . This sits outside the class
public delegate void ValidateDelegate(object sender, ValidateTextBoxArgs e); The ValidateDelegate here would replace EventHandler in the example above
You will also need to create a class that is derived from System.EventArgs , which above I've called ValidateTextBoxArgs
There are many source of information on this. If you need a step-by-step tutorial searching on the keywords delegate and event in msdn will likely turn up something useful - and I'm sure it will explain it better than I have done here.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Thanks for explaining, I'll have a closer look.
|
|
|
|
|
Hello,
Now, I am developing the following tool.
This is download tool using .NET, WebClient.DownloadFile().
In IIS Server, I create virtual directory, set some files.
I execute this tools, but the error occuered.
Error occured ! System.Net.WebException: The remote server send the error. 404 not found
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at System.Net.WebClient.DownloadFile(String address, String fileName)
I am investiged the cause, so I found the solution. "make config file, the contents is the following (take '<' and '>')
configuration
system.net
defaultProxy
bypasslist
add address="192\.\..*" /
/bypasslist
/defaultProxy
/system.net
/configuration
But, I don't know where I set this config file. If you know it or some ideas, please advice me.
cheers,
yu-yu
|
|
|
|
|
Hi,
I'm not sure if what I want to do is possible but here goes.
I've written a stand alone application that queries a database through a series of stored procedures and displays the relevant data in a datagrid. Users can alter and exclude data as and when necessary but only one row at a time. Here's the thing, I want to add a checkbox column as the first column in the datagrid so that users can select all the rows they wish to exclude at once (all the exclude procedure does is move the rows from one table to another). Can it be done? I've had a few stabs at putting the column in but to no avail. Please can anyone out there point me in the right direction?
Much appreciated and thank you in advance.
Below is the code for formatting tables. I'll post any other code anyone wishes/needs to see.
private void formatData(DataSet ds)
{
label5.Text = ds.Tables[0].Rows.Count.ToString()+" row(s)"; //Row counter
// Clear DG tablestyle
dataGrid1.TableStyles.Clear();
// Apply tablestyles & set column widths
DataGridTableStyle dgStyle = new DataGridTableStyle();
dgStyle.MappingName = ds.Tables[0].TableName;
dataGrid1.TableStyles.Add(dgStyle);
dgStyle.GridColumnStyles[0].Width = 120;
dgStyle.GridColumnStyles[1].Width = 150;
dgStyle.GridColumnStyles[2].Width = 200;
dgStyle.GridColumnStyles[3].Width = 120;
dgStyle.GridColumnStyles[6].Width = 200;
}
|
|
|
|
|
Just as you're adding a DataGridTableStyle to DataGrid.TableStyles , actually add separate instances of DataGridColumnStyle -derivatives - like the DataGridTextBoxColumn or DataGridBooleanColumn (the checkbox column) - to the DataGridTableStyle . With what you're currently doing, the default for the column type is being used.
If you read the documentation for the DataGrid.TableStyles property you can see an example.
This really needs to be bounded to your data source, though. You could add a bogus DataColumn to your DataTable . You could also try just adding an unbounded column but, IIRC, the CheckBox won't be clickable. Perhaps defining your own DataGridColumnStyle derivative would help here.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
That's it, thank you very much. Much obliged to you.
|
|
|
|
|
Hi all,
Using the Key_Up or Key_Down event of a textBox i am trying to restrict the user from typing certain characters. I can do this in the Key_Press event using the KeyChar property and the Char.IsDigit().
i.e. if(char.IsDigit(e.KeyChar))
But in Key_Up or Key_Down you don't have the KeyChar property.
Any ideas?
Kev
|
|
|
|
|
|
I know that i can do that but i was hoping there would be a way of checking for a group of characters / keys i.e. All numbers, Full Stop, the Minus Sign etc.
Gues i'll just have to checkfor them all.
Thanks for your help
Kev
|
|
|
|
|
It's not as easy as with the Keypressed event but also you can check for group of characters. For example:
if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9)
{
if (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9)
{
Take a look at the link I provided in my previous post.
www.troschuetz.de
|
|
|
|
|
Stefan,
Thanks for that, i wasn't aware that you could use the > and < operators
with KeyCodes and the Keys enumeration, guess i should have tried it
On another point i thought that assigning e.Handled = true; in the Key Up
event would stop the character from being displayed, this works in the
KeyPress event but in the key up event it still types the character to the
screen.
Kev
|
|
|
|
|
I think it's not possible in the KeyUp event as even the example of the MSDN topic for KeyUp uses a boolean flag which gets checked in KeyPress event to determine whether the character should be displayed or not.
www.troschuetz.de
|
|
|
|
|
Hi
I just started C++, but this code I found on the net blew me away. Could someone please help me understand, especially the lines market with a /**/.
void read_data_from_bs(void *data, int bits_of_data,
unsigned char *bit_stream, unsigned long & bit_offset)
{
int i;
int n;
while (bits_of_data > 0)
{ // <-- Colored with red by Instant Match
n = bits_of_data > 8 ? 8 : bits_of_data; /**/
*(unsigned char *)data = 0;
for (i = 0; i < n; i++)
{
if (read_bit(bit_stream, bit_offset))
{
(*(unsigned char *)data) |= (1 << i); /**/
}
bit_offset++ ;
}
data = ((unsigned char *)data) + 1; /**/
bits_of_data -= n;
}
}
|
|
|
|
|
|
Hi all,
I have created an interface in C# (obviously, since I am posting on C# forum !!!). In tht I am displaying some images using open file dialog. Now I am planning to incorporate another feature whcih is as follows, when the user moves the mouse over the image after it is opened, the corresponding pixel co-ordinates and its intensity value must be displayed on the status bar of the interface. For more clear idea (this is usually implemented in many of the image editors).
I hope I have to use 'MouseEventargs' class, but how can i implement it and incorporate in my interface...
Any advices or ideas are greatly appreciated...
thanks in advance,
Suman
|
|
|
|
|
I don't know how to get the intensity but the cursor position is easy.
Use the Form.Cursor.Position property to get the position of the cursor relative to the form, then just take into account the position of the picture on the form.
The result is the position of the cursor on the picture.
Kev
|
|
|
|
|
Hi,
I can find the intensity value (once we get the cursor position relative to our active window)... but wht i want to know is how to keep on find the position of the cursor on the imge (which u have answered, thanks for tht), but i want that process to be active always as long as the user moves his cursor on the image (ok ok we can use the image boundaries for it). then i want it to show it in my status bar panel (cordinates and intensity value) every time.
hope i am clear to the point.
any ideas/suggestions?
thanks,
Suman
|
|
|
|
|
Can u show me a sample code... in whcih this is implemented. I want to show the values in the status bar all the time as long as the user moves his mouse over the image area.
thanks,
Suman
|
|
|
|
|
That's fine, but you still didn't answer my question. I'll rephrase it. How does the business layer and the user layer communicate with each other? What is on the client side that connects to the server? What does the server expose that the client can see in order to work?
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
OK. The Business Layer is a .dll which the user layer creates an object of to expose its functions. I hope that answers the question.
Thanks Colin.
|
|
|
|
|
So, your business layer is an assembly (in .NET DLLs are properly called assemblies), and your user layer references the assembly (by Adding a Reference to the user layer's project)? Is that right?
If my assumption is correct then the business layer isn't working on the server, it is working on the client. If that is the case then probably the only thing that is one the server is the database.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Let me rephrase the question.
What I want to achieve is the following
Workstation: User Interface
Server: Business Layer and Database Layer.
How can I achieve the 'talking' between the user layer and business layer?
Is a service an appropriate way to achieve this? an example would be good. I have looked at remoting but that was too complicated for the time frame I have.
Thanks
Stephen
|
|
|
|