|
Hi
I know how can i open Combobox dropdown list :
<br />
ComboBox1.DoDragDrop();<br />
But i want to close it programmatically. I want to use it in my custom UserControl like Visual Studio DateTimePicker control. Clicking on it's ComboBox does't cause to openning dropdown list and just show Date Panel.
Tanx.
|
|
|
|
|
DoDragDrop does not drop down the combo box, it starts a drag-and-drop operation. If you want the combo box list to drop down, use the ComboBox.DroppedDown[^] property. You can close it by setting that property to false , open it by setting the property to true .
|
|
|
|
|
Hi,
On some system the showDialogue shows up, on some it is minimized.
I am new to C#, can someone help in showing this dialogue normal.
<br />
public long ShowDialog()<br />
{<br />
long rc = 0;<br />
<br />
try<br />
{<br />
m_dlg = new ScheduleEditor();<br />
if ( m_dlg.Initialize(m_InitData) )<br />
{<br />
m_dlg.StartPosition = FormStartPosition.CenterScreen;<br />
<br />
System.Windows.Forms.DialogResult result = m_dlg.ShowDialog();<br />
switch(result)<br />
{<br />
case System.Windows.Forms.DialogResult.OK:<br />
rc = 0;<br />
break;<br />
case System.Windows.Forms.DialogResult.Cancel:<br />
rc = 1;<br />
break;<br />
}<br />
<br />
m_dlg.EndDialog();<br />
}<br />
m_dlg = null;<br />
}<br />
catch<br />
{<br />
m_dlg = null;<br />
}<br />
GC.Collect();<br />
<br />
return rc;<br />
}<br />
|
|
|
|
|
AnilUnni wrote: GC.Collect();
NEVER do this.
AnilUnni wrote: case System.Windows.Forms.DialogResult.OK:
put using System.Windows.Forms at the top, then just use DialogResult.OK, etc.
AnilUnni wrote: m_dlg.EndDialog();
What does this do ?
AnilUnni wrote: if ( m_dlg.Initialize(m_InitData) )
Why do you need to do this ?
AnilUnni wrote: _dlg.StartPosition = FormStartPosition.CenterScreen;
You can set this on the form itself in the designer.
AnilUnni wrote: m_dlg = new ScheduleEditor();
AnilUnni wrote: m_dlg = null;
In fact, you should have called m_dlg.Dispose(), but, more to the point, why do you have a member if you reset it every time ? Just declare it locally.
A form has a WindowState variable, if the form is minimised, this has been set to minimised somewhere.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
m_dlg.WindowState = FormWindowState.Normal;
I did this but still it shows the dialog state minimized.
Is there any other property i need to consider?
|
|
|
|
|
Ooops I am sorry., I got it.
private void ScheduleEditor_Load(object sender, System.EventArgs e)
{
this.TopMost = false;
// make it visible
this.Opacity = 1;
}
Someone was doing a false. Thanks for the suggestion.
|
|
|
|
|
Hello everyone,
I am using the following code to get the DVD information. I have realised that in the case that the system has both DVD Drive and CD drive, this code gets the info. of the disc on the both drives.
This means eventhough the DVD Drive is loaded by a DVD Disc, the code still trys to get the info on the CD Disc which is not what I wish to have.
I was wondering if there is anyway that I can only get the DVD drive info and not the CD drive.
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
how can convert using DNS from computer name to IP address??
|
|
|
|
|
IPAddress[] ip = Dns.GetHostAddresses("MyHostName");
|
|
|
|
|
Every morning, we receive an excel file from our client which needs to be opened and read by our application. The problem however, is the filename of this excel file differs every morning (the filename represents the exact time in milliseconds when our client generated their file on each day). If the filename was consistent, I would have no problem opening it, however since the name is never the same, I don't know how to programatically open it.
This file is stored in a directory by itself (the prior days file is moved to a different directory).
So does anyone know how to open this file without knowing the filename?
Thanks.
-Goalie35
|
|
|
|
|
Directory.GetFiles will tell you what is there.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Yes chris is right. You know all the prior files would be moved to different directory. so use that function to get the files in that directory,and open the file which is having .xls extension (i hope there will be one file in that directory)
Thanks
Srini
|
|
|
|
|
I'm new at this and am having a problem. I have a one dimensional array with a group of fields filled and need to extract the information in them and list how many times they were used.
Example 1:
int[] numbers = new int[30] {1, 3, 5, 2, 4, 6, 6, 4, 9, 1, 5, 5, 3}
I need to be able to do the following:
Numb // Amount
used: // used:
1 // 2
2 // 1
3 // 2
4 // 2
5 // 3
6 // 2
9 // 1
Can anyone point me in the right direction for the information on how to do this. Any and All help will be appreciated.
|
|
|
|
|
OK, I guess the way to do this, is to use for each to step over your array, and set up a counter for each number you want to track. There are a few ways of doing this, they would include:
create a new array that has the number of elements equal to the highest number in your list, it's an array of numbers, and you set them to 0, and for example, if you find the number 5, you set newArray[5] to be one greater than it was.
Create a struct like this
struct numbers
{
int value;
int times;
}
Then, you create an array of these structs and you find the right one to increment times by.
( the next one is the best )
Dictionary<int, int> times = new Dictionary<int, int>(); // A dictionary is an associative array, we are using numbers, but we can store anything
foreach(int n in numbers)
{
if (!times.KeyExists(n))
{
// Add a key to the dictionary
times[n] = 0;
}
++times[n];
}
Then you can iterate over the keys and use the values to see how many times each one exists.
I suspect this is homework. If it is, then you should do some reading on how the dictionary container works, so you fully understand it. Otherwise, you won't be able to turn the above into code that fully works, nor will you be able to withstand the scrutiny of your teacher when she asks why you did it this way.
-- modified at 18:59 Monday 2nd April, 2007
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I need to remove all comments ( between tags) from XML string.
I tried the following code but comments are still present.
How to remove comments ?
string RemoveComments(string sDoc) {
XmlDocument xDoc = new XmlDocument();
xDoc.PreserveWhitespace = false;
xDoc.LoadXml(sDoc);
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);
xtw.IndentChar = ' ';
xtw.Indentation = 2;
xtw.Formatting = Formatting.Indented;
xDoc.WriteContentTo(xtw);
xtw.Close();
sw.Close();
return sw.ToString();
}
Andrus
|
|
|
|
|
Pseudo code but it should give you an idea
XPathNavigator nav = xDoc.CreateNavigator();
while(nav.MoveToNext(XPathNodeType.Comment))
{
}
only two letters away from being an asset
|
|
|
|
|
Thank you.
I tried the folowing code but comments are still present.
What I'm doing wrong.
string RemoveComments(string sDoc) {
XmlDocument xDoc = new XmlDocument();
xDoc.PreserveWhitespace = false;
xDoc.LoadXml(sDoc);
XPathNavigator nav = xDoc.CreateNavigator();
while (nav.MoveToNext(XPathNodeType.Comment)) {
nav.DeleteSelf();
}
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);
xtw.IndentChar = ' ';
xtw.Indentation = 2;
xtw.Formatting = Formatting.Indented;
xDoc.WriteContentTo(xtw);
xtw.Close();
sw.Close();
return sw.ToString();
}
Andrus
|
|
|
|
|
How about opening the xml file with a StreamReader, read all the text inside and remove all the "" substrings?
|
|
|
|
|
Thank you.
Can you give example how to implement this ?
I'm bit new to C#
Andrus
|
|
|
|
|
Try this:
StreamReader sr = new StreamReader("myOldFile.xml");<br />
StreamWriter sw = new StreamWriter("myNewFile.xml");<br />
<br />
string theText = sr.ReadToEnd();<br />
sr.Close();<br />
<br />
theText = theText.Replace("<!--", "");<br />
theText = theText.Replace("-->", "");<br />
<br />
sw.Write(theText);<br />
sw.Close();
Have a nice day!
|
|
|
|
|
Thank you.
I'm sorry maybe my question was incorrect.
I need to remove comment tags including their contents.
Result must be valid XML.
Your code removes only comment tags.
Result is not valid XML.
How to remove comment tags contents also ?
Is it possible to use some strign function which removes also all characters between comment tags ?
Andrus
|
|
|
|
|
Thank you.
I'm sorry maybe my question was incorrect.
I need to remove comment tags including their contents.
Result must be valid XML.
Your code removes only comment tags.
Result is not valid XML.
How to remove comment tags contents also ?
Is it possible to use some string function which removes also all characters between comment tags ?
Andrus
|
|
|
|
|
I have a large datagrid which I can filter by changing the query and reloading the datagrid but this takes time as its a large amount of data. Is there a way to filter a datagrid without having to reload the data?
|
|
|
|
|
Use a DataView and filter that. So your code would be something like this, assuming you have a single table returned from your dataset.
DataView dv = dataSet.Tables[0].DefaultView;
dv.RowFilter = "ColumnName = 'value'";
dataGrid.DataSource = dv;
dataGrid.DataBind();
At least that should be pretty close to some code that would work.
Hope that helps.
Ben
|
|
|
|
|
Thanks worked like a charm.
|
|
|
|