|
Yes, literals work as expected.
This code to handle the CellClick event works as expected (currentRow and currentCol are declared as form properties).
private void vDateDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
currentRow = e.RowIndex;
currentCol = e.ColumnIndex;
string str;
str = vDateDataGridView[currentCol, currentRow].Value.ToString();
selectedCellLabel.Text = str;
}
But when the following line is executed in the other event handler, currentRow behaves as before!
str = vDateDataGridView[currentCol, currentRow].Value.ToString();
The workaround is to declare currentRow and currentCol as local variables in the CellClick event handler, declare the variables I want to extract from the DataGridView as form properties and get their values in the CellClick event handler.
modified on Tuesday, April 28, 2009 5:55 PM
|
|
|
|
|
I am novie to the Regular expression validatio. my req is a regular expression for currency with thousand seperatror which is decimal(14,3) ... checked the all availabe but no use.. pls help me to get it..(pls Note the regulare expression should restrict to decimal(14,3)
|
|
|
|
|
maybe you could put some examples of valid/invalid input so we can better understand your requirements
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
eg 1,12,000.00, 22,22,333.90 are valid but 12,33,333,444,444.900000(more than 11 preceding the point and more than 3 field afer the point)
|
|
|
|
|
what about...
string regexString = @"^[0-9,]{0,14}.[0-9]{0,3}$";
NOTE: i use 14 before . to allow for the 3 commas possible
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Thks for the post.. i did a basic test and seems it'w working ..thanks v much
|
|
|
|
|
want to sign my project assembly files with some private key and i'm using x509certificate class. I need this certification to be valid permenently, what should i do? we don't have access to edit the validation period in the certification directly, right?
any ideas????? Should i use another approach for my aim? What?
I appreciate any ideas...
Roshanak
|
|
|
|
|
I write ExecuteDataSet function;
public DataSet ExecuteDataSet(string commandText, string tableName, SqlParameter[] parameters)
{
try
{
OpenConnection();
using (SqlCommand command = new SqlCommand(commandText, this.connection))
{
command.Parameters.Add(AddParameter(command, parameters));
using (SqlDataAdapter dataAdapter = new SqlDataAdapter(command))
{
DataSet ds = new DataSet();
dataAdapter.Fill(ds, tableName);
CloseConnection();
return ds;
}
}
}
catch (Exception ex)
{
//Exception Log
CloseConnection();
return null;
}
}
I wan to call AddParameter() fuction in the using block. Bu I get error.
private SqlParameterCollection AddParameter(SqlCommand command, SqlParameter[] parameters)
{
foreach (SqlParameter param in parameters)
{
command.Parameters.Add(new SqlParameter(param.ParameterName, param.Value));
}
return command.Parameters;
}
How can I do?
AddParameter() using in a lot of function. If I write foreach loop in the using block so code is repated a lot.
|
|
|
|
|
What kind of error do you get? Writing down the error message will help a lot.
|
|
|
|
|
Hi, I'm pretty new to programing and drawing is something I've only touched on
I need to get the program to draw a shape (done that) that's as large as the form is (minus some padding) and re sizes as the form size is changed.
I know about using *Whatever* = ((width > height) ? height : Width); but I don't know where to put it and I know about this.height and this.width but don't know where to put that.
So in a nutshell I need help with getting my shape to fill up the maximum possible room in the form and resizing as the form size is changed.
Thanks in advance for any help
P.S. I know this is a very rudimentary question for many (if not all) of you out there so please don't scoff at me
|
|
|
|
|
If you are drawing directly onto the surface of the Form you need to put your code in the Paint event handler of the Form .
Just in case you don't know how to do that. Make sure your Form is selected in the designer, then in the properties window, click the events button (at the top, lightening bolt), then double-click on the Paint item. A handler stub is created in the editor, put your code there.
private void MyForm_Paint(object sender, PaintEventArgs e)
{
}
By putting the code there, it guarantees that your code gets executed every time the Form is drawn, such as when it is resized.
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.”
|
|
|
|
|
Hi Johnny, .
You can to use the resize event of the form , on resize event resize shape , hope you would be able to find event , events can be found using property window , there is small yellow colored , lighting shape button , it will show all event related to the selected object (in our case form , as we have kept it selected) , there You need to find resize and double click on to white space (cell) next to resize , designer will take you to event handler , where you should place your code .
Hope i have not made it more confusing , let me know if you need more information
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
I'd recommend not doing this directly on the form, but deriving a new control from Panel. This control you can place on your form with docking set to fill and it will resize. This way, you gain some portability in your control (for use on other forms). You can even add properties to help define the shape etc.
As far as the drawing goes, there are two handlers you're interested in OnPaint and OnResize. You can hook events for these, or if you do go down the derived control route just override them as protected overrides.
The Resize will just let you know when the control changes size - don't attempt to draw in this. I doubt you even need this really, as you've always got access to the Width and Height in the Paint method. (Actually, you may want to Invalidate() the whole control as the OnPaint handler will clip to just new areas that weren't there prior to the resize - if you need the whole shape to resize you will need to do this).
All drawing should always be done in the OnPaint method. The Width and Height tell you the dimensions. If ever you want to redraw something in Windows, Invalidate() the area and get the OnPaint method to do the drawing.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks for the help guys (and 4 not flaming )
I already knew about the resize and paint events and have handled them correctly (or at least i think i have)
what i specifically need help with is getting the shapes to appear with a button click (multiple shapes each on a separate button) and the resizing of the shape as the form is resized
just a note
in the resize event i have the code
this.refresh();
is that all that goes in that section or is that where i put my code to resize the shape as well?
thanks again
|
|
|
|
|
you should not need to specifically handle resizing the shape if every time it is drawn it uses the width and height of the form.
In paint event...
e.Graphics.DrawElipse(Pens.Red, 0, 0, this.Width, this.Height);
In resize event...
this.Invalidate();
Can you please explain in more details what your buttons are required to do?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
ok, the buttons are meant to trigger the drawing of the object (shape)
I am using a static class to hold the code to draw the shape and then calling it to the form in the paint event to draw them (I think that's how to explain it)
so in the class i have
public static void Square(Graphics g)
{
g.DrawRectangle(Pens.Blue, 10, 10, this.width, this.height);
}
and in the form itself i have
Draw.Triangle(e.Graphics);
so when the button called circle is pressed it triggers the command that calls upon the class to draw a circle
with the this.height and this.width how to I tell the class the height and width of the form
I hope this clears everything up, if not let me know
|
|
|
|
|
Ok, i understand a little better now. Thou im not sure of your question. But i will try to explain how you should handle what you are trying to do...
You should use a class for each of your shapes (triangle, square, etc.) each of these classes should contain the properties for that shape such as location, size, colour etc. (perhaps you could use a 'shape' base class and derive your shapes from that). Each of these classes should contain a method for drawing that takes a Graphics parameter.
Then in your main class you have a collection of shapes, then in your paint event for you panel/form you simple loop the collection and call the draw method on each shape by passing the graphics instance from the paintEventArgs.
So Then all you need to do on button clicks is to create a shape, set the properties, add it to the collection, then call invalidate() for the panel/form.
Next, to accomplish the task of resizing the shapes. I assume it would be logical to resize all the shapes on the screen. So create a handler for the Resize event of the form. Then in here you can go through your collection of shapes and change the location/size as needed. You could also modify the shapes Draw method to take parameters for the width/height of the form and draw each time based on that. Then you just need to call Invalidate() in the resize event.
Hope this helps
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
The only thing i don't understand is that I thought it would be more appropriate to use a refresh event opposed to the invalidate event you suggested, is there a significant difference in the two events?
Ok what i have from the ground up is:
A class called shapes which contains all the code for drawing the shapes
public static void Square(Graphics g)
{
g.DrawSquare(Pens.Blue, 10, 10, this.width, this.height);
}
etc
and then in the form i have a resize event which contains the code to draw the shapes
private void DrawBoard_Paint(object sender, PaintEventArgs e)
{
Draw.Square(e.Graphics);
}
and for the resize event I have
private void DrawBoard_Resize(object sender, EventArgs e)
{
this.Refresh();
}
what i specifically need help with is (as said by someone else) to "call the function that you have written in the class." because it's multiple shapes being drawn and each being drawn on demand not when the app starts and I also need to pass the width and height parameter on the click event I would assume.
in a nutshell I don't know the code to cause the click event to call upon the function in the class that draws the shape as well as the code to pass the width and height to the class
Thanks in advance.
modified on Wednesday, April 29, 2009 7:13 AM
|
|
|
|
|
ok so if i got you correctly...
your square function needs to have additional params for the height and width values.
your button should also call this.Invalidate() which should result in the square being drawn
Johnny Jackson wrote: is there a significant difference in the two events?
Not entirely sure but i think Invalidate() redraws the control itself, and Refresh() redraws the control and all child controls within it.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
hi,
I want to create a Excel file in server from my web application.Is it possible?can i use open office in C#?
Regards,
justindhas
|
|
|
|
|
Which do you want, Excel or OpenOffice Calc?
You decide, then perhaps someone can help.
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 am working on a Project (Kind of CMS). Here we want to upload the word document. And while uploading word document we need to convert them to HTML file. , need to fetch Images and stored them in local directory. Now we need to save the HTML (with Image link changes to the images saved in Local folder) in data base. In the same manner we do saving HTML while using any Rich editor.
We will be using Word 2007 documents only. Any help in this regard will be greatly appreciated.
|
|
|
|
|
I have an application with a function which needs to be run as administrator, but it needs to be the administrator of another account.
Maybe this is not clear at all, so i'll specify my question
user1 runs an application
user1 presses a button which results in running another application
this other application has a manifest file which says to the uac that it needs to be runned with elevated rights
But i don't want this second application to be run with elevated rights from user1, but from user2 (user2 is a domain administrator, user1 is not)
Over the shoulder credentials is turned of on every pc here, so there is no way the user1 can change to user2 (his domain administrator account).
I've been googling for a solution for this problem, but i cannot find anything useful. Is there anyone who can point me in the right direction. I only want vista to prompt me for giving a user and pasword for running this application as a domain admin..
Thanks in advance to anyone who can point me in the right direction
edit: should i have posted this under the vista forum
|
|
|
|
|
Yes, this is a question about Vista's UAC not the application itself
|
|
|
|
|
ok thanks, i reposted this question in the vista forum.
|
|
|
|
|