|
You can add a COLUMN of checkboxes, you cannot add a chackbox to a single row. I use the following:
DataGridViewCheckBoxColumn oDGC = new DataGridViewCheckBoxColumn();
oDGC.HeaderText = "Sel";
oDGC.Name = "Sel";
oDGC.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
oDGC.FlatStyle = FlatStyle.Standard;
oDGC.CellTemplate = new DataGridViewCheckBoxCell();
oDGC.CellTemplate.Style.BackColor = System.Drawing.Color.Beige;
oDGC.ThreeState = false;
oDG.Columns.Insert(iCol, oDGC);
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
(i hope i write true place)
Hi all, i use the two method shown below, to sent text as html to a word document, but non english characters arent shown in the document. what can i do??
private void button2_Click(object sender, EventArgs e)
{
WordApp = new Word.ApplicationClass();
fileName = @"........";
Microsoft.Office.Interop.Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref Format, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
WordApp.Visible = true;
bookmarkPaste (aDoc, bookmarkinWordDoc,myHtmlScript);
}
public void bookmarkPaste(Word.Document aDoc, string bookmarkAdi, string data)
{
try
{
object bookmark = bookmarkAdi;
object missing = System.Reflection.Missing.Value;
object pasteType = Word.WdPasteDataType.wdPasteHTML;
DataObject clipDO = new DataObject();
if (aDoc.Bookmarks.Exists(bookmark.ToString()))
{
Word.Range rangeTbl = aDoc.Bookmarks.get_Item(ref bookmark).Range;
clipDO.SetData(DataFormats.Html,HtmlClipboardData (data));
Clipboard.SetDataObject(clipDO, true);
rangeTbl.PasteSpecial(ref missing, ref missing, ref missing, ref missing, ref pasteType, ref missing, ref missing);
}
else
{
}
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
}
private static string HtmlClipboardData(string html)
{
StringBuilder sb = new StringBuilder();
Encoding encoding = Encoding.UTF8;
string Header = @"
Version: 1.0
StartHTML: {0:000000}
EndHTML: {1:000000}
StartFragment: {2:000000}
EndFragment: {3:000000}
";
string HtmlPrefix = @"
DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN""&
html;
head;
meta http-equiv=Content-Type content=""text/html; charset={0}"";
/head;
body>
<!--StartFragment-->
";
HtmlPrefix = string.Format(HtmlPrefix, encoding.WebName);
string HtmlSuffix = @"
!--EndFragment--;
/body;
/html;
";
// Get lengths of chunks
int HeaderLength = encoding.GetByteCount(Header);
HeaderLength -= 16; // extra formatting characters {0:000000}
int PrefixLength = encoding.GetByteCount(HtmlPrefix);
int HtmlLength = encoding.GetByteCount(html);
int SuffixLength = encoding.GetByteCount(HtmlSuffix);
// Determine locations of chunks
int StartHtml = HeaderLength;
int StartFragment = StartHtml + PrefixLength;
int EndFragment = StartFragment + HtmlLength;
int EndHtml = EndFragment + SuffixLength;
// Build the data
sb.AppendFormat(Header, StartHtml, EndHtml, StartFragment, EndFragment);
sb.Append(HtmlPrefix);
sb.Append(html);
sb.Append(HtmlSuffix);
//Console.WriteLine(sb.ToString());
return sb.ToString();
}
thanks for everything i have...
|
|
|
|
|
Hello,
We have choosen to use Microsoft Enterprise Library in a project that I am involved with. We wan't to write messages to the windows event log with Enterprise Library. I have succeseeded to with that but I have a question with information regarding the stacktrace. When I look at the event log (Windows 2003 server) I have the full stacktrace listed in the event log and in the bottom of the written event I have the message. I wan't to know how to write only the message to event log. I don't wan't to see the full stacktrace.
/Håkan
|
|
|
|
|
|
Hi
In my login form i have set user name Password as "admin" and "sa"
if i type ADMIN and SA it should not work but its working..
how resolve it
thanks in advance
|
|
|
|
|
Mads115 wrote: In my login form i have set user name Password as "admin" and "sa"
if i type ADMIN and SA it should not work but its working..
how resolve it
How did you checking the use id and password? Where is the code? Did you check with String.Equal() or what ?
|
|
|
|
|
this is the Code I am using
SqlConnection Con1 = new SqlConnection("server=.;database=ab;uid=sa;pwd=max");
Con1.Open();
SqlCommand cmd1 = new SqlCommand("select UserName,Password from mads Where Username= '" + usrtxt.Text + "' and Password ='" + passtxt.Text + "'", Con1);
SqlDataReader dr = cmd1.ExecuteReader();
dr.Read();
if (dr.HasRows == true)
{
prj = new Project_Details(usrtxt.Text);
prj.Show();
}
dr.close;
|
|
|
|
|
SQL is case insensitive. You have to force SQL to turn on the case sensitivity for the select query. Just add the following clause with your select query:
COLLATE SQL_Latin1_General_CP1_CS_AS
Use COLLATE SQL_Latin1_General_CP1_CI_AS for case insensitivity.
It can solve your problem.
Regards
Saanj
Either you love IT or leave IT...
|
|
|
|
|
Mads115 wrote: SqlCommand cmd1 = new SqlCommand("select UserName,Password from mads Where Username= '" + usrtxt.Text + "' and Password ='" + passtxt.Text + "'", Con1);
If this is your live code, Please be careful about SQL Injection .
|
|
|
|
|
Check out the following code:
if (string.Compare("hello", "Hello", false) == 0)
{
//do whatever you wish
}
The third parameter makes the string comparison case sensitive.
Regards
Saanj
Either you love IT or leave IT...
|
|
|
|
|
Hi, i have a problem about threads with windows forms.
When users's sessions ended, i want to show a dialog box to inform them to relogin and then to show the relogin form.
It was ok until i use threads in some forms to improve performance.
When a thread reveices a session error, it shows the relogin form. Actualy i use invoke on the main thread.
But while the dialog form is shown, another thread can make a service call and receive the same session error and so tries to show the same relogin form. But it is clear that only one instance of relogin form must be shown at the same time. So i have to use a locking mechanism. But since the thread that shows the dialog box is the main thread, this causes the main thread enter wait state. So the application freezes.
public bool Relogin() {
Interlocked.Increment(ref waitingThreadCount);
event1.WaitOne();
if(this.loginResult == null) {
loginResult = ReloginForm.Show();
}
Interlocked.Decrement(ref waitingThreadCount);
if(waitingThreadCount == 0) {
loginResult = null;
}
event1.Set();
return loginResult.Value;
}
modified on Thursday, June 11, 2009 2:40 AM
|
|
|
|
|
Hi,
I have CrystalActiveXReportViewerLib11_5.dll for my application. I have used a typed Dataset. In this DataSet there are two DataTables DataTable1 and DataTable2. DataTable1 is used for main report and DataTable2 is for SubReport. When i set DataSource for both DataTable i got a problem. For only one dataTable it is ok.
Any help for this problem is appreciated. It is urgent. My code is like this:
DataTable dtt1 = LoadDataTable();
DataTable dtt2 = LoadFriendDataTable();
CRAXDDRT.Application crxApp = new CRAXDDRT.Application();
CRAXDDRT.Report crxReport = new CRAXDDRT.Report();
crxReport = crxApp.OpenReport(Application.StartupPath+"\\rptHouseLandTaxLetter.rpt",null);
crxReport.Database.Tables[1].SetDataSource(dtt1, null);
//crxReport.Database.Tables[2].SetDataSource(dtt2, null); //error occurred here
this.crViewer.ReportSource = crReport;
this.crViewer.ViewReport();
private DataTable LoadDataTable()
{
CrystalReportTest1.DataSet1.DataTable1DataTable dtReport = new DataSet1.DataTable1DataTable();
foreach (DataRow dr in dt.Rows)
{
dtReport.Rows.Add(dr.ItemArray);
}
return dtReport;
}
private DataTable LoadFriendDataTable()
{
CrystalReportTest1.DataSet1.DataTable2DataTable frienddt = new DataSet1.DataTable2DataTable();
foreach (DataRow dr in dt.Rows)
{
frienddt.Rows.Add(dr.ItemArray);
}
return frienddt;
}
modified on Wednesday, June 10, 2009 12:59 AM
|
|
|
|
|
Hi,
I am trying to add ecgraph3d control to my project using VS 2005, the error "failed to import the activex control. please ensure it is properly registered" poped up.
I need help to fix this problem. Thank a lot in advance!
Brandon.
|
|
|
|
|
Have you registered the control ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Yes, I did register control using regsvr32.exe
I have been using a lot of ocx control so far and this is the only one give me that error.
Thanks,
Brandon
|
|
|
|
|
Assuming your control got registered successfully, try clearing all the files in obj/debug or obj/release. Now try to add the control again.
If you have problem in registering control using regsvr32 , use dependency walker and profile regsvr32 by specifying the dll to be registered.
|
|
|
|
|
Navaneeth,
I have tried many time to delete the files in obj and debug folder but the error is still there.
I am not sure I have problem using regsvr32 or not since I have used to register a lot of controls so far. All works fine, except this control ecgraph3D.ocx
How can I use dependency walker and profile regsvr32 ?
Many thanks,
Brandon
|
|
|
|
|
brandonwong123 wrote: I am not sure I have problem using regsvr32 or not
The problem is obviously going to be specific to the control.
Does the control come with any samples ? Do they work ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Christian,
The control comes with visual basic 6 example and it works on my machine. This company has ecgraph.ocx and it works on my visual studio 2005. Now they just have ecgraph3D.ocx as their new product but this control doesn't want to work on my C# 2005
Thanks,
Brandon
|
|
|
|
|
So the VB6 sample you have is for the new control, or the old one ? If that works, then the issue is somewhere in how you're importing the file.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Christian,
The VB6 example is for the new control. I just try to add control on different computer and error is the same.
I am not sure what is causing this problem.
Any further help, please let me know.
Thanks,
Brandon
|
|
|
|
|
Hello All,
I hope someone can help. I have a dataGridView populated with data, I have added a dataGridViewComboBoxColumn. The dataGridViewComboBoxColumn is populated per row. That all works great. The issue I am having is getting the value of a dataGridViewComboBoxColumn Cell.
The last thing I tired is:
DataGridViewComboBoxCell cell = dataGridView1[cntR, cntC] as DataGridViewComboBoxCell;
string val = cell.ValueMember.ToString();
string val2 = cell.Value.ToString();
Which always returns "" for both.
Any help would really be great.
j
|
|
|
|
|
i have the same problem
dgvPhysioSession.Rows[rowIndex].Cells["Diagnosis"].Value
it returns null
|
|
|
|
|
Humm this is a puzzler im settings from a .txt file which looks like this
//This is the directory which your downloaded files will be stored in
DownloadFolder = /mnt/md1/public/Downloads
//The telnet user usualy root
TelnetUser = root
//The telnet password
TelnetPassword = root
//The IP of your NAS eg 192.168.2.2
TelnetIP = 192.168.2.2
I want to convert these values into strings eg TelnetIP = 192.168.2.2 so they can be reused on multiple forms . So ive got them importing with a StreamReader below
private void LoadSettings()
{
StreamReader Settings = new StreamReader("Settings.txt");
string line;
while ((line = Settings.ReadLine()) != null)
{
if (line.StartsWith("/"))
{
}
else
{
string[] splitArray = line.Split(new char[] { '=' });
MessageBox.Show(splitArray[0]);
}
}
}
So in this case splitArray[0] gives DownloadFolder and splitArray[1] gives /mnt/md1/public/Downloads perfect but how do i join them back togeather to give
DownloadFolder = /mnt/md1/public/Downloads
And also im getteng blank lines coming through as settings else if (line.StartsWith("/r/n")) or \r\n dosnt seem to catch them
any ideas ? thanks
|
|
|
|
|
I do not know if this will work but I know when I use string you have to be careful of slashes and so on so for one you could try:
private void LoadSettings()
{
StreamReader Settings = new StreamReader("Settings.txt");
string line;
while ((line = Settings.ReadLine()) != null)
{
if (line.StartsWith(@"/"))
{
}
else
{
string[] splitArray = line.Split(new char[] { '=' });
MessageBox.Show(splitArray[0]);
}
}
}
The at symbol will ensure it is read as string....
as for getting the strings back together you could use a string builder or just add the values together
string var = (splitArray[0] + " = " + splitArray[1]);
I am not sure if that is the best way to do it. Hope that helps.
|
|
|
|