I think changing the the FrameWork to which the project is targeted from IDE may be easier than doing it in the code. To change from IDE, right click on Project concerned in the Solution Explorer, select Properties menu option, in the opened form, select the Application tab page and in that select the required FrameWork in the Target Framework combo box.
VJ Reddy
Posts
-
<<specificVersion>>'True'<<specificVersion/>> is not satisfying -
Integer to Time ConversionI think the following points may be helpful. Use
DateTime.ParseExact
to parse the timeDateTime startTime = DateTime.ParseExact("1330","HHmm",
System.Globalization.CultureInfo.InstalledUICulture);similarly parse the end time. Now find the duration between
end time and start time
using theSubtract
method ofDateTime
object which returns aTimeSpan
object. Then get the total minutes using theTotalMinutes
method ofTimeSpan
object. Use theAddMinutes
method ofDateTime
to add minutes to the end time Then get the string representation of modified end time usingstring endTimeString = endTime.ToString("HHmm",
System.Globalization.CultureInfo.InvariantCulture); -
DropDownList is giving following error : System.NullReferenceExceptionAs explained here http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.datakeys.aspx[^] When the DataKeyNames property is set, the GridView control automatically creates a DataKey object for each row in the control. The DataKey object contains the values of the field or fields specified in the DataKeyNames property. The DataKey objects are then added to the control's DataKeys collection. Use the DataKeys property to retrieve the DataKey object for a specific data row in the GridView control. The reason for
null reference exception
in the above code could be due to not setting theDataKeyNames
property but accessing theDataKeys[e.RowIndex]
value atcustomer.Update(Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString())
Try setting the
DataKeyNames
as shown in above reference likedatakeynames="CustomerID"
-
convert part of a list to an arrayThank you :-D
-
convert part of a list to an arrayReally good answer. 5!
-
convert part of a list to an arrayGood answer. 5!
-
convert part of a list to an arrayGood answer. 5!
-
convert part of a list to an arrayI think the
Take
extension method ofIEnumerable
can be used for this purpose as shown below:List<int> data = new List<int>(){1,2,3,4,5,6,7,8,9,10};
int[] array = data.Take(5).ToArray();The
Take
method takes specified number of elements or the total elements of the list if the total is less than the specified number. -
Row Not Found Or ChangedAs observed in the data of line 40 given above in
022N02177
0
iszero
instead of letter'O'
. But if that is the case and the part number is not found then the execution should go in to theif (part == null)
block. But I want to share what I have noticed and please see whether the issue is because of that. -
about calculator in c#If you want to break the text into two parts on entry of
+
character then I think theKeyPress
event ofTextBox
can be handled to replace the+
character with\n
as shown below:TextBox textBox1 = new TextBox();
textBox1.Multiline=true;
textBox1.Height=100;
textBox1.KeyPress += (s, args) => {
if (args.KeyChar=='+')
args.KeyChar= '\n';
};
Controls.Add(textBox1);If you want to retain
+
and then break the text into next line then replaceargs.KeyChar = '\n';
withSendKeys.Send("{ENTER}");
To run the above code, create aWindows Forms application
in C#, place the above code in theForm.Load
event handler and run the application. -
how to display membar and dealing with other in wpfPlease see this reference http://stackoverflow.com/questions/3797034/confused-with-wpf-combobox-displaymemberpath-selectedvalue-and-selectedvaluepath[^] I think it may be helpful.
-
ActiveX controls are not supported.Please these posts http://www.devinfo.org/di-support/users/kb.php?id=10010[^] http://stackoverflow.com/questions/989663/unable-to-get-window-handle-windowless-activex-controls-are-not-supported[^] on similar issue. They may be helpful.
-
include a fileI think if the requirement is to call a function from an unmanaged DLL then
DllImportAttribute class
explained here http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx[^] may be helpful.#define
being a preprocessor directive as explained here http://msdn.microsoft.com/en-us/library/yt3yck0x(v=vs.90).aspx[^] may not be suitable for the specified purpose. -
Expand the text in the RichTextBox.Please see this Code Project article Fast Colored TextBox for Syntax Highlighting[^] by Pavel Torgashov. It may be helpful.
-
Remove a XMLnode - Pls helpYou're welcome. After trying please give your feedback and if it is helpful you may consider to vote. Thank you for the response.
-
Remove a XMLnode - Pls helpThe
ReplaceChild
method ofXmlNode
class explained here http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.replacechild.aspx[^] can be used for replacing the desired nodes as shown below:void Main()
{
string xmlCounters =
@"<GetCountersResult>
<GetCountsResult xmlns="""">
<Count>
<ID>FP108MR</ID>
<Value>0</Value>
<Part>Z9999</Part>
</Count>
</GetCountsResult>
<GetCountsResult xmlns="""">
<Count>
<ID>FP108MR No2</ID>
<Value>0 No2</Value>
<Part>Z9999 No2</Part>
</Count>
</GetCountsResult>
</GetCountersResult>";XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlCounters); var countNodes = xmlDoc.GetElementsByTagName("Count"); //foreach throws, the element list has changed, error for (int i=0; i < countNodes.Count; i++) { xmlDoc.DocumentElement.ReplaceChild(countNodes\[i\], countNodes\[i\].ParentNode); } string fileName = @"F:\\ModifiedXml.xml"; xmlDoc.Save(fileName);
}
//The contents of file
// <GetCountersResult>
// <Count>
// <ID>FP108MR</ID>
// <Value>0</Value>
// <Part>Z9999</Part>
// </Count>
// <Count>
// <ID>FP108MR No2</ID>
// <Value>0 No2</Value>
// <Part>Z9999 No2</Part>
// </Count>
// </GetCountersResult> -
DatagridviewPlease do not post the same question at two locations. This question was already posted under Quick Answers section.
-
handling ctrl+mouse click on webbrowser control in winformYou're welcome. Thank you for the response. If you feel that the answer is helpful then you may consider to vote the answer.
-
handling ctrl+mouse click on webbrowser control in winformPlease see this article. Easy way to add Keyboard and Mouse events to WebBrowser control[^] I think it may be helpful.
-
simple memory leakGood references. 5!