|
Potentially you could change the read only attribute on the file as soon as you open it, and manage it that way (i.e. convert it back to read/write for the file save). This isn't perfect, though, because it would be in line for a race condition occurring.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I need to add rows to that sheet. How can I change it to readonly?
Gurpreet
|
|
|
|
|
As soon as you open the file, change the readonly file attribute to true. Add your rows, and change the attribute to false - save - then reset to true.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi,
I'm using the AODL tooolkit to create spreadsheets.
The problem is, since AODL is part of open office, all the file come out as .ods files.
I'm looking for one of the following solutions:
1. A way to export files to .xls using AODL (i've searched for way of doing this, and found nothing)
2. Another toolkit, that doesn't require the installation of MS-office, and can build spreadsheets using C#.
3. Whatever other solution you think might help me...
Thank,
SummerBulb
|
|
|
|
|
private void dgvFactorSell_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (dgvFactorSell.Rows[e.RowIndex].Cells["CStoreCode"].EditedFormattedValue != null && dgvFactorSell.Rows[e.RowIndex].Cells["CStoreCode"].EditedFormattedValue.ToString() != "")
{
e.Cancel = true;
}}
now when i am in this cell and if it doesnt content any data and if i click the close button of form it doesnt do any thing (i mean it doest close the form and remain in the same cell)
ANS :http://s.codeproject.com/script/Forums/Images/smiley_smile.gif
I My Self Solved it !
bool FlagIsClose = false;
const int HTCLOSE = 0x14;
const int WM_NCLBUTTONDOWN = 0xA1;
protected override void DefWndProc(ref Message m)
{
if (m.Msg == WM_NCLBUTTONDOWN)
{
if (m.WParam.ToInt32() == HTCLOSE)
{
FlagIsClose = true;
}
}
base.DefWndProc(ref m);
}
modified on Monday, June 14, 2010 8:46 AM
|
|
|
|
|
Im Creating an RDL report Using VS 2005. It accepts a parameter which i wish to pass as an XML file.
<root>
<emp>
<emp detail ID ="1" name="ritu"/>
<emp detail ID ="2" name ="rishi"/>
</emp>
</root>
How can i filter my report data based on the ID (say 1)
|
|
|
|
|
Hi All,
I have two website 1. ABC 2. Xyz.
And i want to transfer data from one site (i.e ABC site) to another site (Xyz site).
Example:
ABC site have data (name , surname) => Pass this data to => Xyz site.
so, How can i pass this data.. Any Idea??
Thanks & Regards,
Priyanka
|
|
|
|
|
You can use HTTP post for passing the data one site to another. You just need to do is write a simple function in your app which will pass the data from your app internally. A simple code snippets is given below, I hope this might be helpful to you.
strPage = "www.codeproject.com/Get/?id=1234 ......... "
Function PostDatas(ByVal strPage As String) As String
Try
Dim oReq As System.Net.HttpWebRequest
Dim oResp As System.Net.HttpWebResponse
oReq = System.Net.HttpWebRequest.Create(strPage)
oResp = oReq.GetResponse
Dim sr As New StreamReader(oResp.GetResponseStream)
Return sr.ReadToEnd()
Catch
-- Handle exception
End Try
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
You might want to consider web services if you want to set up a communication channel between two web sites.
My signature "sucks" today
|
|
|
|
|
Hello CPers,
I'm trying to get a Winform to do some stuff while a button is pressed down, and stop doing it when the button's let go. I'm trying this out in a simple form with a button and a label. So as long as the button is pressed (MouseDown) the value displayed on the label should keep incrementing by 1. I've tried to used a BackgroundWorker for this and have so far failed. So, in my form class I have:
BackgroundWorker bwAsync = new BackgroundWorker();
public Form1() {
InitializeComponent();
bwAsync.WorkerReportsProgress = true;
bwAsync.WorkerSupportsCancellation = true;
bwAsync.DoWork += new DoWorkEventHandler(bwAsync_DoWork);
}
private void button1_MouseDown(object sender, MouseEventArgs e) {
bwAsync.RunWorkerAsync();
}
private void button1_MouseUp(object sender, MouseEventArgs e) {
bwAsync.CancelAsync();
}
void bwAsync_DoWork(object sender, DoWorkEventArgs e) {
BackgroundWorker bwAsync = sender as BackgroundWorker;
int i;
label1.Invoke( (MethodInvoker)delegate()
{
i = int.TryParse(label1.Text, out i) ? i : 0;
while(!bwAsync.CancellationPending){
Console.WriteLine("down");
label1.Text = i.ToString();
i++;
}
});
}
What happens here is, once it goes into DoWork() it gets stuck in the loop, and it never gets to the MouseUp handler. Anyone have any feeback on my code, or on how it's supposed to be done? Would be much appreciated.
Thank you.
modified on Sunday, June 13, 2010 11:47 PM
|
|
|
|
|
Hi,
your label1.Invoke causes the entire while loop to execute on the main thread (so it is allowed to touch the Label), however that also blocks the thread, so your button1_MouseUp handler cannot react to the button being released. (The main thread processes its event queue, popping and executing one message at a time).
Furthermore, your while loop does not contain any timing control (such as a Thread.Sleep), so it will spin as fast as it can (depending on the characteristics and the load of your system), and clogging your Console.
I would use a very different approach, without BGW:
- have a class member of type System.Windows.Forms.Timer;
- have a class member "int tickCount";
- in button1_MouseDown clear tickCount and launch that timer, with an appropriate interval (say 100 msec), and a tick handler basically containing:
Console.WriteLine("down");
tickCount++;
label1.Text=tickCount.ToString();
- in button1_MouseUp simply stop the timer.
The advantages would be: code is much simpler, everything runs on the main thread, which is idle most of the time, as all it does is run one tick handler every 100 msec.
|
|
|
|
|
THAT was ridiculously easy and clean. To think I spent the better part of the day trying to manipulate threads..
Thanks, Luc!
|
|
|
|
|
No problem.
Yes one tends to find convoluted ways first.
BTW: You may want to switch to a BGW as soon as some real work needs to be done. Then the calculations would go into the DoWork handler (without Invoke!) and hence really run on the BGW thread, however reporting progress or intermediate results to the GUI would best be handled by calling ReportProgress(), which causes the ProgressChanged handler to run on the main thread automatically.
|
|
|
|
|
Your suggestions are much appreciated. Will do
|
|
|
|
|
when u have this message Syntax error in UPDATE statement.how can slove it
|
|
|
|
|
aaga5 wrote: when u have this message Syntax error in UPDATE statement.how can slove it
by fixing the syntax of your UPDATE statement.
if you want more details, maybe you should provide more details.
|
|
|
|
|
aaga5 wrote: Syntax error in UPDATE statement.how can slove it
You can read a documentation of the UPDATE statement here[^]. Stick to the syntax described there and everything should be OK. If not, please tell us what was the query.
Greetings - Jacek
|
|
|
|
|
This is the C# forum.
My signature "sucks" today
|
|
|
|
|
Hi
I'm trying to use the name of a logical drive (c: and d . I can't use them to get access to the physical drive in order to get the type, the model, the interface, the capacity, sectors and cylinders.
My code :
private void Form1_Load(object sender, EventArgs e)
{
ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk");
foreach (ManagementObject moDisk in mosDisks.Get())
{
comboBox2.Items.Add(moDisk["DeviceID"].ToString());
}
}
private void button4_Click_1(object sender, EventArgs e)
{
listView2.Items.Clear()
ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE DeviceID = '" + comboBox2.SelectedItem + "'");
foreach (ManagementObject moDisk in mosDisks.Get())
{
ListViewItem item = listView2.Items.Add("Type: " + moDisk["MediaType"].ToString());
ListViewItem item2 = listView2.Items.Add("Model: " + moDisk["Model"].ToString());
ListViewItem item3 = listView2.Items.Add("Interface: " + moDisk["InterfaceType"].ToString());
ListViewItem item4 = listView2.Items.Add("Capacity: " + moDisk["Size"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(moDisk["Size"]) / 1024) / 1024) / 1024), 2) + " GB)");
ListViewItem item5 = listView2.Items.Add("Partitions: " + moDisk["Partitions"].ToString());
ListViewItem item6 = listView2.Items.Add("Signature: " + moDisk["Signature"].ToString());
ListViewItem item7 = listView2.Items.Add("Cylinders: " + moDisk["TotalCylinders"].ToString());
ListViewItem item8 = listView2.Items.Add("Sectors: " + moDisk["TotalSectors"].ToString());
ListViewItem item9 = listView2.Items.Add("Heads: " + moDisk["TotalHeads"].ToString());
ListViewItem item10 = listView2.Items.Add("Tracks: " + moDisk["TotalTracks"].ToString());
ListViewItem item11 = listView2.Items.Add("Bytes per Sector: " + moDisk["BytesPerSector"].ToString());
ListViewItem item12 = listView2.Items.Add("Sectors per Track: " + moDisk["SectorsPerTrack"].ToString());
ListViewItem item13 = listView2.Items.Add("Tracks per Cylinder: " + moDisk["TracksPerCylinder"].ToString());
ListViewItem item14 = listView2.Items.Add("Description: " + moDisk["Description"].ToString());
}
}
I have used this code and it worked fine but I can't get the letters instead of the Model in the combox
private void Form1_Load(object sender, EventArgs e)
{
ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
foreach (ManagementObject moDisk in mosDisks.Get())
{
comboBox2.Items.Add(moDisk["Model"].ToString());
}
}
private void button4_Click_1(object sender, EventArgs e)
{
listView2.Items.Clear();
ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE Model = '" + comboBox2.SelectedItem + "'");
foreach (ManagementObject moDisk in mosDisks.Get())
{
ListViewItem item = listView2.Items.Add("Type: " + moDisk["MediaType"].ToString());
ListViewItem item2 = listView2.Items.Add("Model: " + moDisk["Model"].ToString());
ListViewItem item3 = listView2.Items.Add("Interface: " + moDisk["InterfaceType"].ToString());
ListViewItem item4 = listView2.Items.Add("Capacity: " + moDisk["Size"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(moDisk["Size"]) / 1024) / 1024) / 1024), 2) + " GB)");
ListViewItem item5 = listView2.Items.Add("Partitions: " + moDisk["Partitions"].ToString());
ListViewItem item6 = listView2.Items.Add("Signature: " + moDisk["Signature"].ToString());
ListViewItem item7 = listView2.Items.Add("Cylinders: " + moDisk["TotalCylinders"].ToString());
ListViewItem item8 = listView2.Items.Add("Sectors: " + moDisk["TotalSectors"].ToString());
ListViewItem item9 = listView2.Items.Add("Heads: " + moDisk["TotalHeads"].ToString());
ListViewItem item10 = listView2.Items.Add("Tracks: " + moDisk["TotalTracks"].ToString());
ListViewItem item11 = listView2.Items.Add("Bytes per Sector: " + moDisk["BytesPerSector"].ToString());
ListViewItem item12 = listView2.Items.Add("Sectors per Track: " + moDisk["SectorsPerTrack"].ToString());
ListViewItem item13 = listView2.Items.Add("Tracks per Cylinder: " + moDisk["TracksPerCylinder"].ToString());
ListViewItem item14 = listView2.Items.Add("Description: " + moDisk["Description"].ToString());
}
}
|
|
|
|
|
I am not sure that you can get the drive letters using the PhysicalDrive. Look up Win32_MappedLogicalDisk in the WMI documentation. From memory it is much easier to get the drive letters that way.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas? - Because 31 Oct = 25 Dec.
Business Myths of the Geek #4 'What you think matters.'
|
|
|
|
|
The logical drives (drive letters) identify partitions, not physical devices. It takes a couple of WMI objects to get most of the information you want; you will probably discover that the very physical characteristics (such as number of cylinders) don't make sense any more as they are virtualized within the drive itself; the local intelligence just makes the disk look like one heap of sectors.
Also, the latest versions of Windows (Vista, 7) are likely to refuse full access, even read access, at the device level unless you are an elevated escalated super-administrator.
|
|
|
|
|
connectionString1 = @"
server = .\sqlexpress;
integrated security = true;
database = C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\NORTHWND.MDF;
user instance = true";
connectionString2 = @"
server = .\sqlexpress;
integrated security = true;
database = northwind";
connectionString1 is working fine and connectionString2 is giving the message "Cannot open database northiwnd. login failed for user XYZ".
Can someone tell me whats the difference
|
|
|
|
|
humayunlalzad wrote: atabase = C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\NORTHWND.MDF;user instance = true";
humayunlalzad wrote: database = northwind";
The difference lies in the user instance = true part of the sql.
Read about user instances here.
My signature "sucks" today
|
|
|
|
|
@"
server = .\sqlexpress;
integrated security = true;
database = northwind;
user instance = true";
I am sorry I should have mentioned before hand, that even the above string with "user instance = true" added is not working
|
|
|
|
|
hi all
i have an win application form suppose to show some reports in CrystalReportView i have no idea how to assign a list<> of class to MyCrystalReport
public Form1()
{
InitializeComponent();
StdList = new List<studants>();
StdList.Add(new studants("1", "1", 1));
StdList.Add(new studants("2", "2", 2));
StdList.Add(new studants("3", "3", 3));
StdList.Add(new studants("4", "4", 4));
StdList.Add(new studants("5", "5", 5));
}
private void Form1_Load(object sender, EventArgs e)
{
CrystalReport1 cr = new CrystalReport1();
cr.SetDataSource(StdList);
crystalReportViewer1.ReportSource = cr;
}
but i have not assigned any table with CrystalReport1 it`s all because of i have not any dataset or database or ... and i do not know how to assign add or assign a list<> of objects to my crytalReport Project (CrystalReport1) how can i assign it and work on it
i should definitely use list<>
please help me!!!!!!!!!!
|
|
|
|