|
Not using the standard control.
You could detect the user clicking into the edit box and swap out to a masked textbox, format the data on exit, pass the formatted value back to the dtp.
You will however find there is an endless number of potential formats that you need to cater for and it will drive you absolutely nuts. Most of us have chewed on this over the years. I recommend you simply tell the user it cannot be done, unless that is you have lots of spare time and nothing to fill it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I was afraid of that
I guess i have to wait until my boss is back from his vacation to ask him if i can waste my time with it
Thank you for your reply!
|
|
|
|
|
Is it an option to to put a masked textbox and datetimepicker one over the other with a checkbox next to them?
The Checkbox would toggle the readonly (datetimepicker) or the enter value (masked textbox) on or off.
V.
|
|
|
|
|
I thought of it as one of the possibilities..
thank you for your reply!
|
|
|
|
|
I use linq to sql.
I have a table of employees belong to a company by forigen key as companyID on the employees table. (I have compamies table as my main table)
the linq does it by it's self and knows that the two are related and after binding the context to the datagridview I get the employees table + column of the company name.
my goal is to convert or some how get to the point where I have a coulmn of the employee name and a combobox coulmn of the company which will be bound the companyID. so when I change the company it will know to update the companyID when I submit_changes() on linq context.
tnx
|
|
|
|
|
DataPropertyName
I added a new combobox column during runtime and bound it to the companies table.
set the valuemember and displaymember, and defined DataPropertyName to the same column name as the one I need it to be bound to and vwalla...
any changes made to the combobox saves it automaticly to the database (need to add an event on cell changes the have the context submit_changes() function)
|
|
|
|
|
I have a datagridview with the following code:
private void DgvAfsprakenAgenda_CellClick(object sender, DataGridViewCellEventArgs e)
{
int TempPatientNummer = Convert.ToInt32(this.DgvAfsprakenAgenda.Rows[e.RowIndex].Cells["PatientNummer"].Value.ToString());
}
My problem is as follows:
e.RowIndex is not the correct rownumber, but the shown rownumber in the following conditions:
- the datagridview is sorted in the user interface (by clicking on a column name)
- the user scrolls down to a row not originally visible
It seems that under these circumstances e.RowIndex returns the visible row instead of the row in the datagridview.
Anybody an idea ?
Rob
|
|
|
|
|
Of course it does. What did you expect?
|
|
|
|
|
I expected the rownumber of the datagridview.
I conclude from your answer that it is expected behaviour, so I have to restate the question, how do I find the patientnumber of the shown row, as now I get another rows patientnumber.
Thanks for your initial answer.
Rob
|
|
|
|
|
As a result of the answer of Piebaldconsult I experimented a bit further
I have 35 rows, of which 24 are visible.
I open the form and click the last row e.rowindex is 34 (as expected) and another form is opened.
I close the other form, and click the last row again and e.rowindex is 23
This behaviour I can't explain.
If I sort the form the first click again gives the correct e.rowindex of 34, the subsequent e.rowindex is again 23.
It could be the activated event of this form in which the sort action is performed again:
try
{
DataGridViewColumn dgvColumn = this.DgvAfsprakenAgenda.Columns[Program.AgendaSortColumn];
if (Program.AgendaSortOrder == "A")
{
this.DgvAfsprakenAgenda.Sort(dgvColumn, ListSortDirection.Ascending);
}
else
{
this.DgvAfsprakenAgenda.Sort(dgvColumn, ListSortDirection.Descending);
}
this.tbSorteer.Text = Program.AgendaSortColumn.ToString();
}
catch
{
}
Obviously I'm doing something wrong here...
|
|
|
|
|
The problem is solved, perhaps for future reference the solution:
If I perform:
int FirstShownRow = this.DgvAfsprakenAgenda.FirstDisplayedScrollingRowIndex;
before the resort and:
this.DgvAfsprakenAgenda.FirstDisplayedScrollingRowIndex = FirstShownRow;
after the resorting I allways get the correct rowindex back.
Thanks
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class A
{
}
class B:A
{
}
class c
{
static void Main(string[] args)
{
B obj1 = new A();
}
}
}
will it execute ?? and if not can anyone give me the exact answer ??? i am new to C#..!!
|
|
|
|
|
No. It won't compile - it will complain that you cannot implicitly cast a Class A to Class B (you can explicitly, but that won't execute either.)
Think about it: if you create an instance of A and try to use it as a B what happens? Any additional elements in B do not exist in your instance of A. For example, if B has a public string called "Text" that is not in A, what happens in your code if you say
static void Main(string[] args)
{
B obj1 = new A();
Message.Show(obj1.Text);
} Where is the Text to come form - it hasn't been allocated in A!
It's like buying a loaf of bread and trying to treat it as a banana!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
|
Is Google broken? Don't have access to a book store?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Looks like an interview question.
Please format all code snippets appropriately
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote: Looks like an interview question.
Really?
|
|
|
|
|
I know shocking to think anyone would post such and obvious message
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Since you deleted your question, I'll reply here. (Please don't delete questions, it leaves the forum with half a conversation - that doesn't help anyone else who has a similar problem)
arindam2010 wrote: Can you please tell me little bit more about casting..??
the code works if i write like this
B obj1 = (B)new A();
what is happening actually here ??
First off, it won't work if you write it like that - it will compile, because you are using an explicit cast. But when you try to run it, you will get a run-time exception along the lines of "unable to cast from type A to type B" and your program will stop. Why? Because it would need to invent information, and it doesn't know how to do that.
When you cast from an integer to a float, it knows what to do: add "0.0" and call it a float! When you cast from a float to an integer, it knows what to do: Throw away any digits to the right of the decimal point.
When you cast from one of your classes to another, it doesn't know what is happening. It knows they are different, but it doesn't know how to make them the same.
Think of it this way: If you have a Ford Ka, and fit a Ferrari badge instead of the blue oval, will it out accelerate a Porche? No - it is still a Ford, but it looks a bit different - and won't fool anyone.
You can down cast from a derived class to the class it derived from (because everything in the source class is still there in the derived class), and you can cast that back to the derived class (because it started out as the derived class and in real terms, it still is - you just changed the name).
This is a bit complex to explain without face to face and maybe some diagrams - I would suggest you discuss this with your tutor as he/she will have explained this many times before!
[edit] Left? Right? My right hands side doesn't know whet my left hand side is doing... [/edit]
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
modified on Thursday, September 16, 2010 2:50 PM
|
|
|
|
|
OriginalGriff wrote: When you cast from a float to an integer, it knows what to do: Throw away any digits to the left of the decimal point. ???
|
|
|
|
|
Can I blame Arabic numbers?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
OriginalGriff wrote: Can I blame Arabic numbers
You can blame them. It doesn't mean we necessarily believe you.
|
|
|
|
|
Pete O'Hanlon wrote: It doesn't mean we necessarily believe you
Damn. And it sounded like such a good excuse...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
You got an answer the first time you posted it in questions/answers.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hi,
Please guide me to create XML file using XSD.
Thanks in advance.
|
|
|
|