Click here to Skip to main content
15,887,477 members
Home / Discussions / C#
   

C#

 
AnswerRe: About filealign compiler option Pin
Dave Kreskowiak19-Sep-05 8:05
mveDave Kreskowiak19-Sep-05 8:05 
GeneralRe: About filealign compiler option Pin
Dario Solera19-Sep-05 21:51
Dario Solera19-Sep-05 21:51 
Questioncalling a function in reflection Pin
Yoyosch19-Sep-05 6:21
Yoyosch19-Sep-05 6:21 
AnswerRe: calling a function in reflection Pin
leppie19-Sep-05 7:13
leppie19-Sep-05 7:13 
AnswerRe: calling a function in reflection Pin
Andy Moore19-Sep-05 7:28
Andy Moore19-Sep-05 7:28 
QuestionRe: calling a function in reflection Pin
Yoyosch20-Sep-05 6:41
Yoyosch20-Sep-05 6:41 
QuestionDataGrid values Pin
zaboboa19-Sep-05 6:05
zaboboa19-Sep-05 6:05 
QuestionTextbox visibility and data binding Pin
Wjousts19-Sep-05 6:01
Wjousts19-Sep-05 6:01 
I have a datatable containing a date field which I have databound to a textbox on a form (the textbox is read only). Sometimes the date field is null, so in those cases I want to have the textbox (and it's associated label) disappear completely. I tried intecepting the Binding.Format event to example the value from the data source and set the visibily of the textbox control like this (tbValidTo is the textbox, lblValid is just a label):

<br />
		private void tbValidTo_Format(object sender, ConvertEventArgs e)<br />
		{<br />
			if (e.Value == DBNull.Value)<br />
			{<br />
				if (tbValidTo.Visible)<br />
				{<br />
					tbValidTo.Visible = false;<br />
					lblValid.Visible = false;<br />
				}<br />
			}<br />
			else<br />
			{<br />
				if (!tbValidTo.Visible)<br />
				{<br />
					tbValidTo.Visible = true;<br />
					lblValid.Visible = true;<br />
				}<br />
				DateTime dt = DateTime.Parse(e.Value.ToString());<br />
				if (dt<DateTime.Now)<br />
				{<br />
					lblValid.ForeColor = Color.Red;<br />
				}<br />
				else<br />
				{<br />
					lblValid.ForeColor = SystemColors.WindowText;<br />
				}<br />
				e.Value = dt.ToString("MMMM d, yyyy");<br />
			}<br />
		}<br />


The problem is that this code is acting really weird. As you flick between records it sometimes fails to update the textbox and instead contains the old value. Sometimes it fails to reappear when flicking from a null date record to a record with a data. When I set a breakpoint at the begining of the event I can see that usually the event fires only once when you change records but sometimes it fires 3 times (it gets as far as setting the visibility and then suddenly refires) and other times it doesn't fire at all. Can anybody suggest what the problem here might be? I have another double field that also get's hidden and it works fine so long as the date field is disabled, otherwise it does the same thing. Other fields (that don't get hidden but do get formatted) behave just fine.
QuestionSorting Arraylists Twice Pin
jgallen2319-Sep-05 5:30
jgallen2319-Sep-05 5:30 
AnswerRe: Sorting Arraylists Twice Pin
Stefan Troschuetz19-Sep-05 7:50
Stefan Troschuetz19-Sep-05 7:50 
Questioncombo boxes not updating Pin
Tom Wright19-Sep-05 5:22
Tom Wright19-Sep-05 5:22 
AnswerRe: combo boxes not updating Pin
KaptinKrunch19-Sep-05 7:21
KaptinKrunch19-Sep-05 7:21 
QuestionOptions Design Pin
OmegaSupreme19-Sep-05 4:58
OmegaSupreme19-Sep-05 4:58 
QuestionRegular Expression for images Pin
brunoconde19-Sep-05 3:57
brunoconde19-Sep-05 3:57 
AnswerRe: Regular Expression for images Pin
User 665819-Sep-05 4:25
User 665819-Sep-05 4:25 
QuestionCyclic Visual Pin
PHDENG8119-Sep-05 3:28
PHDENG8119-Sep-05 3:28 
Questionsave file dialog Pin
Mridang Agarwalla19-Sep-05 2:48
Mridang Agarwalla19-Sep-05 2:48 
AnswerRe: save file dialog Pin
enjoycrack19-Sep-05 2:52
enjoycrack19-Sep-05 2:52 
Questionlatebinding Word Pin
KKuehnberger19-Sep-05 2:47
KKuehnberger19-Sep-05 2:47 
AnswerRe: latebinding Word Pin
John Fisher19-Sep-05 6:07
John Fisher19-Sep-05 6:07 
GeneralRe: latebinding Word Pin
KKuehnberger19-Sep-05 6:48
KKuehnberger19-Sep-05 6:48 
GeneralRe: latebinding Word Pin
John Fisher19-Sep-05 13:57
John Fisher19-Sep-05 13:57 
Questionporting c# aplplications to linux Pin
Mridang Agarwalla19-Sep-05 2:35
Mridang Agarwalla19-Sep-05 2:35 
AnswerRe: porting c# aplplications to linux Pin
enjoycrack19-Sep-05 2:56
enjoycrack19-Sep-05 2:56 
AnswerRe: porting c# aplplications to linux Pin
Mohamad Al Husseiny19-Sep-05 8:55
Mohamad Al Husseiny19-Sep-05 8:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.