 |

|
DaveyM69 wrote: Non private fields are generally not considered a great idea.
But calling child methods in a ctor is?
DaveyM69 wrote: it implies to inheriting classes that the fields that are protected by the property can be changed after initialization
A child can misuse the contract with a parent in any number of ways. There is no way to prevent that.
|
|
|
|

|
The reason this is a warning is because you can get yourself into some really nasty messes by doing this, if you don't understand it. The virtual method that you override in the subclasses is run with an incompletely initialised object – in particular its own constructor has not yet run so you don't have access to any instance variables, even those set in a constructor or in field initialisers (as they're compiled into the constructor too).
You've obviously simplified your example a lot and in this case you can provide a protected setter for Id and create the specific data objects in the subclass constructors. I'd say that's a better approach if it's possible.
|
|
|
|

|
Yeah, that's quite possible and may be what I end up doing.
I'd like to mark the relevant fields (at least in the base) read only ideally which is primarily why I'm trying to manipulate from the constructor, along with the fact that this is all to do with construction of the objects so it is the logical place!
|
|
|
|

|
I'm making a music player in C# wpf. I have a listview which itemssource is an observable collection. The song which is currently playing is the song at the current ActiveIndex,
public int ActiveIndex { get; set; }
Not the song at the listview selected index. ActiveIndex changes only when a user double clicks a song in the listview or when he presses the next/previous buttons.
I have a style for a listview row when listview selected index changes, now I want to color the background of a row when the active index changes. I'm thinking this could somehow be done with datatriggers but I have no idea how to do it.
|
|
|
|

|
Hi. I'm probably making some subtle (or more likely not so subtle) error. I'm trying to drive MMC via a C# program. I can, as a trial, get to the menus of Calc.exe via this code:
Process calcProcess=Process.Start("c:\\windows\\system32\\calc.exe");
Thread.Sleep(2000);
AutomationElement aeDesktop = AutomationElement.RootElement;
AutomationElement aeCalc = null;
int numWaits = 0;
do
{
aeCalc = aeDesktop.FindFirst(TreeScope.Children,
new PropertyCondition(AutomationElement.NameProperty, "Calculator"));
Console.WriteLine("Looking for calculator . . . ");
++numWaits;
Thread.Sleep(100);
} while (aeCalc == null && numWaits < 10);
if (aeCalc == null)
throw new Exception("Failed to find calc.EXE");
else
Console.WriteLine("Found it!");
AutomationElementCollection menuCalcBars = aeCalc.FindAll(TreeScope.Children, new PropertyCondition(
AutomationElement.ControlTypeProperty, ControlType.MenuBar));
And I get a Count of 1 (for the one menu). BUT when I do this with MMC, I get a count of 0, no menu. In UISpy I can see the Calc menu but I can't see the MMC menu. Any help is GREATLY appreciated.
Ron
|
|
|
|
|

|
we dont provide any programs here we provide solutions to the problems for ppl like you. None is going to write a program for you here but ready to help you when you are stuck with your programs.
you can use FileCopy[^] method to copy/move your files?
Jibesh V P
|
|
|
|

|
you will need to look into the following class
DirectoryInfo[^]
I would particularly look into the exists method for checking to see if your directory exists, getfiles so that you can look at the files that exist in the directory as you will need to implement logic if the folder and files already exist.
And as the other poster has stated you then need to look into File.Copy[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|

|
Hi,
i am using .Net 2.0.
here i am using data set to retrieve value from data base and then binding it with data grid view.
but it's not displaying appropriately.
here is my code.
DataAdapter d=new DataAdapter();
select command fro data adptr.
dataSet ds=new dataSet();
d.Fill(ds);
Gridview1.datasource=ds;
gridview1.databind();
i changed auto-generate property of gridview to true also..
|
|
|
|

|
did you check the table has any rows in it?
Jibesh.V.P
India
|
|
|
|

|
yes...
data set is displaying just above the GridView.
with the specific records...
but not inside the GridView....
|
|
|
|

|
can you copy the screen shot of the screen ?
Jibesh V P
|
|
|
|

|
i took screen shoot then only...but was not there. please tell me hw to post screen shoot
|
|
|
|

|
you can use any free image hosting site. try this[^]
Jibesh V P
|
|
|
|
|

|
Yes. I can see the image. instead the dataSource as such can you bind with the dataTable inside the dataSource.
eg: datagridview1.DataSource = dataSet.Tables[0];
Jibesh V P
|
|
|
|
|

|
will try to find an answer. not a webExpert so it might take some more time than usual, if you can e-mail the webpage files i dont need to create on by my own.?
Jibesh V P
|
|
|
|

|
aman1124 wrote: gridview1.databind(); According to Microsoft this method is only used in Webforms. Is this an ASP.NET or pure .NET application?
One of these days I'm going to think of a really clever signature.
|
|
|
|

|
by looking at the image[^] they shared it looks like ASP.Net application but not sure what it is.
Jibesh V P
|
|
|
|
|

|
Then you should use the ASP.NET forum.
One of these days I'm going to think of a really clever signature.
|
|
|
|

|
i work with webbrowser for showing simple text. i am in situation where i want that when user drag any file on webbrowser control then i want to show a icon for that file and one progressbar and one button programmatically. i manage to show file associated icon ob richtextbox just like using System.Drawing.Icon.ExtractAssociatedIcon(string filePath)
here is the code for handling file drag drop on richtextbox like below one
public Form1()
{
InitializeComponent();
richTextBox1.AllowDrop = true;
this.richTextBox1.DragEnter += new DragEventHandler(richTextBox1_DragEnter);
this.richTextBox1.DragDrop += new DragEventHandler(richTextBox1_DragDrop);
}
void richTextBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
if ((e.Data.GetDataPresent(DataFormats.FileDrop)))
{
e.Effect = DragDropEffects.Copy;
}
}
void richTextBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
string strFilePath = ((Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
Icon oIcon= System.Drawing.Icon.ExtractAssociatedIcon(strFilePath);
Bitmap myBitmap = new Bitmap(oIcon.ToBitmap());
Clipboard.SetDataObject(myBitmap);
DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap);
richTextBox1.Text = "";
if (richTextBox1.CanPaste(myFormat))
{
richTextBox1.Paste(myFormat);
richTextBox1.AppendText(" " + System.IO.Path.GetFileName(strFilePath));
}
else
{
MessageBox.Show("The data format that you attempted site" +
" is not supportedby this control.");
}
}
here is one image link for your visualization purpose http://i.stack.imgur.com/5oRkt.png
i want to accomplish the same thing for webbrowser control for handing file drag drop and want to show one file associated icon and one progressbar and one button. please guide me with sample code for doing with webbrowser control. thanks
tbhattacharjee
|
|
|
|

|
knightonline "SendKeys" or similar code does not work
|
|
|
|

|
We have no idea what you're talking about.
But, if you're trying to use SendKey with a DirectX based game chances are really good it's not going to work.
|
|
|
|

|
So how do I run it? because there are those who
|
|
|
|

|
You might want to provide some details as to what you're doing. I have no idea what "KnightsOnline" is and what you're trying to do.
You also might want to use complete sentences. "Because there are those who" doesn't make any sense to me.
|
|
|
|

|
for example, the game will come down in the right-click mouse. or 1 or 2 key are flat
|
|
|
|

|
I don't know what you're talking about.
Assume I know NOTHING about KnightOnline, since I don't. I have no idea what you're doing and you're not providing any background information to tell me what I need to know.
|
|
|
|

|
Dave Kreskowiak, ty bro !
do you have someone who can help ?
|
|
|
|

|
"SendKey" and an online game makes me think you are trying to write a bot or something of that nature. Is that correct?
If so, then perhaps the game servers have some sort of bot-detection system built in that is simply gobbling up your requests and ignoring them.
I wasn't, now I am, then I won't be anymore.
|
|
|
|

|
I'm not your "bro".
And it's unlikely anyone can help because you haven't given all the background information required to figure out what you're doing.
|
|
|
|

|
If you can't explain your problem properly, we can't help. So far you haven't posted a single coherent thought. Tell us what you are trying to accomplish and don't assume that we can figure your problems out with random phrases.
|
|
|
|

|
Try SendMessage with types 0x100 (key down) and 0x101 (key up). The keycode goes in wParam.
|
|
|
|

|
Here is the documentation for SendKeys[^]. This could help you out (no idea what knightonline is).
|
|
|
|

|
Hi,
SendKeys.SendWait[^] can help you.
ismail20 wrote: knightonline
What's knightonline? If you refer in your question to "knightonline", then you need to tell what it is.
In some cases, my signature will be longer then my message...
<em style="color:red"> <b>ProgramFOX</b></em> ProgramFOX
|
|
|
|

|
..and just like with Warcraft, there are limits to what you can and are allowed to do. Their website has it's own forum, I suggest you post your question there. And don't be surprised if it's labeled "cheating"
|
|
|
|

|
Eddy Vluggen wrote: don't be surprised if it's labeled "cheating"
In some cases, my signature will be longer then my message...
<em style="color:red"> <b>ProgramFOX</b></em> ProgramFOX
|
|
|
|

|
i have latitudes and longitudes i want to calculate distance between those latlongs and also how to retrieve existed latlongs from database like sql in c#
|
|
|
|

|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Edit your question and provide better information.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|

|
Well, if your database doesn't support geo types, you could always store them as floats. To get the difference, use the Haversine[^] formula.
|
|
|
|

|
How about some codez:
public double HaversineDistance(Location location) {
double R = 6371; double dLat = (location.Latitude - Latitude).ToRadians(); double dLon = (location.Longitude - Longitude).ToRadians();
double a = Math.Pow(Math.Sin(dLat / 2), 2) +
Math.Cos(Latitude.ToRadians()) * Math.Cos(location.Latitude.ToRadians()) *
Math.Pow(Math.Sin(dLon / 2), 2);
double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
double d = R * c; return d;
}
|
|
|
|

|
naveen 2012 wrote: calculate distance between those latlongs
"Great circle" distance? Or "rectilinear" distance? Or "digging a hole to China" distance?
P.S. I forgot about the "Dalek Dave Pub Crawl Distance".
|
|
|
|

|
<div class="bo9 space">
<table border="0" cellspacing="0" cellpadding="0" class="bot">
<thead>
<tr>
<th class="bor f2" colspan="13"><h2>Mở thưởng chủ nhật ngày 30/12/2012</h2>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="span-2 bol f1b db"><h3>Đặc Biệt</h3></td>
<td class="bor f2 db" colspan="12">21505</td>
</tr>
<tr>
<td class="span-2 bol f1b"><h3>Giải Nhất</h3></td>
<td class="bor f2" colspan="12">00305</td>
</tr>
<tr>
<td class="span-2 bol f1b"><h3>Giải Nhì</h3></td>
<td class="bol f2" colspan="6">16086</td>
<td class="bor f2" colspan="6">54638</td>
</tr>
<tr>
<td class="span-2 bol f1b" rowspan="2"><h3>Giải Ba</h3></td>
<td class="bol f2" colspan="4">85671</td>
<td class="bol f2" colspan="4">74937</td>
<td class="bor f2" colspan="4">60046</td></tr>
<tr><td class="bol f2" colspan="4">48910</td>
<td class="bol f2" colspan="4">28668</td>
<td class="bor f2" colspan="4">73173</td>
</tr>
<tr>
<td class="span-2 bol f1b"><h3>Giải Tư</h3></td>
<td class="bol f2" colspan="3">2979</td>
<td class="bol f2" colspan="3">1875</td>
<td class="bol f2" colspan="3">9307</td>
<td class="bor f2" colspan="3">1100</td>
</tr>
<tr>
<td class="span-2 bol f1b" rowspan="2"><h3>Giải Năm</h3></td>
<td class="bol f2" colspan="4">7891</td>
<td class="bol f2" colspan="4">4924</td>
<td class="bor f2" colspan="4">2383</td></tr>
<tr><td class="bol f2" colspan="4">6579</td>
<td class="bol f2" colspan="4">7116</td>
<td class="bor f2" colspan="4">1362</td>
</tr>
<tr>
<td class="span-2 bol f1b"><h3>Giải Sáu</h3></td>
<td class="bol f2" colspan="4">376</td>
<td class="bol f2" colspan="4">929</td>
<td class="bor f2" colspan="4">292</td>
</tr>
<tr>
<td class="span-2 bol f1b"><h3>Giải Bảy</h3></td>
<td class="bol f2" colspan="3">48</td>
<td class="bol f2" colspan="3">15</td>
<td class="bol f2" colspan="3">65</td>
<td class="bor f2" colspan="3">62</td>
</tr>
<tr>
<th class="bor f1" colspan="13">Nhận KQXS <span class="sred">Thủ Đô</span> : Soạn <span class="sred">KXTD</span> gửi <span class="sred">8185</span></th>
</tr>
</tbody>
</table>
</div>
How to extract tab table in this html code use regular expressions?
Thank!
|
|
|
|
|

|
Short.
Sweet.
Accurate.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|

|
PIEBALDconsult wrote: Use an XmlDocument.
Or the HTML Agility Pack[^]!
Bob Dole The internet is a great way to get on the net.
 2.0.82.7292 SP6a
|
|
|
|

|
I suppose, but I prefer to limit reliance on third-party products.
|
|
|
|

|
I have the following function which I got online, and have changed to suit my needs :-
private Boolean SheetExists(string strFilename)
{
Boolean Match = false;
OleDbConnection objConn = null;
System.Data.DataTable dt = null;
try
{
String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + strFilename + ";Extended Properties=Excel 8.0;";
objConn = new OleDbConnection(connString);
objConn.Open();
dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
String[] excelSheets = new String[dt.Rows.Count];
int i = 0;
foreach (DataRow row in dt.Rows)
{
excelSheets[i] = row["TABLE_NAME"].ToString();
i++;
}
for (int j = 0; j < excelSheets.Length; j++)
{
if (excelSheets[j] == "Sheet1$")
{
Match = true;
}
}
if (Match == true)
return true;
else
return false;
}
finally
{
if (objConn != null)
{
objConn.Close();
objConn.Dispose();
}
if (dt != null)
{
dt.Dispose();
}
}
}
Basically it checks if sheet1 exists in a workbook. I'm currently using the variable "Match" to obtain a "return true" or a "return false". I'm sure it possible to modify the code so that it returns the true/false directly, I just can't figure out how.
Any ideas? Thanks
|
|
|
|

|
Modify your test so it breaks out of the loop as soon as a match is found
for (int j = 0; j < excelSheets.Length; j++)
{
if (excelSheets[j] == "Sheet1$")
{
Match = true;
break;
}
}
//delete the following lines after the loop
if (Match == true)
return true;
else
return false;
// add this line after the finally block
return Match;
[edit]
You could actually check the names in your foreach block to make it more efficient.
[/edit]
One of these days I'm going to think of a really clever signature.
|
|
|
|
 |