|
No, You didnt understand my Question
you have to choose :you should enter data in Cell[2] Or Cell[3] (I mean the user will select and when one has data the onther one will be filled with data Automatically)
Thanks for reply
Please HELP !
|
|
|
|
|
I have been looking at your problem since I got your message. I now understand what you require but unfortunately I cannot find a way to do it.
d@nish was quite right in saying that all you have to do is set CurrentCell to the value you want. Just put a Button on your Form and in its' Click event handler put the following:
private void button1_Click(object sender, EventArgs e)
{
dataGridView1.CurrentCell = dataGridView1[3, 0];
}
and regardless of where you select in the DGV, each time you click the button the [3, 0] cell is selected. No problem.
The problem is in finding an event to handle where you can both check the values for the two cells (that bit is relatively easy) and also set the CurrentCell without throwing an exception (that is where the problems occur).
It is now time for my cocoa and bed but I will keep thinking about this and will get back to you if I find an answer.
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.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
I have a (sort of) solution. It is not perfect and that bothers me but I cannot spend any more time on this.
I hope that it will at least give you a starting point for a solution of your own.
I tested this using a DataGridView with four text columns. The second column (columnIndex 1) should contain "Home" to be considered valid and cause a jump to the fourth column, and the third (columnIndex 2) should when editing reaches there should contain "Business" to be valid.
private bool IsValidColumn1Response(DataGridViewCell dgvCell)
{
return (dgvCell.Value == null) ? false : dgvCell.Value.ToString() == "Home";
}
private bool IsValidColumn2Response(DataGridViewCell dgvCell)
{
return (dgvCell.Value == null) ? false : dgvCell.Value.ToString() == "Business";
}
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
DataGridView dgv = sender as DataGridView;
if (dgv != null)
{
DataGridViewCell currentCell = dgv.CurrentCell;
if ((currentCell != null) && (currentCell.ColumnIndex == 1))
{
int nextRow = currentCell.RowIndex;
int nextCol = currentCell.ColumnIndex;
if (this.IsValidColumn1Response(currentCell))
{
dgv[nextCol + 1, nextRow].Value = "N/A";
nextCol += 2;
}
DataGridViewCell nextCell = dgv.Rows[nextRow].Cells[nextCol];
if (nextCell != null && nextCell.Visible)
{
dgv.CurrentCell = nextCell;
}
}
else if ((currentCell != null) && (currentCell.ColumnIndex == 0))
{
int nextRow = currentCell.RowIndex;
int nextCol = currentCell.ColumnIndex;
if (this.IsValidColumn2Response(dgv[currentCell.ColumnIndex + 2, currentCell.RowIndex]))
{
nextCol++;
dgv[nextCol, nextRow].Value = "N/A";
}
DataGridViewCell nextCell = dgv.Rows[nextRow].Cells[nextCol];
if (nextCell != null && nextCell.Visible)
{
dgv.CurrentCell = nextCell;
}
}
}
}
As you will see, if you try this out, there are some problems particularly with going back and changing already entered text. It is, however, a start.
Good luck!
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.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
Handle CellLeave event and set the active/current cell in the event handler.
|
|
|
|
|
Hi, thanks for reply
Is it possible to give a short example.
Thanks
I need it very much.
Thanks
Regards,
Jojoba
|
|
|
|
|
That is exactly what I have been playing with since my previous message to the OP.
Problem is CellLeave fires before the data has actually reached the cell you either get null (for new cell) or the old cell content so there is no value to test against to tell if a jump should be made or not. CellValuePushed is only fired if VirtualMode is true. You cannot set CurrentCell in CellValidating or CellValidated because you get a StackOverflowException. I'm still playing around but this ain't easy.
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.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
Have you tried using the CellValidating event? That's where I've usually done those sort of things after checking to make sure the cell value is valid.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
I've tried to do this in CellValidating , CellValidated and CellParsing . All three throw a StackOverflowException on the line that sets CurrentCell .
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.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
Yes, I see what you mean. It acts as if changing the value of CurrentCell triggers the events all over again.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
i am taking the system date as
DateTime.Now.Date
its giving diffetent values for diferent culture
6/5/2010 12:00:00 AM : for English(United State)
05/06/2010 00:00:00 : for English(United Kingdom)
I want my dates in '6/5/2010 12:00:00 AM' how to get date independent of regional settings
|
|
|
|
|
DateTime is just a long counting ticks IIRC - what you are seeing is just the string representation for the culture in question. Specify your own string format, culture or InvariantCulture.
PiebaldConsult will be here shortly with his ISO comments!
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
As Davey says, DateTime.Now just returns a time - it has no format. When you specify the output format, then you can use the current culture, specify a culture, or fix the format so that it is culture invariant.
Have a look here[^] - it shows all the various parts you can use to format your date.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
As others have pointed out, a DateTime is a region independent structure already. What you are talking about is using a format converter to control how it is displayed.
Before you look at setting the output of the date to be a particular format, I must ask you to consider how your application is going to be used; people have a specific local regional setting in place and generally expect their dates to be displayed in those formats - this can be critical because it has an effect on the understanding of the date. When I looked at your example, my first thought was that you were talking about the 6th of May because I am based in the UK, by displaying a different regional setting you have skewed my understanding of your data.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Ah, DateTime, a perfect source of confusion around the globe. You might want to read this[^]. It holds some cues, including a reference to the infamous ISO 8601.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Thank you for your response. I have found out the solution .
I am setting my Application Culture at startup
Application.CurrentCulture = new CultureInfo("en-US");
|
|
|
|
|
I want to find the handle of parent window containing windowless content. Example of web page containing windowless content is http://www.metacafe.com. On this site video files is getting played in windowless mode i.e. the player is not a window but just an content embedded in some other window (host/parent window). I want to determine handle of this parent window. contrary to this on youtube, the area on which video runs, is in itself a window.
Using spy++, I can determine the hierarchy of window in the IE window and If i will follow this hierarchy I can reach to the host/parent window on metacafe. But I believe it would only be applicable to metacafe. There must be some site which will host windowless content in different windows hierarchy.
So, please let me know if anyone knows how to get window handle of parent/host window containing/hosting windowless content.
Regards
f
|
|
|
|
|
hi,
I have a big problem in building deffrent mode of my application, imagine that we have a project contans of 3 part, for example a,b,c.In part a some codes of b and c must not be compiled in compile time, for this i used #define preproc and now, i need to compile full project by defining a, b or c
there is a command which is csc.exe /define:[a|b|c]
but this command only compiles one file and make exe. Now is there any way to compile a project with defining ? of course not changing source codes!my project considers 1000 source files
|
|
|
|
|
Don't post the same question in the forums and QA - it duplicates work and annoys people.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
You should take a closer look on MSBuild!
|
|
|
|
|
thank you, msbuild has no config for define purpose,has it? please type an example
|
|
|
|
|
You can execute the following command to use your specific #define variable.
For example:
msbuild /t:Rebuild /p:Configuration=Release /p:DefineConstants=YourDefineStatement YourSolution.sln
This will rebuild the specified solution. It will result in a release build with the YourDefineStatement specified as preprocessor define statement.
|
|
|
|
|
kasraa00098000 wrote: but this command only compiles one file and make exe
No, you can compile multiple files or produce a DLL. CSC is called by Visual Studio, so it can compile and produce anything VS can.
|
|
|
|
|
really? how can I compile a csproj file with csc? what about a group of cs file?
|
|
|
|
|
I know nothing about regex. I want to replace some charaters in a string.They are:
+ --> {+}
^ --> {^}
% --> {%}
{ --> {{}
} --> {}}
Who can give me the C# code? Thanks in advance.
|
|
|
|
|
Why do you have to use a regex? If you're not comfortable writing them and you don't have a complex pattern to parse, then don't bother. You can always use string.Replace instead which would do the job equally well. A lot of times, people are advised to use regular expressions when they don't add value, and it really is a case of using a sledgehammer to crack a nut.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|