|
Hi,
I'm still struggling with a good MVC approach myself, so I don't have the complete answer to your question, however this[^] might be useful to you.
|
|
|
|
|
I have a small project in c# and ms-access. I use query builder to manage my tables in ms-access.
The problem is, select query works great, update query works great, but delete doesn't work and there is no error message!
Please help.
================================
using (cn)
{
OleDbDataAdapter adapter = new OleDbDataAdapter();
string queryString = "SELECT [A],[B] FROM [C]";
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _conStrName + ";User Id=admin;Password=;";
OleDbConnection connection = new OleDbConnection(cn.ConnectionString);
adapter.SelectCommand = new OleDbCommand(queryString, connection);
OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
adapter.SelectCommand.CommandText = queryString;
adapter.DeleteCommand = builder.GetDeleteCommand();
adapter.Update(ds.Tables["resourcesToTasks"]);
return ds;
}
|
|
|
|
|
I have learned a lot doing this project with datagrid views. But I have one issue though minor to me is a major issue to the client. I have been working on this for over 2 weeks and can not find any examples to give me the output I am looking for.
Please Help any Ideas please:
What I need to be able to do is essentially print my database grid column header names vertically at a 90.0F angle. Not horizontally as the default.
I have learned how to do this to the grid itself so it prints correctly on the screen. Which is:
private void dgvReport_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex == -1 && e.ColumnIndex >= 4)
{
e.PaintBackground(e.ClipBounds, true);
Rectangle rect =
this.dgvReport.GetColumnDisplayRectangle(e.ColumnIndex, true);
Size titleSize =
TextRenderer.MeasureText(e.Value.ToString(), e.CellStyle.Font);
if (this.dgvReport.ColumnHeadersHeight < titleSize.Width)
this.dgvReport.ColumnHeadersHeight = titleSize.Width;
e.Graphics.TranslateTransform(0, titleSize.Width);
e.Graphics.RotateTransform(-90.0F);
e.Graphics.DrawString(e.Value.ToString(), e.CellStyle.Font,
Brushes.Black, new PointF(rect.Y, rect.X));
e.Graphics.RotateTransform(90.0F);
e.Graphics.TranslateTransform(0, -titleSize.Width);
e.Handled = true;
}
}
But When I send the grid to the printer the columns are all horizontal not vertical. What can I do to print the columns vertical. Any examples anywhere?
|
|
|
|
|
Found the solution
StringFormat CellFormat = new StringFormat();
CellFormat.FormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip | StringFormatFlags.NoWrap | StringFormatFlags.DirectionVertical;
CellFormat.Alignment = StringAlignment.Center;
g.DrawString(column.HeaderText,
cell.Font(scale),
new SolidBrush(cell.ForeColor()),
CellBounds,
CellFormat);
The StringFormatFlags.DirectionVertical transforms the text vertically. Their is no need to picture draw the text vertically.
|
|
|
|
|
I hace some code which starts:
<br />
if (textBox1.Text.Length > 0)<br />
{<br />
String pat = "*.csv";<br />
Regex r = new Regex (pat, RegexOptions.IgnoreCase);<br />
Match m = r.Match(textBox1.Text);<br />
if (m.Success)<br />
{<br />
GetCSV(textBox1.Text);<br />
}<br />
which is giving me the error: "parsing "*.csv" - Quantifier {x,y} following nothing."
What am I doing wrong please?
|
|
|
|
|
Everything?
Regex pattern patching is not as simple as "*.xxx" for file name: '*' means "repeated zero or more times" and '.' means any character.
If you are trying to match the entire text box with a wild card filename, then why not just do:
if (textBox1.Text == "*.csv")
{
...
} since that will work.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
Or something like if ( textBox1.Text.EndsWith ( ".csv" ) ) ...
But I would likely use a System.IO.FileInfo and check its Extension property.
|
|
|
|
|
Hi
I have created a .NET application with a custom installer, that all works fine.
After the installation process I need to access a file that is located inside the folder where the MSI installer / setup is located.
The problem I have is I cannot work out how to get the path for the MSI installer / setup.
Can anybody please help and advice me the best way to get this path while I am still inside the "Commmited" of the installer
vb.net or C# either will be fine.
Thanks
|
|
|
|
|
|
Hi,
i want to retrieve some content from a webpage.
The method below retrieve the webpage content (in html).
public string GetWebpageContent(string StockQuote)
{
string serverURL = "http://www.google.com/finance?q=" + StockQuote;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serverURL);
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII);
string retVal = reader.ReadToEnd();
reader.Close();
return retVal;
}
Below method retrieve the stockprice in the web content. the html i wan to read consist this
<div>After Hours: <span class=bld id="ref_21913_el">10.60</span>
I wan to retrieve the value 10.60
The id="ref_21913_el" is not a fix value, so i have to read base on
<span class=bld....
public string GetStockPrice()
{
StringBuilder ReversePrice = new StringBuilder();
string Price = "";
MatchCollection StockQuote = Regex.Matches(urlContent, "", RegexOptions.Singleline);
string StockPriceTag = StockQuote[0].Value;
string WithoutEndSpanTag = StockPriceTag.Remove(StockPriceTag.Length - 7, 7);
for (int i = WithoutEndSpanTag.Length - 1; i >= 0; i--)
{
char[] AllChar = WithoutEndSpanTag.ToCharArray();
if (AllChar[i] != '>')
{
ReversePrice.Append(AllChar[i]);
}
else
{
char[] arr = ReversePrice.ToString().ToCharArray();
Array.Reverse(arr);
Price = new string(arr);
break;
}
}
return tbxStockQuote.Text + ", $" + Price;
}
how do i change my MatchCollection StockQuote = Regex.Matches(urlContent, "<span class=bld(.*?)</span>", RegexOptions.Singleline);
so i can read the 10.60 value?
modified on Monday, November 30, 2009 7:37 AM
|
|
|
|
|
If I were u I, I will change the StockPriceTag string to "<root><span class=\"pr\">\n<span id=\"ref_705173_l\">26.83</span> </root>". Then load it in an XML Document. Where you can simple read the value of Span tag.
Cheers.
|
|
|
|
|
Here's a Regular Expression that will match your span and put the price in a named group:
\<span class=bld id=\"[^\"]*\"\>(?'Price'[\d\.]*)\</span\>
Read up on what Regular Expressions can do.
|
|
|
|
|
Hi,
How to play number of files one by one like playlist using windows media player control.
eg:
i have the following files
music1.mp3, music2.mp3, music3.mp3
when i click a button i need to play each files one after one...
thankyou,
YPKI
|
|
|
|
|
Have a look at the file-format ASX.
Here is a sample, hope that helps.
<ASX VERSION="3.0">
<TITLE>Example Media Player Show</TITLE>
<PARAM NAME="Director" VALUE="Jane D." />
<ENTRY>
<TITLE>Example Clip</TITLE>
<REF HREF="http://example.microsoft.com/media.asf" />
<PARAM NAME="Location" VALUE="North America" />
<PARAM NAME="Release Date" VALUE="March 1998" />
</ENTRY>
<ENTRY>
<TITLE>Another Clip</TITLE>
<REF HREF="http://example.microsoft.com/more_media.asf" />
<PARAM NAME="Location" VALUE="Japan">
<PARAM NAME="Release Date" VALUE="December 1996" />
</ENTRY>
</ASX>
[edit] example modified [/edit]
Greetings
Covean
|
|
|
|
|
hello,
try to use the foreach or the for loop in your list
|
|
|
|
|
Hello,
I want to build speech recognition application for vista and xp too. I am using .net framework 3.5.
I have tried many examples for that but i failed to run. It gives me an error say "the language for the grammar does not match the language of the speech recognizer." , i just don't know exactly where i am getting an error.
Please help me, its urgent.
Thank you in advance.
|
|
|
|
|
I think this fails because the Grammer element for the Culture you specified is not installed properly.
If you just ignore it, the Speech Recognition will works I think.
|
|
|
|
|
Thank you,
i have set culture info to my speech recognition language and it works fine. But i want to know if i want to run same application in xp and vista too, is it possible?
|
|
|
|
|
yes why not.
Same thing will run I guess.
|
|
|
|
|
I am using the following code to import a csv file into a datagridview:
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.IO;<br />
<br />
namespace CSVImporter<br />
{<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
List<string[]> csv =<br />
parseCSV("C:\\text.csv");<br />
DataTable newTable = new DataTable();<br />
string[] headers = csv[0];<br />
int counter = 0;<br />
foreach (string column in headers)<br />
{<br />
DataColumn colNewDGCol = new DataColumn();<br />
colNewDGCol.ColumnName = "CSV" + headers[counter];<br />
newTable.Columns.Add(colNewDGCol);<br />
newTable.Columns[counter].HeaderText = headers[counter];<br />
counter++;<br />
}<br />
<br />
foreach (string[] row in csv)<br />
{<br />
newTable.Rows.Add(row);<br />
}<br />
dataGridView1.DataSource = newTable;<br />
}<br />
<br />
public List<string[]> parseCSV(string path)<br />
{<br />
List<string[]> parsedData = new List<string[]>();<br />
<br />
using (StreamReader readFile = new StreamReader(path))<br />
{<br />
string line;<br />
string[] row;<br />
<br />
while ((line = readFile.ReadLine()) != null)<br />
{<br />
row = line.Split(',');<br />
parsedData.Add(row);<br />
}<br />
}<br />
<br />
return parsedData;<br />
}<br />
}<br />
}<br />
<br />
But the line: newTable.Columns[counter].HeaderText = headers[counter];
does not work.
How can I create the appropriate column header text please?
|
|
|
|
|
bonjour,
tu dois faire newTable.Columns[counter].ColumnName = headers[counter];
au lieu de newTable.Columns[counter].HeaderText = headers[counter];
je l'ai testé et j'ai pu afficher les données dans grid view
|
|
|
|
|
Beaucoup de mercis de votre aide. Beaucoup a apprécié.
|
|
|
|
|
For a WinForm application using C#, how to make the form become gray/dark slowly when pop up a dialog? Like XP does when user is going to shut down computer.
Thanks in advance.
|
|
|
|
|
Just open a form maximized with no Titlebar. Make the background of the form black.
Use Opacity of the form below 50, and show the dialog above the form.
I think you will find the same effect.
|
|
|
|
|