|
Hi all,
My application lets a user select a True Type font from the FontFamily.Families enumeration:
foreach (FontFamily ff in FontFamily.Families)
{
if(ff.IsStyleAvailable(FontStyle.Regular))
fontCombo.Items.Add(ff.Name);
}
This doesn't work for Open Type fonts, e.g. I just installed Costura Light, and it's now available in MS Word, but invisible to my enumeration above.
Googling doesn't reveal any solution to this; all the sites just assume the font is there after you install it.
What do I have to do to make Open-Type fonts available? Thanks!
=========================
EDIT -- THERE'S NO SIMPLE WAY TO DO THIS: GDI+ ONLY SUPPORTS TRUE TYPE. THERE'S A CONVOLUTED WAY TO USE GDI FOR OPEN-TYPE FONTS FROM MANAGED C++ DESCRIBED HERE: http://www.codeguru.com/cpp/g-m/gdi/fonthandlinganddetection/article.php/c10621/Make-GDI-Less-Finicky-About-Fonts.htm[^]
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
modified 4-Jun-12 16:09pm.
|
|
|
|
|
Can someone please provide a sample code which explains all features of OOPS in C#.
Thanks in advance.
Kris
kriskan
|
|
|
|
|
Can someone please explain what the S stands for in OOPS?
could it be OOPSS for object-oriented programming self study?
|
|
|
|
|
|
Would you liked to be tagged "Abusive/Troll"??
Luc is one of the most respected people on this site and your first post is to tell him to "shutup". Nice job introducing yourself.
|
|
|
|
|
There are many examples of C# oops in the Hall of Shame.
|
|
|
|
|
You should ask google....
""Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I think you should pick up a book on object oriented programming and go through it.
A case study will be good for a start but will not be enough to cover more detailed topics like operator overloading etc.
|
|
|
|
|
|
Someone (I guess OP) did not like your offer of help; I have adjusted the score.
|
|
|
|
|
OOPS! The uni-voter did it again...
Countered.
|
|
|
|
|
Just for the record, this is not a question that can be answered in a programming forum. Yes, someone could give you some sample code, but while it might give examples of all features, it would probably not explain them. And in any case, such an answer would take up far too much space. What you are asking for is the text of a book, which is beyond the capabilities of this site. Take a look at some of the links that others have provided and prepare to get down to some serious study.
|
|
|
|
|
i'm new at c#, so i convert my messenger project from vb.net to c#, but after dat the problem occurs.
i got an error saying
//The best overloaded method match for 'System.Net.Sockets.Socket.Receive(ref.System.Net.IPEndPoint)' has some invalid arguments// in this line :
data = ReceivingClient.Receive(endPoint);
i've tried to convert it to Byte but still can't work.
can someone please tell me what's wrong?
here's the full code :
public delegate void AddMessage(ref string message);
private const int Port = 33333;
private const string BroadcastAddress = "255.255.255.255";
private UdpClient ReceivingClient;
private UdpClient SendingClient;
private Thread ReceivingThread;
private bool EnableReceiver = true;
public Client()
{
InitializeComponent();
}
private void Client_Load(object sender, EventArgs e)
{
InitializeSender();
InitializeReceiver();
}
private void MessageReceived(ref string message)
{
textbox1.Text = message;
}
private void Receiver()
{
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, Port);
AddMessage messageDelegate = MessageReceived;
while ((EnableReceiver == true))
{
byte[] data = null;
data = ReceivingClient.Receive(endPoint);
string message = Encoding.ASCII.GetString(data);
Invoke(messageDelegate, message);
}
}
private void InitializeSender()
{
SendingClient = new UdpClient(BroadcastAddress, Port);
SendingClient.EnableBroadcast = true;
}
private void InitializeReceiver()
{
ReceivingClient = new UdpClient(Port);
ThreadStart start = new ThreadStart(Receiver);
ReceivingThread = new Thread(start);
ReceivingThread.IsBackground = true;
ReceivingThread.Start();
}
modify >>>>
finally i found it, like this :
data = ReceivingClient.Receive(ref(endPoint));
thank you very much.
modified 4-Jun-12 6:25am.
|
|
|
|
|
According to the documentation[^] (which is where you should always check first), the Receive() method does not take an endpoint as a parameter.
|
|
|
|
|
The CLR classes are the same, whether you call them from a VB.NET app or a C# app. So if the C# version doesn't work for you, well, something got lost in translation. Wasn't there a ByRef in your VB.NET app?
Midnight Ahri wrote: data = ReceivingClient.Receive(ref(endPoint));
And that is too many parentheses to my taste.
|
|
|
|
|
Hi Guys,
I've made a program to read data from an SQL database and show those in dynamic comboboxes. Now I would like to save all data back to SQL database after changes was made in those comboboxes.
Any ideea how to accomplish this?
Best regards
Vidor
public void showRequill()
{
DataSet dsRequill = new DataSet();
BindingSource bsRequill = new BindingSource();
SqlDataAdapter daRequill = new SqlDataAdapter();
DataTable dtRequill = new DataTable();
int cnt = 0;
try
{
daRequill.SelectCommand = new SqlCommand("select * from RD1 where UserNumber='" + cbWorkerNr.Text + "'", CN);
daRequill.Fill(dsRequill);
daRequill.Fill(dtRequill);
bsRequill.DataSource = dsRequill.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
foreach (DataColumn column in dtRequill.Columns)
{
newLabel = new Label();
newCombo = new ComboBox();
newLabel.Text = column.ColumnName;
newLabel.AutoSize = true;
newLabel.Visible = true;
newCombo.Size = new Size(35, 21);
newCombo.Items.AddRange(new object[] { "U", "S", "E", "B", "L" });
newCombo.Name = "cbRequill_" + cnt.ToString();
newCombo.Visible = true;
newCombo.DataBindings.Clear();
newCombo.DataBindings.Add(new Binding("Text", bsRequill, column.ColumnName));
newCombo.TextChanged += new EventHandler(newCombo_TextChanged);
flpRequill.Controls.Add(newLabel);
flpRequill.Controls.Add(newCombo);
cnt++;
}
}
|
|
|
|
|
Hi,
what i understand is, you have some list of items to display and then after update that items it should be back to the database. correct ?
so what i suggest is, at the time of updating data. Do not use update query. instead remove all those records and insert it again(using single transaction). because you do not have idea about which data is modified.
Or the other solution is, you need to maintain index of the data you get from database. and then match the string value and update only if it modified. but this way leads to so many questions.
let me know above idea works for you,
thanks
-Amit.
|
|
|
|
|
Hi,
The idea seems to be fine, but i don't know how to implement (using single transaction)
The problem is that the column number could be changed so I need to insert somehow with a "foreach" or "for loop". As you can see I managed the reading with foreach and making comboboxes programatically, and I want to save/update in the same way.
Best regards
Vidor
|
|
|
|
|
Hi,
you have UserNumber to get the information. so create one storedProcedure to update your record. in that storedprocedure create one transaction to remove the entries with given UserName and insert Updated Entries. this is what you need to do.
Does it make sense.
Thanks
-amit
|
|
|
|
|
Off topic, but SQL Injection Attack is possible with:
daRequill.SelectCommand = new SqlCommand("select * from RD1 where UserNumber='" + cbWorkerNr.Text + "'", CN);
You should use parameterized queries to be safer.
SQL Injection Attacks and Some Tips on How to Prevent Them[^]
""Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
I have a modal form where in the consturctor I grab some data from a text file and create a dataset/datatable that holds the data and binds it to the datagridview control on the form. When the form is displayed, the dataset/datatable isn't displayed but when I debug through the code and get to line 3 it tells me that the datasource has bound to the dataset/datatable and I can view the datasource in the visualizer. The debugger steps through to line 4 then the form is displayed...but without the dataset/datatable.
I have added at design time the datagridview with two columns corresponding to the columns from the text file and this is what is displayed and not the dataset I've bound it too in the constructor.
Is there an issue with binding in the constructor
cheers
public frmAdjustments()
{
InitializeComponent();
line2 _data = BuildDataSet ("AdjustmentTypes.txt","AdjustmentsTable","|");
line3 dataGridView1.DataSource = _data;
}
private void button1_Click(object sender, EventArgs e)
{
line1 frmAdjustments frmA = new frmAdjustments();
line4 frmA.ShowDialog();
}
Mat
|
|
|
|
|
I fixed it.
I was just binding the dataset and not specifying the datatable. Line 3 is now
dataGridView1.DataSource = _data.Tables[0];
I assumed as there was only one datatable that it could work out that was the one to use...don't ever assume
Mat
|
|
|
|
|
matleeds wrote: don't ever assume
The one assumption that seems valid most of the time is this: if it doesn't work, I assume I did something wrong.
|
|
|
|
|
Hi,
Please see the Example below,the same way i opened modal dialog,which is showing Data also.
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
DataSet ds = new DataSet("myds");
DataTable dt = new DataTable("mydt");
dt.Columns.Add("mycol");
dt.Rows.Add("a");
ds.Tables.Add(dt);
dataGridView1.DataSource = ds.Tables[0];
}
}
//Opening the Modal dialog.
Form2 f = new Form2();
f.ShowDialog();
|
|
|
|
|
Right now a C#.net 2010 application edits the columns for field1 and field2 separately. Now I need to combine the edits together since the two columns are related to each other alot.
Thus here is the following code, can you tell me how you would combine the edits together for these two columns:
(note: data table is obtained from information loaded into an excel 2003 spreadsheet)
public override List<ColumnNames> GetColumnNames()
{
List<ColumnNames> list = base.GetColumnNames();
list.Add(ColumnNames.filed1);
list.Add(ColumnNames.field2);
return list;
}
public override List<RuleError> ValidateData(DateTime receivedDate)
{
base.ValidateData(receivedDate);
DataTable excelData = ExcelDataTable;
string colName = ColumnNames.field2.ToString();
string field2ColName = colMap[colName].ToString();
colName = ColumnNames.filed1.ToString();
string field1ColName = colMap[colName].ToString();
int iEnd = excelData.Rows.Count;
for (int i = DataRowNumber - 1; i < iEnd; i++)
{
DataRow dr = excelData.Rows[i];
{
List<RuleError> list = Validate(dr, receivedDate, didc);
if (list == null)
list = new List<RuleError>();
string field1 = dr[field1ColName].ToString();
re = Validatefield1ible(field1);
if (re != null)
{
list.Add(re);
}
string colVal = dr[field2ColName].ToString();
re = Validatefield2(colVal);
if (re != null)
{
list.Add(re);
}
}
excelData.AcceptChanges();
didc.Dispose();
return masterList;
}
public override List<RuleError> LoadData(ImportWkbk wb, string destDocLoc)
{
string colName = ColumnNames.field2.ToString();
string field2ColName = colMap[colName].ToString();
colName = ColumnNames.filed1.ToString();
string field1ColName = colMap[colName].ToString();
Hashtable htSubs = new Hashtable();
Int64 submissionID = 0;
VCust firstCust = null;
int iEnd = ExcelDataTable.Rows.Count;
for (int i = DataRowNumber - 1; i < iEnd; i++)
{
DataRow dr = ExcelDataTable.Rows[i];
try
{
string field1 = dr[field1ColName].ToString().Trim().ToUpper();
lis.filed1 = field1.Length > 0 ? field1 : null;
string field2 = dr[field2ColName].ToString().Trim().ToUpper();
lis.field2 = field2.Length > 0 ? field2 : null;
didc.SubmitChanges();
didc.Dispose();
return null;
}
public RuleError Validatefield1ible(string field1)
{
RuleError re = null;
if (field1 == null || field1.Trim().Length < 1)
return null;
if (field1.Trim().ToUpper().Equals (field1ibleStatus.PART) ||
field1.Trim().ToUpper().Equals (field1ibleStatus.aLL)
)
{
return null;
}
re = new RuleError(RuleErrorCodes.OTHER, RuleErrorTypes.ERROR, "error 1");
return re;
}
public RuleError Validatefield2(string field2us)
{
RuleError re = null;
if (field2us == null || field2us.Trim().Length < 1)
return null;
if(field2us.Trim().ToUpper().Equals(field2.NO) ||
field2us.Trim().ToUpper().Equals(field2.YES) ||
field2us.Trim().ToUpper().Equals(field2.maybe)
)
{
return null;
}
re = new RuleError(RuleErrorCodes.OTHER, RuleErrorTypes.ERROR, "error 2.");
return re;
}
}
|
|
|
|